for epoch in range(epochs):
    epoch += 1      # <-- you dont need to increse epoch by one, this is done automatically by the for statement above
    inputs = Variable(torch.from_numpy(x_train))
    labels = Variable(torch.from_numpy(y_train))
    optimizer.zero_grad()
    outputs = model(inputs)
    loss = criterion(outputs,labels)
    loss.backward()
    optimizer.step()
    print('epoch {}, loss {} '.format(epoch, loss.data[0]))
    #                                             ^
    #                                             | 

This is the problem I guess, replace loss.data[0] with loss.data.item()