【发布时间】:2021-04-20 09:47:51
【问题描述】:
问题确实在标题中,我正在寻找 scipy/numpy/etc 中的方法。 (不是 TensorFlow),它封装了 tf.tensor_scatter_nd_add 中描述的行为,但在 Numpy 数组而不是张量上。
我遇到了scipy.ndimage.sum 方法,但无法重现我在下面给出的示例。
您认为适合的任何方法都必须能够重现 TF 文档中提供的 rank-3 示例:
indices = tf.constant([[0], [2]])
updates = tf.constant([[[5, 5, 5, 5], [6, 6, 6, 6],
[7, 7, 7, 7], [8, 8, 8, 8]],
[[5, 5, 5, 5], [6, 6, 6, 6],
[7, 7, 7, 7], [8, 8, 8, 8]]])
tensor = tf.ones([4, 4, 4],dtype=tf.int32)
updated = tf.tensor_scatter_nd_add(tensor, indices, updates)
print(updated)
希望有人以前解决过类似的问题并可以在这里提供帮助 - 提前致谢!
【问题讨论】:
标签: python numpy tensorflow scipy