У меня возникли проблемы с пониманием базовой концепции с тензорным потоком. Как работает индексирование для тензорных операций чтения/записи? Чтобы сделать это конкретным, как можно преобразовать следующие примеры numpy в tensorflow (используя тензоры для массивов, индексов и значений):
x = np.zeros((3, 4))
row_indices = np.array([1, 1, 2])
col_indices = np.array([0, 2, 3])
x[row_indices, col_indices] = 2
x
с выходом:
array([[ 0., 0., 0., 0.],
[ 2., 0., 2., 0.],
[ 0., 0., 0., 2.]])
... и...
x[row_indices, col_indices] = np.array([5, 4, 3])
x
с выходом:
array([[ 0., 0., 0., 0.],
[ 5., 0., 4., 0.],
[ 0., 0., 0., 3.]])
... и, наконец,...
y = x[row_indices, col_indices]
y
с выходом:
array([ 5., 4., 3.])