Athos
Athos

Reputation: 165

How to pass tf.glorot_uniform_initializer() into tf.Variable(0 not get_variable()

For tensorflow I would like to create a tf variable using tf.Variable

test = tf.Variable()

and usingtf.glorot_uniform_initializer()with the shape = [ 2 , 3 ]

I know I can use

w2 =tf.get_variable( "w2" , shape = [ hiddensize ,
    outputsize ] , initializer =
    tf.glorot_uniform_initializer() , dtype =
    tf.float32
    )

but it may potential gets scope error, tf.Variable() won't.

If anyone can help me, I would much appreciate it.

Upvotes: 2

Views: 1849

Answers (1)

javidcf
javidcf

Reputation: 59731

You can get an initial value from the initializer just using it as a callable:

test = tf.Variable(tf.glorot_uniform_initializer()((2, 3)))

Upvotes: 2

Related Questions