Skip to content

Commit

Permalink
add a small constant to avoid division by zero (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
karray committed Oct 6, 2023
1 parent af2d53a commit 21ef872
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pytorch_grad_cam/score_cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_cam_weights(self,
upsampled.size(1), -1).min(dim=-1)[0]

maxs, mins = maxs[:, :, None, None], mins[:, :, None, None]
upsampled = (upsampled - mins) / (maxs - mins)
upsampled = (upsampled - mins) / (maxs - mins + 1e-8)

input_tensors = input_tensor[:, None,
:, :] * upsampled[:, :, None, :, :]
Expand Down

0 comments on commit 21ef872

Please sign in to comment.