raghakot / keras-vis

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

filter_indices on dense layer can be set to any arbitrary integer. #79

Open GlastonburyC opened 6 years ago

GlastonburyC commented 6 years ago

I'm using a pretrained InceptionV3 network with two classes, heres the last few layers and parameters:

flatten (Flatten)                (None, 2048)          0           max_pool[0][0]                   
____________________________________________________________________________________________________
predictions (Dense)              (None, 2)             4098        flatten[0][0]                    
====================================================================================================
Total params: 21,806,882
Trainable params: 21,772,450
Non-trainable params: 34,432
____________________________________________________________________________________________________

When I use:

visualize_saliency(InceptionV3_model,layer_idx=312, filter_indices=0, seed_input=example_img, backprop_modifier='guided', grad_modifier="absolute"),alpha=0.5)

I thought I could set filter_indices to 0 or 1 to represent the classes? However, it allows me to set filter_indices to any arbitrary integer? For example, filter_indices = 2000. It supplies a different saliency map every time I change this integer (outside of the set [0,1] this doesn't make sense)

Why is this, I'm using the dense layer (layer_idx=312) I want to make sure I'm seeing the saliency map corresponding to each class. This doesn't seem to be the case.