【发布时间】:2022-01-06 20:06:39
【问题描述】:
考虑下面的代码:
import tensorflow as tf
test=tf.constant([[[100., 2., -30.],[-4,5,6]], [[4., 5., 6.],[-7,8,9]]]) # matrix
print(test)
test1=tf.constant([[[100.]],[[ 8.]]])
print(test1)
将 test1 添加到 test 的前两列时,我们会得到以下输出:
print(test[:,:,0:2]+test1)
我不想将 test1 变量添加到测试变量的最后一列,但同时我想在输出中包含测试变量的最后一列不变:
[[[200. 102., -30.]
[ 96. 105., 6.]]
[[ 12. 13., 6]
[ 1. 16., 9]]]
如何快速编写代码?
【问题讨论】:
标签: python tensorflow tensorflow2.0 tensor addition