KFrank:

Assuming batchsize = 4 , nClasses = 5 , H = 224 , and
W = 224 , CrossEntropyLoss will be expecting the input
(prediction) you give it to be a FloatTensor of shape
(4, 5, 244, 244) , and the target (ground truth) to be a
LongTensor of shape (4, 244, 244).


Dear @KFrank you hit the nail, thank you. Thank you.
The target is a single image HxW, each pixel labeled as belonging to [0…nClasses-1]
loss = CrossEntropyLoss(input, target)  in the specified  size computes correctly (I was too wrong).
Can you suggest me some place to learn the keys of DL, I am starting on it. Thank you again.