Closed
Description
Hi, I was interested in visualizing a CNN I created. I was following the example provided but when I try to use my model instead of a pretrained model from torchvision I get:
File "cnn_layer_visualization.py", line 82, in <module>
gradients = backprop.calculate_gradients(input_, target_class)
File "C:\Users\Mike\Anaconda3\lib\site-packages\flashtorch\saliency\backprop.py", line 106, in calculate_gradients
output.backward(gradient=target)
File "C:\Users\Mike\Anaconda3\lib\site-packages\torch\tensor.py", line 107, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "C:\Users\Mike\Anaconda3\lib\site-packages\torch\autograd\__init__.py", line 93, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: invalid gradient at index 0 - expected type torch.cuda.FloatTensor but got torch.FloatTensor
I looked through the source code a bit and saw that Backprop
moves the network to cuda (if available) regardless if I move it there myself or not. Is this possibly a bug? I've had a bit of trouble with CUDA in the past so it might be a problem on my end.
Thanks for your time, if there's any other information I can provide please let me know. Cheers.
Metadata
Metadata
Assignees
Labels
No labels