Tensorflow "feed" confusion -
i seem misunderstanding way "feeding" supposed work in tensorflow. here simple example of issue:
import tensorflow tf x = tf.variable(0.0,dtype=tf.float32) sess = tf.session() sess.run(tf.global_variables_initializer()) print(sess.run(x)) # prints 0.0 expected sess.run(x,feed_dict={x:1.0}) print(sess.run(x)) # prints 0.0 again, expected see 1.0
so, how feed value tensor , value "stick"?
thanks in advance!
import tensorflow tf y = tf.variable(0.0, name='y') init = tf.global_variables_initializer() tf.session() sess: sess.run(init) print("initial value : ", sess.run(y)) print("feeding values using dict :" ,sess.run(y, feed_dict={y:1.0})) print("final value : ",sess.run(y)) t = tf.assign(y,10) print("assigned new value variable using assign method: ", t.eval()) print("final value : ", sess.run(y))
output:
initial value : 0.0 feeding values using dict : 1.0 final value : 0.0 assigned new value variable using assign method: 10.0 final value : 10.0
i hope clarifies concept
Comments
Post a Comment