tf.shape

tf.shape([1])
Out[39]: <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>
tf.shape([[1]])
Out[40]: <tf.Tensor: shape=(2,), dtype=int32, numpy=array([1, 1], dtype=int32)>
tf.shape([[[1]]])
Out[41]: <tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 1, 1], dtype=int32)>
tf.shape([[[1,2]]])
Out[44]: <tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 1, 2], dtype=int32)>
tf.shape([[1,2,3],[4,5,6]])
Out[46]: <tf.Tensor: shape=(2,), dtype=int32, numpy=array([2, 3], dtype=int32)>
a = tf.keras.layers.Input((None, 10))
a
Out[64]: <tf.Tensor 'input_4:0' shape=(None, None, 10) dtype=float32>

a.shape
Out[65]: TensorShape([None, None, 10])

tf.shape(a)
Out[66]: <tf.Tensor 'Shape_12:0' shape=(3,) dtype=int32>
posted @ 2022-08-19 22:49  luoganttcc  阅读(6)  评论(0)    收藏  举报