Solved by ptrblck in post #2 
              
              
                Since your output and target shape do not match, but are broadcastable, you might get a wrong result. 
Have a look at this example: 
x = torch.arange(1, 5).view(2, 2)
y = torch.ones(2, 2)
loss = x - y
print(loss)

x = x.unsqueeze(1)
loss = x - y
print(loss)

While you would most likely expect the fi…