The criterion takes the output and the corresponding label as it arguments, your code is passing output of shape 10 and input img of (3,28,28)
Try these changes

img, target = data
loss = criterion(target, label)