add randn

This commit is contained in:
Ali Hamdi 2017-06-10 00:38:16 +02:00
parent cd8c2c2f83
commit 6d106c914d
3 changed files with 5 additions and 2 deletions

View File

@ -38,6 +38,7 @@ graph(::typeof(Flux.cast), args...) = TensorFlow.cast(args...)
graph(::typeof(solve), A, b) = TensorFlow.matrix_solve(A, b)
graph(::typeof(triangular_solve), A, b) = TensorFlow.matrix_triangular_solve(A, b; lower=false)
graph(::typeof(randu), x) = Ops.random_uniform(convert(Tensor{Int32},x);dtype=Float32)
graph(::typeof(randn), x) = TensorFlow.random_normal(convert(Tensor{Int32},x);dtype=Float32)
for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos,
sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj,

View File

@ -1,6 +1,6 @@
export reshape, tile, fill, cast, solve, triangular_solve, randu
export reshape, tile, fill, cast, solve, triangular_solve, randu, randn
import Base: reshape, fill
import Base: reshape, fill, randn
reshape(x::AbstractArray, dims::AbstractArray) = reshape(x,tuple(dims...))
tile(x::AbstractArray, mult::AbstractArray) = repeat(x,outer=tuple(mult...))
@ -9,3 +9,4 @@ cast{T}(x::AbstractArray, ::Type{T}) = convert(Array{T},x)
solve(A::AbstractArray, b::AbstractArray) = A\b
triangular_solve(A::AbstractArray, b::AbstractArray) = A\b
randu(x::AbstractArray) = rand(tuple(x...))
randn(x::AbstractArray) = randn(tuple(x...))

View File

@ -59,6 +59,7 @@ end
_,A,_ = lu(A)
@test tf(@net (x,y) -> triangular_solve(x,y))(A,b) A\b
@test size(tf(@net x -> randu(x))([2,3])) == (2,3)
@test size(tf(@net x -> randn(x))([2,3])) == (2,3)
end
end