Could you post the stack trace which shows which line of code raised this error?
Besides this indexing error, you will get errors using your criterion, as nn.CrossentropyLoss expects the target to be a LongTensor containing class indices, while it seems you are trying to pass a one-hot encoded target.