Hi, thanks for the response. Yes, your code works for me too. What doesn’t work is to use the free-function form of the NLL loss:
auto input = torch::randn({3, 10, 24, 24});
auto target = torch::randint(0, 10, {3, 24, 24}, torch::kLong);
auto loss = torch::nll_loss(input, target);

Is there any design reason for this to behave differently from NLLLoss? If not, I suggest it either gets brought up-to-par with the class, or removed altogether, to avoid confusion. Thanks again!