Skip to content

[BUG] NotImplementedError raised every time layers are checked with _do_model_checks() for analyzers inheriting from AnalyzerBase #323

@juliowissing-iis

Description

@juliowissing-iis

Describe the bug

When creating an analyzer that uses model checks (e.g., LRPSequentialPresetA), a NotImplementedError is raised for every check that should only be a warning. This originates from the snippet (lines 120-125 in analyzer/base.py):

if check_type == "exception":
    raise NotAnalyzeableModelException(tmp_message)
if check_type == "warning":
    # TODO(albermax) only the first warning will be shown
    warnings.warn(tmp_message)
raise NotImplementedError()

Steps to reproduce the bug

import tensorflow as tf
import innvestigate
tf.compat.v1.disable_eager_execution()

model = _   # create model with non-ReLU activation
analyzer = innvestigate.analyzer.LRPSequentialPresetA(model)

Expected behavior

As LRPSequentialPresetA only has a check with check_type "warning" no exception should be raised, just a warning. To fix this I changed the abovementioned snippet to:

if check_type == "exception":
    raise NotAnalyzeableModelException(tmp_message)
elif check_type == "warning":
    # TODO(albermax) only the first warning will be shown
    warnings.warn(tmp_message)
else: 
    raise NotImplementedError("Check type {} unkown".format(check_type))

Platform information

  • OS: MacOS 13.6
  • Python version: 3.11.5
  • iNNvestigate version: 2.1.1
  • TensorFlow version: 2.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageBug report that needs assessment

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions