Tensorflow中显示shape的真值
a = tf.constant([[3, 4]], dtype=tf.float32)
可不定义,没有小数点int32,有小数点float32
print(a)
print(tf.shape(a))
这个就是对shape[1,2]的print [1,2]的操作名称是Shape:0,shape是(2),数据类型是Int32
with tf.Session() as sess:
print(sess.run(tf.shape(a)))
# 这样就可以输出[1 2]
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/7025acd44011e7e4e3de10234ba19c6b.png)