tf.reshape(): 改变张量的维度
np.reshape():改变array的维度
tf.get_shape()是获取张量的维度
np.shape是获取array的维度
tf的两个都是方法,np改变大小是方法,获取大小是属性
tf测试代码
>>> a=tf.constant([[1,2,3],[4,5,6]])
>>> tf.reshape(a,(3,2))
<tf.Tensor 'Reshape:0' shape=(3, 2) dtype=int32>
>>> a.get_shape()
TensorShape([Dimension(2), Dimension(3)])
np代码
>>> a=np.array([[1,2,3],[4,5,6]])
>>> np.reshape(a,(3,2))
array([[1, 2],
[3, 4],
[5, 6]])
>>> a.shape
(2, 3)