Open javierrodenas opened 3 years ago
What I did so far:
from sklearn.utils import class_weight
class_weights = class_weight.compute_class_weight('balanced', np.unique(target_values), target_values.numpy())
class_weights = torch.tensor(class_weights, dtype=torch.float)
train_loss_fn = nn.CrossEntropyLoss(weight=class_weights).cuda()
See that I am changing the loss function, before I was using TokenLabelGTCrossEntropy :
train_loss_fn = TokenLabelGTCrossEntropy(dense_weight=args.dense_weight,\
cls_weight = args.cls_weight, mixup_active = mixup_active).cuda()
Hello,
I was trying to compute the class weight "balanced". I see that there are two arguments:
How can I multiply the loss to get the balanced class weight?
Thank you in advance