Код: Выделить всё
outputКод: Выделить всё
updatesЯ прочитал документацию Tensorflow (я работаю с версией графического процессора 1.13.1) и обнаружил, что tf.scatter_nd должен подойти для моей проблемы. Проблема в том, что я не могу заставить это работать; Кажется, у меня возникли проблемы с пониманием того, как мне организовать idx.
Давайте рассмотрим пакетный_размер = 2, поэтому я делаю следующее:
Код: Выделить всё
updates = tf.constant([[1, 2, 3], [4, 5, 6]]) # shape [2, 3]
output_shape = tf.constant([2, 1, 4, 4])
idx = tf.constant([[[1, 0], [1, 1], [1, 0]], [[0, 0], [0, 1], [0, 2]]]) # shape [2, 3, 2]
idx_expanded = tf.expand_dims(idx, 1) # so I have shape [2, 1, 3, 2]
output = tf.scatter_nd(idx_expanded, updates, output_shape)
Код: Выделить всё
ValueError: The outer 3 dimensions of indices.shape=[2,1,3,2] must match the outer 3 dimensions of updates.shape=[2,3]: Shapes must be equal rank, but are 3 and 2 for 'ScatterNd_7' (op: 'ScatterNd') with input shapes: [2,1,3,2], [2,3], [4]Буду признателен за любую помощь.>
Подробнее здесь: https://stackoverflow.com/questions/569 ... al-tensors
Мобильная версия