Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this same to apply pos_weight? #12

Open
jtlee90 opened this issue May 20, 2020 · 0 comments
Open

Is this same to apply pos_weight? #12

jtlee90 opened this issue May 20, 2020 · 0 comments

Comments

@jtlee90
Copy link

jtlee90 commented May 20, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant