Skip to content

Commit

Permalink
Merge pull request #266 from adrhill/adrhill/update-analyzers
Browse files Browse the repository at this point in the history
Update analyzer init and serialization
  • Loading branch information
albermax committed Aug 3, 2021
2 parents 32ead9d + 7419aa4 commit db8a58e
Show file tree
Hide file tree
Showing 14 changed files with 1,551 additions and 1,298 deletions.
39 changes: 18 additions & 21 deletions src/innvestigate/analyzer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Get Python six functionality:
from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import annotations

from .base import NotAnalyzeableModelException
from .deeptaylor import BoundedDeepTaylor, DeepTaylor
from .gradient_based import (
from typing import Dict, Type

from innvestigate.analyzer.base import AnalyzerBase, NotAnalyzeableModelException
from innvestigate.analyzer.deeptaylor import BoundedDeepTaylor, DeepTaylor
from innvestigate.analyzer.gradient_based import (
BaselineGradient,
Deconvnet,
Gradient,
Expand All @@ -12,9 +13,9 @@
IntegratedGradients,
SmoothGrad,
)
from .misc import Input, Random
from .pattern_based import PatternAttribution, PatternNet
from .relevance_based.relevance_analyzer import (
from innvestigate.analyzer.misc import Input, Random
from innvestigate.analyzer.pattern_based import PatternAttribution, PatternNet
from innvestigate.analyzer.relevance_based.relevance_analyzer import (
LRP,
LRPZ,
BaselineLRPZ,
Expand All @@ -36,12 +37,13 @@
LRPZPlus,
LRPZPlusFast,
)
from .wrapper import AugmentReduceBase, GaussianSmoother, PathIntegrator, WrapperBase

###############################################################################
###############################################################################
###############################################################################

from innvestigate.analyzer.wrapper import (
AugmentReduceBase,
GaussianSmoother,
PathIntegrator,
WrapperBase,
)
from innvestigate.utils.types import Model

# Disable pyflaks warnings:
assert NotAnalyzeableModelException
Expand All @@ -52,12 +54,7 @@
assert PathIntegrator


###############################################################################
###############################################################################
###############################################################################


analyzers = {
analyzers: Dict[str, Type[AnalyzerBase]] = {
# Utility.
"input": Input,
"random": Random,
Expand Down Expand Up @@ -98,7 +95,7 @@
}


def create_analyzer(name, model, **kwargs):
def create_analyzer(name: str, model: Model, **kwargs) -> AnalyzerBase:
"""Instantiates the analyzer with the name 'name'
This convenience function takes an analyzer name
Expand Down
Loading

0 comments on commit db8a58e

Please sign in to comment.