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

Error #8

Open
myt889 opened this issue Mar 8, 2022 · 0 comments
Open

Error #8

myt889 opened this issue Mar 8, 2022 · 0 comments

Comments

@myt889
Copy link

myt889 commented Mar 8, 2022

您好,感谢您的代码,有几个问题想要请教您:
目的:可视化Query2Label这个多标签分类模型的decoder中的multi-head attention.

  1. 首先Query2Label模型是由CNN backbone+ Transformer decoder组成的,其中decoder部分由torch.nn .MultiheadAttention()构成,比如有4个heads。CNN backbone,Transformer网络分别在单独的.py文件搭建。
    目前我已经在Transformer.py文件中按您的建议步骤,在指定位置输入代码:
    from visualizer import get_local
    @get_local("attention_map")
    并且在需要网络输出attention的def forward()前,输入代码:
    @get_local('attention_map')
    def forward(self, tgt,....):
    ..........
    attention_map = out
    return out
    2. 按您的指南,写了对应的可视化代码。
    3. 运行代码,出现如下错误:
    File "/home/tym/myprojects/Dection/visualizer/visualizer.py", line 15, in call
    c = Bytecode.from_code(func.code)
    AttributeError: type object 'Transformer' has no attribute 'code'

我想问您,(1)由于模型复杂,需要多个模块嵌套,那上述步骤1,对么?(2)运行代码错误的原因是什么?如何解决,谢谢您。

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

1 participant