I have some pretty basic code, based on sample code, for an MLP.  I’m using a dataset of my own data that I’ve created.  100 inputs  (1x100 float tensor per instance), 1 output (1x1), four classes (0, 1,2,3).
I’m just trying to get a basic mlp to work so I’m only dealing with 20 rows in my training set…batch size at 1 to start.
And I get the above error.
Any ideas?
Other details
Pytorch version 0.1.12_2
python 2.7.13
Should I switch to python 3?
Code:

path = "%s/%s" % (base_dir, filename)
print('opening data set %s.' % path)
dataset =  torch.load(path)

long_target = dataset.target_tensor.long()
dataset.target_tensor = long_target


batch_size = 1
kwargs = {'num_workers': 8, 'pin_memory': True}
train_loader = torch.utils.data.DataLoader(
                 dataset=dataset,
                 batch_size=batch_size,
                 shuffle=True, **kwargs)

criterion = nn.CrossEntropyLoss()



class MLPNet(nn.Module):
    def __init__(self):
        super(MLPNet, self).__init__()
        self.fc1 = nn.Linear(100, 500)
        self.fc2 = nn.Linear(500, 256)
        self.fc3 = nn.Linear(256, 1)

    def forward(self, x):
        x = x.view(-1, 100)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = F.relu(self.fc3(x))
        return x

model = MLPNet().cuda()

print(model)


optimizer = optim.SGD(model.parameters(), lr=0.01, momentum=0.9)
for epoch in xrange(100):
    # training
    for batch_idx, (x, target) in enumerate(train_loader):
        optimizer.zero_grad()
        x, target = Variable(x.cuda()), Variable(target.cuda())
        #pdb.set_trace()
        output = model(x)
        loss = criterion(output, target)  #error occurs here
        loss.backward()
        optimizer.step()