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

About the coefficient 1000.0 in DKD.py #1

Closed
ywher opened this issue Apr 14, 2022 · 2 comments
Closed

About the coefficient 1000.0 in DKD.py #1

ywher opened this issue Apr 14, 2022 · 2 comments

Comments

@ywher
Copy link

ywher commented Apr 14, 2022

in line 21 - 26 in DKD.py

pred_teacher_part2 = F.softmax(
    logits_teacher / temperature - 1000.0 * gt_mask, dim=1
)
log_pred_student_part2 = F.log_softmax(
    logits_student / temperature - 1000.0 * gt_mask, dim=1
)

What dose the coefficient 1000.0 represent? Is it the number of classes ?

@cailinhang
Copy link

cailinhang commented Apr 14, 2022

What dose the coefficient 1000.0 represent? Is it the number of classes ?

I guess that softmax(-1000) ≈ 0. Thus -1000 is just used to make the probability of the target class to be around 0.

@Zzzzz1
Copy link
Collaborator

Zzzzz1 commented Apr 15, 2022

It's an implementation for masking out the target logits (only keeping the non-target logits). A more readable way is "pred = F.softmax(logits[1-gt_mask] / temperature)", yet we find it would cost a lot of time because of the indexing operation.

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

3 participants