Skip to content

Commit 21ef872

Browse files
authored
add a small constant to avoid division by zero (#449)
1 parent af2d53a commit 21ef872

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pytorch_grad_cam/score_cam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_cam_weights(self,
3737
upsampled.size(1), -1).min(dim=-1)[0]
3838

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

4242
input_tensors = input_tensor[:, None,
4343
:, :] * upsampled[:, :, None, :, :]

0 commit comments

Comments
 (0)