- RuntimeError: The size of tensor a (32) must match the size of tensor b (512) at non-singleton dimension 1
出错在于:张量 weights
和 activations
相乘时,PyTorch中张量维度不匹配
解决办法:在gradcam.py第72行插入下面代码:
for i in range(4):
weights = torch.cat((weights, weights), 1)
i += 1
改进前:
改进后: