You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
首先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'
您好,感谢您的代码,有几个问题想要请教您:
目的:可视化Query2Label这个多标签分类模型的decoder中的multi-head attention.
目前我已经在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)运行代码错误的原因是什么?如何解决,谢谢您。
The text was updated successfully, but these errors were encountered: