
Last chance! 50% off unlimited learning
Sale ends in
Index_select
(Tensor) the input tensor.
(int) the dimension in which we index
(LongTensor) the 1-D tensor containing the indices to index
(Tensor, optional) the output 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 dimensions have the same size as in the original tensor.
# NOT RUN {
if (torch_is_installed()) {
x = torch_randn(c(3, 4))
x
indices = torch_tensor(c(1, 3), dtype = torch_int64())
torch_index_select(x, 1, indices)
torch_index_select(x, 2, indices)
}
# }
Run the code above in your browser using DataLab