Я пытаюсь использовать tf.scatter_add
, но не понимаю, почему я получаю эту ошибку:
c = tf.Variable(tf.constant([[2, 0, 0],
[0, 3, 0],
[0, 0, 0]]))
indices = [[1, 1]] # A list of coordinates to update.
values = [1] # A list of values corresponding to the respective
# coordinate in indices
shape = [3, 3] # The shape of the corresponding dense tensor, same as `c`.
offset = tf.scatter_nd(indices, values, shape)
add = tf.scatter_add(c, indices, values)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(add)
print(c.eval())
ValueError: Фигуры должны иметь одинаковый ранг, но имеют 1 и 3 для 'ScatterAdd_22' (op: 'ScatterAdd') с входными формами: [3,3], [1,2], [1].
У меня нет проблем с использованием tf.scatter_nd
.