The model output should be [batch_size, nb_classes], so [10, 5] in your case, with F.log_softmax(x, dim=1) applied on the logits.
You shouldn’t call torch.argmax on the outputs.
PS: This shouldn’t be an error, but you should either use

the inplace method of squeeze: y_train.squeeze_(1)

or the “vanilla” method and assign the result: y_train = y_train.squeeze(1)


(Methods with an underscore work inplace)