In PyTorch master 0.4 709fcfd, variables cannot be indexed.
import torch
from torch.autograd import Variable
print(torch.__version__)
# 0.4.0a0+709fcfd
x = Variable(torch.Tensor([0]))
x.data[x.data == 1]
# [torch.DoubleTensor with no dimension]
x[x == 1]
# *** RuntimeError: dimension out of range (expected to be in range of [-1, 0], but got 1)
This used to work in PyTorch 0.2 f964105:
import torch
from torch.autograd import Variable
print(torch.__version__)
# 0.2.0+f964105
x = Variable(torch.Tensor([0]))
x.data[x.data == 1]
# [torch.FloatTensor with no dimension]
x[x == 1]
# Variable containing:[torch.FloatTensor with no dimension]