Reputation: 381
I am having You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [2,2]
error.I have already fed the placeholderaa
import numpy as np
import tensorflow as tf
aa = tf.placeholder(dtype=tf.float32, shape=(2, 2))
bb = tf.Variable(aa)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
print(sess.run(bb,feed_dict={aa:np.random.rand(2,2)}))
Upvotes: 1
Views: 859
Reputation: 59701
The problem is in sess.run(init)
; you need a value for aa
in order to initialize bb
. aa
is not needed to retrieve bb
later, though, since it already has been assigned a value.
import numpy as np
import tensorflow as tf
aa = tf.placeholder(dtype=tf.float32, shape=(2, 2))
bb = tf.Variable(aa)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init, feed_dict={aa: np.random.rand(2, 2)})
print(sess.run(bb))
Upvotes: 2