Class-balanced-loss-pytorch
Class-balanced-loss-pytorch copied to clipboard
Is this same to apply pos_weight?
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?