I see what you mean (took me a while to figure out). so rather than passing the weight argument (which is the rescaling weight of each bach element) to the loss function we pass the pos_weight argument (which is weight of positive example). In what scenarios would you want to use one or the other ? Also, if i am calculating pos_weight argument for each batch, don’t i still have to instantiate the loss function for each batch to pass the pos_weight argument. Will something like this work:
criterion = torch.nn.BCEWithLogitsLoss()
for img, label in trainloader:
    # Assuming i calculate 'pos_weights' for each batch
    weights = torch.FloatTensor ([count_of_lbl0 / count_of_lbl1])
    criterion.pos_weight = weights
    loss = criterion(output, label)