jaeyung1001:

print(criterion(output, y_train_tensor[i]))


Maybe you misunderstood about nn.CrossEntropyLoss()?
You need not take max and pass the index to the loss.
nn.CrossEntropyLoss() expects a 2D array of logits where each row belongs to values predicted for a particular item.