Elements of a tensor can be retrieved with the [index] operator.

The [index] operator is equivalent to a select(1, index) if the tensor has more than one dimension. If the tensor is a 1D tensor, it returns the value at index in this tensor.

Example:

> x = torch.Tensor(3,3)
> i = 0; x:apply(function() i = i + 1; return i end)
> = x

 1  4  7
 2  5  8
 3  6  9
[torch.Tensor of dimension 3x3]

> = x[2] -- returns row 2

 2
 5
 8
[torch.Tensor of dimension 3]

> = x[2][3] -- returns row 2, column 3
8