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

torch.nn.modules.module.ModuleAttributeError: 'ResidualAttentionBlock' object has no attribute 'attn_probs' #39

Open
TongLi97 opened this issue Feb 29, 2024 · 7 comments

Comments

@TongLi97
Copy link

Execute line of code:
num_tokens = image_attn_blocks[0].attn_probs.shape[-1]

An error message appears:
torch.nn.modules.module.ModuleAttributeError: 'ResidualAttentionBlock' object has no attribute 'attn_probs'

What problem causes this?

@OHaiYo-lzy
Copy link

have the same problem here

@che011
Copy link

che011 commented Jul 1, 2024

If you're using the original openai's clip, do use this git repo's clip folder. In their clip/model.py line 184 they defined a new attribute attn_probs that the original clip repo did not have. Hope this helps!

@asPagurus
Copy link

You may git clone current CLIP (place it instead of CLIP directory inside this module) and patch it with attached patch-file.
There are new file inside clip directory and some addition in module.py
But good result you may get only for old models - for example for ViT-B/32.
New models show many noise(( and I don't know why (for now)
If you want run notebook with clip examples you have to copy images from current CLIP folder to new
patch0.patch

@Marverlises
Copy link

If you're using the original openai's clip, do use this git repo's clip folder. In their clip/model.py line 184 they defined a new attribute attn_probs that the original clip repo did not have. Hope this helps!

From this-https://github.com/openai/CLIP/blob/main/clip/model.py ? I didn't find the replaced one, can you tell in detail? thanks

@che011
Copy link

che011 commented Jul 22, 2024

Use this repo’s clip at this link: https://github.com/hila-chefer/Transformer-MM-Explainability/blob/main/CLIP

The model file I was mentioning would be here: https://github.com/hila-chefer/Transformer-MM-Explainability/blob/main/CLIP/clip/model.py

@Marverlises
Copy link

Use this repo’s clip at this link: https://github.com/hila-chefer/Transformer-MM-Explainability/blob/main/CLIP

The model file I was mentioning would be here: https://github.com/hila-chefer/Transformer-MM-Explainability/blob/main/CLIP/clip/model.py

ok thank u!

@zqs010908
Copy link

I used clip at this link: https://github.com/hila-chefer/Transformer-MM-Explainability/blob/main/CLIP
but an error message appears:
AttributeError: 'NoneType' object has no attribute 'shape'

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

6 participants