Thanks @ptrblck. It looks like you are using the form of the target with dimension (N,). However, I need the form where the target has dimension (N, d1, … dk). More explicitly (N, 300, 300). I am trying to train a semantic segmentation task where each pixel in the image has its own label.

Capture.PNG855×337 27 KB

I’m not sure the BCEWithLogitsLoss will work for me, since my target dimension is not the same as my input dimension.

Capture3.PNG839×312 16 KB