Skip to content
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

Bug in LRP alpha-beta rule #273

Open
nkoenen opened this issue Nov 29, 2021 · 0 comments
Open

Bug in LRP alpha-beta rule #273

nkoenen opened this issue Nov 29, 2021 · 0 comments

Comments

@nkoenen
Copy link

nkoenen commented Nov 29, 2021

Hi,
I think you have a bug in the calculation of the alpha-beta rule. Consider the following example:

import tensorflow
import keras as k
import innvestigate
import innvestigate.utils as iutils
import numpy as np
import time

k.backend.clear_session()

model = k.Sequential(
    [
        k.layers.Dense(1, activation="softmax", input_shape = [2],
        weights = [np.array([[1],[-1]]), np.array([-1])])
    ]
)

inputs = np.array([[1,1]])


model = iutils.keras.graph.model_wo_softmax(model)
analyzer = innvestigate.create_analyzer("lrp.alpha_1_beta_0", model)
analyzer.analyze(inputs)
#> array([[-10000000.,         0.]], dtype=float32)
analyzer = innvestigate.create_analyzer("lrp.alpha_2_beta_1", model)
analyzer.analyze(inputs)
#> array([[-2.e+07,  5.e-01]], dtype=float32)

But as far as I understood the rule, (-1, 0) or (-2, 0.5) should come out there.

Best,
Niklas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant