Transformer-MM-Explainability icon indicating copy to clipboard operation
Transformer-MM-Explainability copied to clipboard

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

Open TongLi97 opened this issue 11 months ago • 7 comments

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?

TongLi97 avatar Feb 29 '24 03:02 TongLi97

have the same problem here

OHaiYo-lzy avatar May 01 '24 14:05 OHaiYo-lzy

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!

che011 avatar Jul 01 '24 06:07 che011

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

asPagurus avatar Jul 02 '24 09:07 asPagurus

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

Marverlises avatar Jul 22 '24 04:07 Marverlises

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

che011 avatar Jul 22 '24 15:07 che011

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!

Marverlises avatar Jul 23 '24 07:07 Marverlises

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'

zqs010908 avatar Sep 03 '24 10:09 zqs010908