Cannot create a random tensor


#1

Hello all,
Does anyone have experience with random number generation in TensorFlow.jl?
At the moment, I am failing to create a random_normal. If I invoke

random_normal([5,5])

I receive following error message:

ERROR: Tensorflow error: Status: NodeDef missing attr 'dtype' from Op<name=RandomStandardNormal; signature=shape:T -> output:dtype; attr=seed:int,default=0; attr=seed2:int,default=0; attr=dtype:type,allowed=[DT_HALF, DT_FLOAT, DT_DOUBLE]; attr=T:type,allowed=[DT_INT32, DT_INT64]; is_stateful=true>; NodeDef: random_normal_11/RandomStandardNormal_11 = RandomStandardNormal[T=DT_INT64, _class=[], seed=0, seed2=0](random_normal_11/RandomStandardNormal_11/Const_95)

Stacktrace:
 [1] check_status at /Users/tpevny/.julia/v0.6/TensorFlow/src/core.jl:405 [inlined]
 [2] TensorFlow.Operation(::TensorFlow.NodeDescription) at /Users/tpevny/.julia/v0.6/TensorFlow/src/core.jl:969
 [3] #random_standard_normal#1831(::Void, ::Void, ::Void, ::Void, ::Function, ::Array{Int64,1}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/ops/imported_ops.jl:18158
 [4] (::TensorFlow.Ops.#kw##random_standard_normal)(::Array{Any,1}, ::TensorFlow.Ops.#random_standard_normal, ::Array{Int64,1}) at ./<missing>:0
 [5] (::TensorFlow.##166#167{Float64,Float64,Void,Array{Any,1},Array{Int64,1}})() at /Users/tpevny/.julia/v0.6/TensorFlow/src/ops/sequences.jl:27
 [6] with_op_name(::TensorFlow.##166#167{Float64,Float64,Void,Array{Any,1},Array{Int64,1}}, ::Void, ::String) at /Users/tpevny/.julia/v0.6/TensorFlow/src/core.jl:924
 [7] #random_normal#165 at /Users/tpevny/.julia/v0.6/TensorFlow/src/ops/sequences.jl:26 [inlined]
 [8] random_normal(::Array{Int64,1}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/ops/sequences.jl:25

and if I supply d_type

random_normal([5,5],dtype=Float32)

I receive

Error showing value of type TensorFlow.Tensor{Float64}:
ERROR: MethodError: Cannot `convert` an object of type Array{Int64,1} to an object of type TensorFlow.TensorShape
This may have arisen from a call to the constructor TensorFlow.TensorShape(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] setindex!(::Dict{Tuple{String,Int64},TensorFlow.TensorShape}, ::Array{Int64,1}, ::Tuple{String,Int64}) at ./dict.jl:420
 [2] _get_shape(::TensorFlow.Tensor{Float32}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:107
 [3] (::TensorFlow.ShapeInference.##7#8)(::TensorFlow.Operation) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:144
 [4] _get_shape(::TensorFlow.Tensor{Float64}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:103
 [5] (::TensorFlow.ShapeInference.##17#18)(::TensorFlow.Operation) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:190
 [6] _get_shape(::TensorFlow.Tensor{Float64}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:103
 [7] (::TensorFlow.ShapeInference.##17#18)(::TensorFlow.Operation) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:190
 [8] _get_shape(::TensorFlow.Tensor{Float64}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/shape_inference.jl:103
 [9] show(::IOContext{Base.Terminals.TTYTerminal}, ::TensorFlow.Tensor{Float64}) at /Users/tpevny/.julia/v0.6/TensorFlow/src/show.jl:48
 [10] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::TensorFlow.Tensor{Float64}) at ./REPL.jl:122
 [11] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::TensorFlow.Tensor{Float64}) at ./REPL.jl:125
 [12] display(::TensorFlow.Tensor{Float64}) at ./multimedia.jl:194
 [13] eval(::Module, ::Any) at ./boot.jl:235
 [14] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [15] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [16] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

I am rather puzzled here.

Furthermore, I would like to ask, if it is possible to create random tensor with a shape that will be inferred dynamically on basis of on other tensor. Something along the line

x=random_normal(shape(y))

where y will have shape [-1,d]

Thank you very much for answers. I have posted this as an issue to TensorFlow.jl