Skip to content

Commit

Permalink
cam should be initialized to zero matrix. Modify example images
Browse files Browse the repository at this point in the history
  • Loading branch information
spoonnotfound committed Jan 7, 2018
1 parent e701e5c commit 5153665
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 1 deletion.
Binary file modified examples/cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/dog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion grad-cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __call__(self, input, index = None):
target = target.cpu().data.numpy()[0, :]

weights = np.mean(grads_val, axis = (2, 3))[0, :]
cam = np.ones(target.shape[1 : ], dtype = np.float32)
cam = np.zeros(target.shape[1 : ], dtype = np.float32)

for i, w in enumerate(weights):
cam += w * target[i, :, :]
Expand Down

0 comments on commit 5153665

Please sign in to comment.