Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializing variable with another variable using tensorflow

I am building neural network using denoising stacked autoencoders. I train autoencoder and then I would like to take the matrix of weights W and copy/initialize/clone it's values into new variable which is used in supervised optimization. How can I do such thing?

.initialized_value() doesn't work for me :/

like image 520
Snurka Bill Avatar asked Sep 16 '26 20:09

Snurka Bill


1 Answers

Use var.assign, ie

vara = tf.Variable(0)
varb = tf.Variable(0)
init_op = tf.initialize_all_variables()
sess = tf.InteractiveSession()
sess.run([init_op])
sess.run([vara.assign_add(1)])
print 'variable a', vara.eval()
print 'variable b', varb.eval()
sess.run([varb.assign(vara)])
print 'variable b', varb.eval()

You should see

variable a 1
variable b 0
variable b 1
like image 77
Yaroslav Bulatov Avatar answered Sep 18 '26 10:09

Yaroslav Bulatov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!