albermax / innvestigate

A toolbox to iNNvestigate neural networks' predictions!
Other
1.26k stars 233 forks source link

Update backend #263

Closed adrhill closed 3 years ago

adrhill commented 3 years ago

Updates the backend in preparation for the switch to TF2.0. I tried to not touch innvestigate/analyzers to keep this commit a bit more concise. Further type annotations and fixes will follow as soon as this is merged.

Changes

Type annotations

Adds type annotations to the backend, making refactoring a whole lot easier going forward. Static type checking can be run by calling

poetry run mypy

In the future, this should be included as part of CI.

Bug fixes

Dead code removal

Linting fixes

Updated lots of small things to appease pylint and flake8, mostly updating variable names with more meaningful ones and untangling if-else-statements.

codecov-commenter commented 3 years ago

Codecov Report

Merging #263 (e619003) into master (c6ce893) will increase coverage by 1.19%. The diff coverage is 79.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
+ Coverage   71.36%   72.55%   +1.19%     
==========================================
  Files          41       43       +2     
  Lines        4173     4129      -44     
  Branches      637      614      -23     
==========================================
+ Hits         2978     2996      +18     
+ Misses       1007      948      -59     
+ Partials      188      185       -3     
Impacted Files Coverage Δ
src/innvestigate/analyzer/deeptaylor.py 89.36% <ø> (-6.39%) :arrow_down:
src/innvestigate/applications/mnist.py 0.00% <0.00%> (ø)
src/innvestigate/applications/imagenet.py 37.83% <40.00%> (ø)
src/innvestigate/utils/keras/backend.py 65.38% <62.50%> (+30.29%) :arrow_up:
src/innvestigate/utils/keras/checks.py 78.31% <70.17%> (+1.71%) :arrow_up:
src/innvestigate/utils/keras/graph.py 56.44% <73.39%> (+0.41%) :arrow_up:
src/innvestigate/tools/perturbate.py 62.98% <76.92%> (ø)
src/innvestigate/tools/pattern.py 79.43% <83.33%> (+1.91%) :arrow_up:
src/innvestigate/layers.py 82.79% <89.10%> (+4.40%) :arrow_up:
src/innvestigate/utils/types.py 100.00% <100.00%> (ø)
... and 5 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 c6ce893...e619003. Read the comment docs.