Tensorflow ValueError: The form must be rank 1, but rank 2

import tensorflow as tf x = [[1,2,3],[4,5,6]] y = [0,1] z = [1,2] x = tf.constant(x) y = tf.constant(y) z = tf.constant(z) m = x[y,z] 

I expect m = [2,6]

I can get the result byanano or numpy. How to get the result using tensor flow?

+5
source share
1 answer

Would you like to use tf.gather_nd

  slices = tf.gather_nd(x, [y, z]) 

Hope this helps.

+5
source

Source: https://habr.com/ru/post/1259120/


All Articles