import tensorflow as tf
logits=tf.constant([[1.0,2.0,3.0],[1.0,2.0,3.0],[1.0,2.0,3.0]])
labels = tf.constant([[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0]])
logits_ = tf.reshape(logits, [-1, 1])
labels_ = tf.reshape(labels, [-1, 1])
print(logits.shape.as_list())
print(labels.shape.as_list())
print(logits_.shape.as_list())
print(labels_.shape.as_list())
输出
[3, 3]
[3, 3]
[9, 1]
[9, 1]
【1】 [TensorFlow笔记] 获取Tensor的维度(tf.shape(x)、x.shape和x.get_shape()的区别)_手撕机的博客-CSDN博客_获取tensor的shape