Solved by ptrblck in post #2 
              
              
                nn.BCEWithLogitsLoss allows you to pass a weight as well as a pos_weight argument. 
The former tensor should have the shape [batch_size] and will be applied to each sample, while the latter should have the shape [nb_classes] and will be applied to the positive examples as described in the docs. 
Bas…