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