a = tf.placeholder(dtype=tf.int32, shape=[2])
print(a)
a = tf.reduce_max(a)
print(a)
with tf.Session() as sess:
print(sess.run(a, feed_dict={a:[5,10]}))
out:
Tensor("Placeholder:0", shape=(2,), dtype=int32)
Tensor("Max:0", shape=(), dtype=int32)
Traceback (most recent call last):
File "/home/hdj/yk/WEBQA/ceshi.py", line 16, in <module>
print(sess.run(a, feed_dict={a: [5,10]}))
File "/home/hdj/anaconda3/envs/ky/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 905, in run
run_metadata_ptr)
File "/home/hdj/anaconda3/envs/ky/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1116, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2,) for Tensor 'Max:0', which has shape '()'
a = tf.placeholder(dtype=tf.int32, shape=[])
b = a + a
b = b + b
with tf.Session() as sess:
print(sess.run(b, feed_dict={a:2}))
out:
8