albermax / innvestigate

A toolbox to iNNvestigate neural networks' predictions!
Other
1.25k stars 234 forks source link

Update analyzer init and serialization #266

Closed adrhill closed 2 years ago

adrhill commented 3 years ago

Following up on the refactoring of the backend in #263, this PR makes the analyzers more transparent. Tests covering the new serializations will be added in a separate PR.

Changes

  1. make all class attributes explicit in the class __init__ and remove dynamic tricks using getattr-defaults
  2. make class initialization more transparent by always calling super().__init__() first
  3. move AnalyzerNetworkBase and ReverseAnalyzerBase into separate files
  4. fix / add missing serialization for WrapperBase, LRPSequentialPreset*Flat and BoundedDeepTaylor analyzers

also adds more type annotations, comments, and linting changes.

codecov-commenter commented 3 years ago

Codecov Report

Merging #266 (7419aa4) into master (32ead9d) will decrease coverage by 1.23%. The diff coverage is 82.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
- Coverage   72.65%   71.41%   -1.24%     
==========================================
  Files          43       45       +2     
  Lines        4136     4216      +80     
  Branches      614      619       +5     
==========================================
+ Hits         3005     3011       +6     
- Misses        947     1017      +70     
- Partials      184      188       +4     
Impacted Files Coverage Δ
src/innvestigate/utils/keras/graph.py 49.28% <ø> (-7.16%) :arrow_down:
src/innvestigate/analyzer/deeptaylor.py 79.31% <71.42%> (-10.06%) :arrow_down:
src/innvestigate/analyzer/misc.py 87.50% <73.33%> (-12.50%) :arrow_down:
...stigate/analyzer/relevance_based/relevance_rule.py 71.42% <73.80%> (+0.76%) :arrow_up:
src/innvestigate/analyzer/base.py 72.63% <77.55%> (-7.50%) :arrow_down:
src/innvestigate/analyzer/network_base.py 80.80% <80.80%> (ø)
src/innvestigate/analyzer/wrapper.py 87.97% <83.09%> (+1.63%) :arrow_up:
...ate/analyzer/relevance_based/relevance_analyzer.py 79.03% <83.65%> (-2.29%) :arrow_down:
src/innvestigate/analyzer/gradient_based.py 81.19% <84.31%> (-2.88%) :arrow_down:
src/innvestigate/analyzer/reverse_base.py 86.61% <86.61%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 32ead9d...7419aa4. Read the comment docs.