官方文档链接
https://www.tensorflow.org/api_docs/python/tf/reshape
调用
tf.reshape(
tensor,
shape,
name=None
)
It means that tf.reshape produces a new tensor.
x = tf.constant([29.05088806, 27.61298943, 31.19073486, 29.35532951,
30.97266006, 26.67541885, 38.08450317, 20.74983215,
34.94445419, 34.45999146, 29.06485367, 36.01657104,
27.88236427, 20.56035233, 30.20379066, 29.51215172,
33.71149445, 28.59134293, 36.05556488, 28.66994858])
y = x #只是将一个变量y指向了x所指向的Tensor对象,并没有创建新的Tensor,用以判断进行了reshape操作后,原Tensor是否改变,是否创建了新的Tensor对象
x = tf.reshape(x,[5,-1])
print(sess.run(x))
print(sess.run(y))
[[29.050888 27.61299 31.190735 29.35533 ]
[30.97266 26.675419 38.084503 20.749832]
[34.944454 34.45999 29.064854 36.01657 ]
[27.882364 20.560352 30.20379 29.512152]
[33.711494 28.591343 36.055565 28.669949]]
[29.050888 27.61299 31.190735 29.35533 30.97266 26.675419 38.084503
20.749832 34.944454 34.45999 29.064854 36.01657 27.882364 20.560352
30.20379 29.512152 33.711494 28.591343 36.055565 28.669949]