-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to_captum
: Support for explaining heterogenous graphs (#5934)
This PR adds `CaptumHeteroModel` , `to_captum_input` and `captum_output_to_dicts` which can be used to explain heterogenous graphs as follows. ``` data: HeteroData = (...) model = ... # A heterogenous model mask_type = ... captum_model: CaptumHeteroModel = to_captum_model(model, mask_type, output_idx=output_idx, data.metadata) inputs, additonal_forward_args = to_captum_input(data.x_dict, data.edge_index_dict, mask_type) ig = IntegratedGradients(captum_model) ig_attr_nodes_edges = ig.attribute(inputs, target=target, additional_forward_args=additonal_forward_args, internal_batch_size=1) x_attr_dict, edge_attr_dict = captum_output_to_dicts(ig_attr_nodes_edges, mask_type, data.metadata) ``` **TODOs in follow up PRs** 1. Add an example for `to_captum` with hetero data. 1. Move this behind the `ExplainerAlgorithm` interface being developed in #5804. The interaace has to be extended to support `HeteroData`. Co-authored-by: Ramona Bendias <ramona.bendias@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Charles Dufour <34485907+dufourc1@users.noreply.github.com> Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
- Loading branch information
1 parent
01037db
commit a76d897
Showing
6 changed files
with
502 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.