I’m confused reading the explanation given in the official doc i.e.,


pos_weight (Tensor 10, optional ) – a weight of positive examples. Must be a vector with length equal to the number of classes.


For example, if a dataset contains 100 positive and 300 negative examples of a single class, then pos_weight for the class should be equal to 300/100=3. The loss would act as if the dataset contains 3×100=300 positive examples.



weight (Tensor 10, optional ) – a manual rescaling weight given to the loss of each batch element. If given, has to be a Tensor of size nbatch.

In the context of multi-label binary classification (i.e., semantic segmentation):

How weight is supposed to be calculated when the ground truth mask is of the shape [N, 1, H, W]?
In what ways both parameters work differently and contribute to the calculation of the BCE loss?