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

How does the attention loss work #8

Closed
zeabin opened this issue Jan 9, 2022 · 1 comment
Closed

How does the attention loss work #8

zeabin opened this issue Jan 9, 2022 · 1 comment

Comments

@zeabin
Copy link

zeabin commented Jan 9, 2022

Hi, thanks for sharing the code.

I notice that detach() is called before backward() for attention loss in train_step and the back propagation should not go through attention loss. So how can the attention loss work?

NAD/main.py

Lines 30 to 34 in d61e4d7

cls_loss = criterionCls(output_s, target)
at3_loss = criterionAT(activation3_s, activation3_t).detach() * opt.beta3
at2_loss = criterionAT(activation2_s, activation2_t).detach() * opt.beta2
at1_loss = criterionAT(activation1_s, activation1_t).detach() * opt.beta1
at_loss = at1_loss + at2_loss + at3_loss + cls_loss

@bboylyg
Copy link
Owner

bboylyg commented Jan 10, 2022

Hi, thank you very much for your reminder. This error has been fixed now.

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