【发布时间】:2017-12-05 14:24:27
【问题描述】:
我有一个 3-D 张量,我想在其中更新一些值,就像在这个 numpy 代码中一样:
x_np = np.zeros((2,3,2))
updates_np = np.ones((2,2))
indices_1 = np.array([0, 1])
indices_2 = np.array([1, 1])
x_np[indices_1, indices_2, :] = updates_np
结果如下:
>>> x_np
array([[[ 0., 0.],
[ 1., 1.],
[ 0., 0.]],
[[ 0., 0.],
[ 1., 1.],
[ 0., 0.]]])
我想更新最后一个维度上的完整行,为此我尝试使用scatter_update(我也尝试使用dynamic_stitch)。但似乎 scatter_update 不接受超过一维作为更新索引。
如何在张量流中做到这一点?
【问题讨论】:
标签: python tensorflow