Returns a new Tensor
which is a tensor slice at the given index
in the
dimension dim
. The returned tensor has one less dimension: the dimension
dim
is removed. As a result, it is not possible to select()
on a 1D
tensor.
> x = torch.Tensor(5,6):zero() > print(x) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [torch.Tensor of dimension 5x6] > y = x:select(1, 2):fill(2) -- select row 2 and fill up > print(y) 2 2 2 2 2 2 [torch.Tensor of dimension 6] > print(x) 0 0 0 0 0 0 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [torch.Tensor of dimension 5x6] > z = x:select(2,5):fill(5) -- select column 5 and fill up > print(z) 5 5 5 5 5 [torch.Tensor of dimension 5] > print(x) 0 0 0 0 5 0 2 2 2 2 5 2 0 0 0 0 5 0 0 0 0 0 5 0 0 0 0 0 5 0 [torch.Tensor of dimension 5x6]