chr5tphr/zennit

[How to use] heatmap variants [...] such as the guided_backprop or smoothgrad [...] ?

sebastian-lapuschkin opened this issue · 2 comments

Hi, thanks again for the response. After looking through the linked original example. I'm wondering why I can't use other heatmap variants other than epsilon ? such as the guided_backprop or smoothgrad which seem to produce a better heatmap then epsilon_plus or epsilon_alpha2_beta1_flat

Originally posted by @linghu258 in #24 (comment)

dear @linghu258 ,

examples on how to achieve this are given in the Example section in the ReadMe.
For convenience, corresponding parameterisations for feed_forward.py are given below:

Guided Backprop:

.venv/bin/python feed_forward.py \
    data/lighthouses \
    'results/vgg16_guided_backprop_{sample:02d}.png' \
    --inputs 'results/vgg16_input_{sample:02d}.png' \
    --parameters params/vgg16-397923af.pth \
    --model vgg16 \
    --composite guided_backprop \
    --relevance-norm symmetric \

SmoothGrad:

.venv/bin/python feed_forward.py \
    data/lighthouses \
    'results/vgg16_smoothgrad_{sample:02d}.png' \
    --inputs 'results/vgg16_input_{sample:02d}.png' \
    --parameters params/vgg16-397923af.pth \
    --model vgg16 \
    --attributor smoothgrad \
    --relevance-norm absolute \
    --cmap hot

Note the difference between the use of --attributor for SmoothGrad as a "noise tunnel" approach based on (simple) gradient backprop and --composite for GuidedBackprop, a rule-based modification for the backprop of gradients, allowing for a combination of attributors and composites, as in the call for IntegratedGuidedBackprop below:

.venv/bin/python feed_forward.py \
    data/lighthouses \
    'results/vgg16_smoothed_guided_backprop_{sample:02d}.png' \
    --inputs 'results/vgg16_input_{sample:02d}.png' \
    --parameters params/vgg16-397923af.pth \
    --model vgg16 \
    --attributor integrads \
    --composite guided_backprop \
    --relevance-norm symmetric \

closing due to inactivity