- class AttentionExplainer(reduce: str = 'max')[source]
An explainer that uses the attention coefficients produced by an attention-based GNN (e.g.,
TransformerConv) as edge explanation. Attention scores across layers and heads will be aggregated according to the
reduce (str, optional) – The method to reduce the attention scores across layers and heads. (default:
- forward(model: Module, x: Tensor, edge_index: Tensor, *, target: Tensor, index: Optional[Union[int, Tensor]] = None, **kwargs) Explanation [source]
Computes the explanation.
model (torch.nn.Module) – The model to explain.
x (Union[torch.Tensor, Dict[NodeType, torch.Tensor]]) – The input node features of a homogeneous or heterogeneous graph.
edge_index (Union[torch.Tensor, Dict[NodeType, torch.Tensor]]) – The input edge indices of a homogeneous or heterogeneous graph.
target (torch.Tensor) – The target of the model.
index (Union[int, Tensor], optional) – The index of the model output to explain. Can be a single index or a tensor of indices. (default:
**kwargs (optional) – Additional keyword arguments passed to