报错内容
saliency_map = (weights * activations).sum(1, keepdim=True)
RuntimeError: The size of tensor a (32) must match the size of tensor b (512) at non-singleton dimension 1
解决方案,如图
gradcam.py第73行添加
for i in range(4):
weights = torch.cat((weights,weights),1)
i +=1
-
for i in range(4):
weights = torch.cat((weights,weights),1)
i +=1
热力图参考链接: