add reshape

This commit is contained in:
Ali Hamdi 2017-06-09 22:13:25 +02:00
parent 9e0b6af7a8
commit 7aad224206
4 changed files with 9 additions and 1 deletions

View File

@ -23,7 +23,7 @@ include("core.jl")
import .FluxCore: back!, update!, graph import .FluxCore: back!, update!, graph
include("utils.jl") include("utils.jl")
include("ops.jl")
include("params.jl") include("params.jl")
include("compiler/code.jl") include("compiler/code.jl")

View File

@ -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, dim) = TensorFlow.size(x,convert(Tensor{Int32}, dim))
graph(::typeof(size), x) = TensorFlow.size(x) graph(::typeof(size), x) = TensorFlow.size(x)
graph(::typeof(chol), args...) = TensorFlow.transpose(TensorFlow.cholesky(args...)) 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, for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos,
sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj, sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj,

5
src/ops.jl Normal file
View File

@ -0,0 +1,5 @@
export reshape
import Base: reshape
reshape(x::AbstractArray, dims::AbstractArray) = reshape(x,tuple(dims...))

View File

@ -47,6 +47,8 @@ end
A = randn(6,5) A = randn(6,5)
A = A'*A A = A'*A
@test tf(@net x -> chol(x))(A) chol(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
end end