创建一个常数张量,传入list或者数值来填充
tensor = tf.constant([1, 2, 3, 4, 5, 6, 7])
with tf.Session() as sess:
print(sess.run(tensor))---
[1 2 3 4 5 6 7]
a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3])
with tf.Session() as sess:
print(sess.run(a))
-----
[[1 2 3] [4 5 6]]