Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: not enough values to unpack (expected 4, got 2) for GradCAM++ #17

Open
r0cketr1kky opened this issue May 17, 2020 · 0 comments

Comments

@r0cketr1kky
Copy link

r0cketr1kky commented May 17, 2020

Model: Alexnet
Dataset: CIFAR-10

The code works well with layer_name='features' but I get this error when I change it to layer_name='classifier'

Code:

# GRADCAM++ 
image_path = 'xyz'
image = load_image(image_path)
norm_image = apply_transforms(image, size=32)

model_dict = dict(arch=model, layer_name='classifier_0', input_size=(32, 32))
  
gradcampp = GradCAMpp(model_dict)
output = gradcampp(norm_image)
visualize(norm_image, output)

Error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-63-fed255ab9edc> in <module>()
      7 
      8 gradcampp = GradCAMpp(model_dict)
----> 9 output = gradcampp(norm_image)
     10 visualize(norm_image, output)

1 frames
<ipython-input-46-e7d860e12ca6> in __call__(self, input_, class_idx, retain_graph)
     70 
     71     def __call__(self, input_, class_idx=None, retain_graph=False):
---> 72         return self.forward(input_, class_idx, retain_graph)

<ipython-input-49-d221b5d1444c> in forward(self, input_image, class_idx, retain_graph)
     32         gradients = self.gradients['value']
     33         activations = self.activations['value']
---> 34         b, k, u, v = gradients.size()
     35 
     36         alpha_num = gradients.pow(2)

ValueError: not enough values to unpack (expected 4, got 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant