Your target
is probably all zeros.
I would recommend to avoid narmalizing the target and rescaling it again. Instead just keep the class indices and remove the transformation for your target
.
If you call target.long()
on small numbers, they will be all zeros. Scaling with 255
won’t change that.
A fast fix would be to first multiply it with 255
and then convert it to a long tensor or as I described avoid normalizing it in the first place:
F.cross_entropy(pred, (target.squeeze(1) * 255.).long())