Class-balanced-loss-pytorch icon indicating copy to clipboard operation
Class-balanced-loss-pytorch copied to clipboard

Is this same to apply pos_weight?

Open jtlee90 opened this issue 4 years ago • 0 comments

Instead calculating a weight for each batch, applying to class using pos_weight argument in torch.nn.BCELoss(pos_weights=weights)

Simply, https://github.com/vandit15/Class-balanced-loss-pytorch/blob/master/class_balanced_loss.py#L71-L82

Are those line of codes same with

effective_num = 1.0 - np.power(beta, samples_per_cls)
weights = (1.0 - beta) / np.array(effective_num)
weights = weights / np.sum(weights) * no_of_classes
loss = torch.nn.BCELoss(reduction='mean', pos_weight=weights)

this code?

jtlee90 avatar May 20 '20 09:05 jtlee90