This commit is contained in:
Ali Hamdi 2017-06-09 22:34:07 +02:00
parent 2fce3b195e
commit f25f985109
3 changed files with 5 additions and 2 deletions

View File

@ -33,6 +33,7 @@ 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)) graph(::typeof(reshape), x, dims) = TensorFlow.reshape(x,convert(Tensor{Int32},dims))
graph(::typeof(Flux.tile), args...) = TensorFlow.tile(args...) graph(::typeof(Flux.tile), args...) = TensorFlow.tile(args...)
graph(::typeof(fill), x, dims) = Ops.fill(convert(Tensor{Int32}, dims), Tensor(x))
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,

View File

@ -1,6 +1,7 @@
export reshape, tile export reshape, tile, fill
import Base: reshape import Base: reshape, fill
reshape(x::AbstractArray, dims::AbstractArray) = reshape(x,tuple(dims...)) reshape(x::AbstractArray, dims::AbstractArray) = reshape(x,tuple(dims...))
tile(x::AbstractArray, mult::AbstractArray) = repeat(x,outer=tuple(mult...)) tile(x::AbstractArray, mult::AbstractArray) = repeat(x,outer=tuple(mult...))
fill{T}(x::T, dims::AbstractArray) = fill(x,tuple(dims...))

View File

@ -51,6 +51,7 @@ end
@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 @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
A = randn(Float32,(4,3,1)) A = randn(Float32,(4,3,1))
@test tf(@net (x,y) -> Flux.tile(x,y))(A,[1,1,3]) repeat(A,outer=(1,1,3)) @test tf(@net (x,y) -> Flux.tile(x,y))(A,[1,1,3]) repeat(A,outer=(1,1,3))
@test tf(@net (x,y) -> fill(x,y))(3.2,[3,2]) convert(Array{Float32},3.2*ones(3,2))
end end
end end