Skip to content

Commit

Permalink
Add note for edge_size coefficient in GNNExplainer (#8215)
Browse files Browse the repository at this point in the history
Following from #1985

The default value of edge_size coefficient is suitable for many
networks, but at the end it is tightly related with the number of edges.
It is useful to reevaluate if we want to use this number based on our
objective of "compactness" of the explanation.

I consider that this value is not properly announced (my feeling is that
normally it is just ignored) and with this PR I try to raise awareness
about it with a note in the comments of the class.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: rusty1s <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2023
1 parent 79bf578 commit ee30973
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions torch_geometric/explain/algorithm/gnn_explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ class GNNExplainer(ExplainerAlgorithm):
gnn_explainer_link_pred.py <https://github.com/pyg-team/
pytorch_geometric/blob/master/examples/explain/gnn_explainer_link_pred.py>`_.
.. note::
The :obj:`edge_size` coefficient is multiplied by the number of nodes
in the explanation at every iteration, and the resulting value is added
to the loss as a regularization term, with the goal of producing
compact explanations.
A higher value will push the algorithm towards explanations with less
elements.
Consider adjusting the :obj:`edge_size` coefficient according to the
average node degree in the dataset, especially if this value is bigger
than in the datasets used in the original paper.
Args:
epochs (int, optional): The number of epochs to train.
(default: :obj:`100`)
Expand Down

0 comments on commit ee30973

Please sign in to comment.