AndreaCodegoni/Tiny_model_4_CD

Improvement with weighted loss

Opened this issue · 2 comments

My own dataset is very imbalanced, and I achieved superior results using:

        weight_for_positive_class = 5
        pos_weight = torch.tensor([weight_for_positive_class])
        self.criterion = torch.nn.BCEWithLogitsLoss(pos_weight=pos_weight)

Hello Robin!

Thanks for pointing out!
I have a curiosity: to find the weight did you use any type of optimization or make any inference starting from the dataset?

@AndreaCodegoni nothing too flashy I tried a range 3,4,5,10,20