This seems to be indeed the right shape and I remembered I’ve seen this issue before!
Could you check, if nll_loss2d is defined and if so use it instead of nll_loss (I’m currently not on my machine to check it)?