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

What is the meaning of 'flat' variable in vit_rollout.py? #9

Open
yojayc opened this issue Aug 17, 2021 · 1 comment
Open

What is the meaning of 'flat' variable in vit_rollout.py? #9

yojayc opened this issue Aug 17, 2021 · 1 comment

Comments

@yojayc
Copy link

yojayc commented Aug 17, 2021

The code doesn't use the variable after reevaluating it in line 27

flat[0, indices] = 0

@marc345
Copy link

marc345 commented Jan 12, 2022

@yojayc
This is for discarding the lowest attention weights, flat is generated as a view into the attention_heads_fused, therefore modifying flat in line 27, results in modifying attention_heads_fused, you can learn more about views here.
Not also as the indices that are equal to zero are filtered out, this is done because the attention weights accounting for the CLS token are kept by default.
I hope this helps.

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