PyTorch now supports a subset of NumPy style advanced indexing. This allows users to select arbitrary indices at each dimension of the Tensor, including non-adjacent indices and duplicate indices, using the same
-style operation. This allows for a more flexible indexing strategy without needing calls to PyTorch's
Index[Select, Add, ...] functions.
x = torch.Tensor(5, 5, 5) # Pure Integer Array Indexing - specify arbitrary indices at each dim x[[1, 2], [3, 2], [1, 0]] --> yields a 2-element Tensor (x, x) # also supports broadcasting, duplicates