ValueError: Invalid layer name: layer4.2
bemoregt opened this issue · comments
Gromit Park commented
Hi, @kazuto1011
I changed yourcode lkike this:
def main(image_path, arch, topk, cuda):
CONFIG = {
'resnet18': {
'target_layer': 'layer4.2',
'input_size': 224
},
then I've met this error:
File "/Users/mun/grad-cam-pytorch/grad_cam.py", line 101, in _find
raise ValueError('Invalid layer name: {}'.format(target_layer))
ValueError: Invalid layer name: layer4.2
What's wrong to me?
Thanks in advance.
from @bemoregt.
Kazuto Nakashima commented
You can check valid layer names with this command:
print(*list(models.resnet18().named_modules(), sep='\n'))
If you're interested in the output of the last convolution layer, try to specify "layer4.1".