Did your model predictions change from the negative to the positive class or vice verse when you’ve changed the pos_weight?



 skyunyoo:

pos_weight <0; 0.2 scale


I don’t think a negative pos_weight would make sense, would it?



 skyunyoo:

Is there a way to load the target in this code samples_weights = [weights[t] for t in target] ?


If you are creating the targets lazily in each iteration, you could create the target tensor once before the training via:
targets = []
for _, target in dataset:
    targets.append(target)
targets = torch.stack(targets)

and use it to create the WeightedRandomSampler.



 skyunyoo:

In my think, if I use WeightedRandomSampler , use of pos_weight doesn’t seem to make sense. Is this correct?


Might be the case, but I would recommend to run experiments and verify that each step is working as expected.