1Konny / gradcam_plus_plus-pytorch

A Simple pytorch implementation of GradCAM and GradCAM++
359 stars 95 forks source link

RuntimeError: grad can be implicitly created only for scalar outputs #7

Open geekysethi opened 4 years ago

geekysethi commented 4 years ago

mask, _ = gradcam(inputs) File "/home/ashish18024/anaconda3/envs/dl/lib/python3.7/site-packages/gradcam/gradcam.py", line 88, in __call__ return self.forward(input, class_idx, retain_graph) File "/home/ashish18024/anaconda3/envs/dl/lib/python3.7/site-packages/gradcam/gradcam.py", line 70, in forward score.backward(retain_graph=retain_graph) File "/home/ashish18024/anaconda3/envs/dl/lib/python3.7/site-packages/torch/tensor.py", line 118, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "/home/ashish18024/anaconda3/envs/dl/lib/python3.7/site-packages/torch/autograd/__init__.py", line 87, in backward grad_tensors = _make_grads(tensors, grad_tensors) File "/home/ashish18024/anaconda3/envs/dl/lib/python3.7/site-packages/torch/autograd/__init__.py", line 28, in _make_grads raise RuntimeError("grad can be implicitly created only for scalar outputs") RuntimeError: grad can be implicitly created only for scalar outputs