raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.97k stars 664 forks source link

Possible miscalculation within grad-cam #172

Open Qinusty opened 5 years ago

Qinusty commented 5 years ago

I feel like this makes more sense as np.minimum?

Based on the comment above and the results it produces.

An example can be seen below. Negative gradients are removed with np.minimum()

>> a = np.array([1.0, -1.0])
>> np.maximum(a, 0)
[0, -1.0]
>> np.minimum(a, 0)
[1.0, -1.0]
keisen commented 5 years ago

I've run your code. But I could not reproduce the same result.

In [1]: import numpy as np
In [2]: a = np.array([1.0, -1.0])
In [3]: np.maximum(a, 0)
Out[3]: array([1., 0.])
In [4]: np.minimum(a, 0)
Out[4]: array([ 0., -1.])