Open scutfrank opened 1 year ago
me too
Could you try it on Colab? I think this is caused by the update in torch.
change to this
count = 0 for channel, mean, std in zip(denormalized[0], means, stds): denormalized[0][count] = denormalized[0][count].mul(std) denormalized[0][count] = denormalized[0][count].add(mean) count+=1
the key is change channel.mul_(std).add_(mean)
to denormalized[0][count] = denormalized[0][count].mul(std)
and denormalized[0][count] = denormalized[0][count].add(mean)
. Because these are in place. 这里的乘法和加法都是就地操作的,这里不适用,所以要拆开来。按照发的这个代码换一下就可以了。
change to this
count = 0 for channel, mean, std in zip(denormalized[0], means, stds): denormalized[0][count] = denormalized[0][count].mul(std) denormalized[0][count] = denormalized[0][count].add(mean) count+=1
the key is changechannel.mul_(std).add_(mean)
todenormalized[0][count] = denormalized[0][count].mul(std)
anddenormalized[0][count] = denormalized[0][count].add(mean)
. Because these are in place. 这里的乘法和加法都是就地操作的,这里不适用,所以要拆开来。按照发的这个代码换一下就可以了。
This solution is useful, thanks!
Traceback (most recent call last): File "D:/1.Study/PycharmProjects/Score-CAM-master/test.py", line 50, in
basicvisualize(input.cpu(), scorecam_map.type(torch.FloatTensor).cpu(), save_path='resnet.png')
File "D:\1.Study\PycharmProjects\Score-CAM-master\utils__init__.py", line 299, in basicvisualize
input = format_forplotting(denormalize(input))
File "D:\1.Study\PycharmProjects\Score-CAM-master\utils__init_.py", line 173, in denormalize
channel.mul(std).add_(mean)