Tutorial by Examples

Refer to the tf.slice(input, begin, size) documentation for detailed information. Arguments: input: Tensor begin: starting location for each dimension of input size: number of elements for each dimension of input, using -1 includes all remaining elements Numpy-like slicing: # x has shape...
Generally tf.gather gives you access to elements in the first dimension of a tensor (e.g. rows 1, 3 and 7 in a 2-dimensional Tensor). If you need access to any other dimension than the first one, or if you don't need the whole slice, but e.g. only the 5th entry in the 1st, 3rd and 7th row, you are b...
This example is based on this post: TensorFlow - numpy-like tensor indexing. In Numpy you can use arrays to index into an array. E.g. in order to select the elements at (1, 2) and (3, 2) in a 2-dimensional array, you can do this: # data is [[0, 1, 2, 3, 4, 5], # [6, 7, 8, 9, 10, 11], # ...
tf.gather_nd is an extension of tf.gather in the sense that it allows you to not only access the 1st dimension of a tensor, but potentially all of them. Arguments: params: a Tensor of rank P representing the tensor we want to index into indices: a Tensor of rank Q representing the indices into ...

Page 1 of 1