albermax / albermax/innvestigate

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

Đang mở
#323 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
triage
Ngôn ngữ chính
Python
Star
1.3k
Fork
230
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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):
```python
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

```python
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:
```python
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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.