Closed MFreidank closed 5 years ago
Hello,
No, it won't work like that for ResNet because of residual layers' nested nature. You have to update the line where the code iterates through the layers to cover nested sequential layers.
Have a look at how ResNet architecture is organized in Pytorch and for example, AlexNet and you will understand it better.
You don't need to make HUGE changes, just a couple of lines will be enough.
Hope it helps, Utku
Hi again,
thanks for your comments and explanation. I was able to make the guided_backprop.py
code work with resnet18
and up with minor modifications. I decided this is probably not worthy of a pull request, since my changes are local only to guided_backprop.py
. Instead I published my changes in a gist for future reference as similar requests seem to have appeared in the past (issue #3).
Thanks a lot again, MFreidank
Hello,
first off: thanks a lot for open-sourcing all these methods in a single place of reference, incredibly useful!
I am trying to use
src/guided_backprop.py
to visualize predictions of atorchvision.models.resnet18
model. I figured it should be as easy as replacingpretrained_model = models.alexnet(pretrained=True)
withpretrained_model = models.resnet18(pretrained=True)
in line179
ofsrc/misc_functions.py
.However, the images from guided backpropagation do not look nearly as good as for alexnet, in particular, it is not possible to distinguish the snake in them:
Could you provide guidance on how to use your guided backpropagation implementation with resnet models?
Thanks in advance, MFreidank