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] Relevances not conserved in A1B0, W2, Bounded #327

Open
Shreyas911 opened this issue Aug 26, 2024 · 0 comments
Open

[BUG] Relevances not conserved in A1B0, W2, Bounded #327

Shreyas911 opened this issue Aug 26, 2024 · 0 comments
Labels
triage Bug report that needs assessment

Comments

@Shreyas911
Copy link

Shreyas911 commented Aug 26, 2024

Describe the bug

It seems that relevances are not conserved across layers when using LRP-A1B0, LRP-W2, and LRP-Bounded rules. I am able to manually write the code to conserve these relevances if needed and don't fully understand why the library cannot do it. I do have some intuition though as you can see in the minimum working example below. The Manual LRP-A1B0 without bias in the numerator and only one bias in the denominator can completely reproduce the library's A1B0 output. While this is great, not having a multiple of the bias term in the denominator means that relevances are then not conserved across layers. Using the library's LRP-A1B0-IB seems to improve things a bit, but not up to machine precision.

In mathematical terms, what the library is doing is this (for a 2x2 weight matrix and 2x1 bias and LRP-A1B0 rule):

denominator = x[0,0]*np.max(W[0,pred_class],0)+x[0,1]*np.max(W[1,pred_class],0)+np.max(b[pred_class],0)

What should be expected for relevance conservation is this:

denominator = x[0,0]*np.max(W[0,pred_class],0)+x[0,1]*np.max(W[1,pred_class],0)+2*np.max(b[pred_class],0)

A (almost) minimum working example can be found here: https://github.com/Shreyas911/XAIRT/blob/main/examples_TomsQoI/LRP_manual_MWE.ipynb

Expected behavior

I expected the relevance to be conserved for all these rules, especially since manually implementing them for a single-layer network I am able to achieve relevance conservation across the layers up to machine precision.

Any help/insights are appreciated. Thanks a lot!

@Shreyas911 Shreyas911 added the triage Bug report that needs assessment label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Bug report that needs assessment
Projects
None yet
Development

No branches or pull requests

3 participants
@Shreyas911 and others