How pytorch calculates bce loss if output is bs,nc,h,w that is in case of segmentation
I obtained  different results when I do
X= -Mask log( sigmoid (output) -(1-mask) log(1-sigmoid(1-output) )
X.mean(0).sum() ,
here  it start from 3k ,ends in nan
And when I  use f.bce with logits range of loss 0.5 to 1
Why is there a difference .m I missing any step for aggregating bce loss. There is no nan here .