Index tensor by tensor of multidimensional indices ...
https://discuss.pytorch.org/t/index-tensor-by-tensor-of...21.09.2019 · I have a 4D tensor x, and a 2D index tensor i of shape (N, 3), where i[n] is an index over the first 3 dimensions of x. I would like to extract the x values at these indices. After some trial and error, I found that the following does what I want: result = x[i[:, 0], i[:, 1], i[:, 2]] I was wondering if there was a better way to do so. I looked at torch.gather and torch.index_select, …
torch.split — PyTorch 1.11.0 documentation
pytorch.org › docs › stabletorch.split — PyTorch 1.11.0 documentation torch.split torch.split(tensor, split_size_or_sections, dim=0) [source] Splits the tensor into chunks. Each chunk is a view of the original tensor. If split_size_or_sections is an integer type, then tensor will be split into equally sized chunks (if possible).
torch.index_select — PyTorch 1.11.0 documentation
pytorch.org › docs › stabletorch.index_select(input, dim, index, *, out=None) → Tensor. Returns a new tensor which indexes the input tensor along dimension dim using the entries in index which is a LongTensor. The returned tensor has the same number of dimensions as the original tensor ( input ). The dim th dimension has the same size as the length of index; other ...
torch.tensor_split — PyTorch 1.11.0 documentation
pytorch.org › generated › torchtorch.tensor_split torch.tensor_split(input, indices_or_sections, dim=0) → List of Tensors Splits a tensor into multiple sub-tensors, all of which are views of input , along dimension dim according to the indices or number of sections specified by indices_or_sections. This function is based on NumPy’s numpy.array_split (). Parameters