What does tf.gather_nd intuitively do?

Ok, so think about it like this:

You are providing a list of index values to index the provided tensor to get those slices. The first dimension of the indices you provide is for each index you will perform. Let’s pretend that tensor is just a list of lists.

[[0]] means you want to get one specific slice(list) at index 0 in the provided tensor. Just like this:

[tensor[0]]

[[0], [1]] means you want get two specific slices at indices 0 and 1 like this:

[tensor[0], tensor[1]]

Now what if tensor is more than one dimensions? We do the same thing:

[[0, 0]] means you want to get one slice at index [0,0] of the 0-th list. Like this:

[tensor[0][0]]

[[0, 1], [2, 3]] means you want return two slices at the indices and dimensions provided. Like this:

[tensor[0][1], tensor[2][3]]

I hope that makes sense. I tried using Python indexing to help explain how it would look in Python to do this to a list of lists.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)