tf.reshape

官方文档链接

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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值