utkuozbulak / pytorch-cnn-visualizations

Pytorch implementation of convolutional neural network visualization techniques
MIT License
7.81k stars 1.49k forks source link

'NoneType' object has no attribute 'data' #92

Closed iBrain-007 closed 3 years ago

iBrain-007 commented 3 years ago

I got an error when I run guided_backprop.py on my own model: guided_grads = GBP.generate_gradients(preprocessed_img, target_class) gradients_as_array = self.gradients.data.cpu().numpy()[0] And the terminal outputs the following error": AttributeError: 'NoneType' object has no attribute 'data' Are there any suggestions? Thanks advance.

utkuozbulak commented 3 years ago

Hey,

You have to hook correct layers. If your model does not follow the assumed architecture (features/classifier), you have to make minor modifications in the code. Have a look at a couple of related opened issues before.