diff --git a/src/Flux.jl b/src/Flux.jl index 9a508002..f8db5553 100644 --- a/src/Flux.jl +++ b/src/Flux.jl @@ -23,7 +23,7 @@ include("core.jl") import .FluxCore: back!, update!, graph include("utils.jl") - +include("ops.jl") include("params.jl") include("compiler/code.jl") diff --git a/src/backend/tensorflow/graph.jl b/src/backend/tensorflow/graph.jl index b34e23a7..9b73cfa7 100644 --- a/src/backend/tensorflow/graph.jl +++ b/src/backend/tensorflow/graph.jl @@ -31,6 +31,7 @@ graph(::typeof(svd), x) = svd(x) graph(::typeof(size), x, dim) = TensorFlow.size(x,convert(Tensor{Int32}, dim)) graph(::typeof(size), x) = TensorFlow.size(x) graph(::typeof(chol), args...) = TensorFlow.transpose(TensorFlow.cholesky(args...)) +graph(::typeof(reshape), x, dims) = TensorFlow.reshape(x,convert(Tensor{Int32},dims)) for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos, sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj, diff --git a/src/ops.jl b/src/ops.jl new file mode 100644 index 00000000..69329b00 --- /dev/null +++ b/src/ops.jl @@ -0,0 +1,5 @@ +export reshape + +import Base: reshape + +reshape(x::AbstractArray, dims::AbstractArray) = reshape(x,tuple(dims...)) diff --git a/test/backend/tensorflow.jl b/test/backend/tensorflow.jl index 1dcfdf53..7d1940e6 100644 --- a/test/backend/tensorflow.jl +++ b/test/backend/tensorflow.jl @@ -47,6 +47,8 @@ end A = randn(6,5) A = A'*A @test tf(@net x -> chol(x))(A) ≈ chol(A) + A = randn(Float32,(6,3)) + @test transpose(tf(@net (x,y) -> reshape(x,y))(transpose(A),[2,9])) ≈ reshape(A,(9,2)) # Note: TF is row major and julia is not end end