KFrank:

>>> torch.nn.BCEWithLogitsLoss (weight = wtb, reduction = 'mean') (inp, trg)
tensor(0.5271)



@KFrank this explains all possible scenarios…

>>> torch.nn.BCEWithLogitsLoss (weight = wtb, reduction = 'mean') (inp, trg)
tensor(0.5271)

my ask is in this case why pytorch chose to mean using numel  when we are doing weighted sum  of class predictions ,where weights are unequal.
Regular mean is also a kind of weighted Sum where each item in pool has got  an equal weight which is by Numel. …
But when weights are unequal like above then further dividing it by Numel could deflate the loss number.s . I have experienced this ,model is not able to learn well…
eg. check this competition metric loss

  
      
      kaggle.com
  
  
    

RSNA STR Pulmonary Embolism Detection

Classify Pulmonary Embolism cases in chest CT scans


  
  
    
    
  
  


i tried doing a simple mean but it gave very poor results