raghakot / keras-vis

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

Inconsistent results from keras-vis==0.4.1 visualize_saliency #175

Open QiYanPitt opened 5 years ago

QiYanPitt commented 5 years ago

The input model (including weights) and image are exactly the same, but visualize_saliency showed different results.

(1). Use "pip install keras-vis" to install today

mapp = visualize_saliency(model, -1, 0, test_image) mapp array([[[ 0, 0, 127], [ 0, 0, 127], [ 0, 0, 127], ..., mapp.shape (224, 224, 3) #with channel dimension

(2). Use "python setup.py install" to install today

mapp = visualize_saliency(model, -1, 0, test_image) mapp array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., mapp.shape (224, 224) #without channel dimension

(3). Use "python setup.py install" to install a few months back

mapp = visualize_saliency(model, -1, 0, test_image) mapp array([[2.6736882e-06, 4.2871939e-06, 1.0572998e-05, ..., 0.0000000e+00, 0.0000000e+00, 0.0000000e+00], [7.3370802e-06, 6.2087306e-06, 2.0982738e-05, ..., 0.0000000e+00, 0.0000000e+00, 0.0000000e+00], [6.6768080e-06, 2.4095621e-05, 7.1576418e-05, ..., 0.0000000e+00, 0.0000000e+00, 0.0000000e+00], ..., mapp.shape (224, 224)

After checking the results. (3) seems to be correct. (1) and (2) are wrong probably due to dependent package version, but I have no idea. Can anyone help me out?

keisen commented 5 years ago

Hi @QiYanPitt . Thank you for your report.

(1) is obviously wrong, you're right. Now, keras-vis that have published to PiPy is old that has some issues.

That's, (2) should be correct because it is computed by letest version of keras-vis. There may be any problem in current keras-vis if (2) is wrong for you. Could you please give us more details for the problem.

I'm not sure that (3) is correct or wrong, sorry. Because that is up to when it's a few months back .

zhenglilei commented 5 years ago

Hi @QiYanPitt . Thank you for your report.

(1) is obviously wrong, you're right. Now, keras-vis that have published to PiPy is old that has some issues.

That's, (2) should be correct because it is computed by letest version of keras-vis. There may be any problem in current keras-vis if (2) is wrong for you. Could you please give us more details for the problem.

I'm not sure that (3) is correct or wrong, sorry. Because that is up to when it's a few months back .

I thought the output heatmap is a RGB image with 3 channels. So why (1) with 224, 224, 3 is wrong but (2) and (3) with 224,224 are correct?

On version 0.4.1, I am able to run the ./example/vggnet/attention.ipynb using visualize_cam, but i failed with version 0.5.0.