Confusing error using BCEWithLogitsLoss with weighted loss

Hello,

I have encountered this confusing case recently. Refer ptblck’s comment from this thread.
If you are doing binary-classes segmentation, you could also use CrossEntropyLoss and pass weight argument to it.