Solved by quanguet in post #4 
              
              
                The last layer (prediction layer) yielding the logits must have num_classes as output_size; here, say, 10. 
I just modified your code a little bit. The following should work properly. 
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision imp…