-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update analyzer init and serialization #266
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update imports accordingly and remove "comment walls".
This commit makes all class attributes explicit in the class __init__. This means that some dynamic tricks using `getattr` defaults had to be refactored, the most notable being the function `_do_model_checks()` in base.py. As a consequence, `super().__init__()` can now always be called first on initialization, which makes it much more transparent. As a consequence, each analyzer has to manually call `_do_model_checks()` at the end of initialization. Other improvements: * switched to Python 3 style super without arguments * add type annotations, e.g. using TypedDicts like `ModelCheckDict` and `CondReverseMapping` * broke out `_add_lambda_layer_check` in network_base.py * add warning on change of `neuron_selection_mode` in AugmentReduceBase * remove boolean attribute `_keras_based_augment_reduce` from AugmentReduceBase and adapt `analyze()` * removed some duplicate softmax checks * removed lists from kwarg defaults * made `BASELINE_LRPZ_LAYERS` global
previously, calling `analyzer.load()` would result in duplicate `input_layer_rule` kwargs. Popping the kwarg when it exists seems like a reasonable workaround. Rules differing from "Flat" now result in an error, which I think is preferable to having them silently overwritten.
add separate function `_get_neuron_selection_array` for neuron_selection_mode "index"
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Move class attribute `neuron_selection_mode` to parent class. This is useful as it is also used in `WrapperBase`, which just inherits from `AnalyzerBase`.
use previous mechanism of overwriting the subanalyzer's `neuron_selection_mode`. Add comments and assert subanalyzer neuron selection mode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
__init__
and remove dynamic tricks usinggetattr
-defaultssuper().__init__()
firstAnalyzerNetworkBase
andReverseAnalyzerBase
into separate filesWrapperBase
,LRPSequentialPreset*Flat
andBoundedDeepTaylor
analyzersalso adds more type annotations, comments, and linting changes.