Thank you for you reply.
The shape of output, target and predicted are in the following
output torch.Size([1, 22, 256, 256])
#(Batch size, nClasses, H, W)
target torch.Size([1, 1, 256, 256])
#(Batch size, Channels, H, W)
predict torch.Size([1, 256, 256])
#(Batch size H, W)




 KFrank:

In particular, why are you selecting away one of
target's dimensions in your loss calculation? (Is it a “channels” or
“classes” dimension?)


I am dropping the channel dimension for loss calculation as I think that’s the required input type for CrossEntropyLoss and do you know the calculation method for accuracy is correct or not.
I am working on semantic segmentation problem and my training set is about 2000 images.
I found that the loss is keep dropping but a bit slow. I’m trying to  run for a larger epochs now