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

GCE implementation #3

Open
sunniesuhyoung opened this issue Feb 27, 2021 · 1 comment
Open

GCE implementation #3

sunniesuhyoung opened this issue Feb 27, 2021 · 1 comment

Comments

@sunniesuhyoung
Copy link

Why is GCE implemented as

F.cross_entropy(logits, targets, reduction='none') * (Yg.squeeze().detach()**self.q)*self.q

instead of (1 - Yg.squeeze().detach()**self.q) / self.q ?

@mvandenhi
Copy link

mvandenhi commented Mar 26, 2022

Hey Sunnie,
in your formulation you mustn't use detach(), as you still need to take the derivative there. While in their formula, the authors notice that the derivative of the GCE consists of the CE-derivative as well as the "loss_weight"(see p.5 of their paper). Hence, by fixing and detaching the "loss_weight" from the graph, for the backward pass they now only need to compute the gradient the cross_entropy function which is probably much faster.
I don't understand why they multiply by the constant q though, do you?
Best,
Moritz

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

2 participants