Adapt fidelity and unfaithfulness to HeteroExplanation#10677
Open
Mellandd wants to merge 2 commits intopyg-team:masterfrom
Open
Adapt fidelity and unfaithfulness to HeteroExplanation#10677Mellandd wants to merge 2 commits intopyg-team:masterfrom
fidelity and unfaithfulness to HeteroExplanation#10677Mellandd wants to merge 2 commits intopyg-team:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adapts the explainability metrics in
torch_geometric.explain.metricto heterogeneous graphs (#9112 ).fidelityandunfaithfulnesspreviously assumed a homogeneousExplanationand accessedexplanation.x/explanation.edge_indexwith plain tensor masks. When called with aHeteroExplanationthey failed, masks live per node/edge type and complement masks need to be computed per-type.Changes
fidelity.py: early dispatch to a new_hetero_fidelityhelper forHeteroExplanation; the homogeneous body is left unchanged. Adds a private_hetero_model_kwargshelper that reconstructs the original modelkwargsfrom_model_args, respecting the*_dictsuffix convention used by the explainer.faithfulness.py: same dispatch pattern with_hetero_unfaithfulness. In the heterogeneous branchtop_kis applied per node type and clamped to the number of features available for that type.New tests
test_fidelity_hetero(2) andtest_unfaithfulness_hetero(24, parametrised ontop_k×explanation_type×node_mask_type×return_type).Dependency
Full
kwargspropagation (e.g.edge_attr_dict) requires_model_argsto be populated onHeteroExplanation, which is the subject of #10676 . This PR usesgetattr(explanation, '_model_args', [])so it degrades gracefully when running against a base without that change.