torch_geometric.explain.algorithm.GNNExplainer

class GNNExplainer(epochs: int = 100, lr: float = 0.01, **kwargs)[source]

Bases: ExplainerAlgorithm

来自“GNNExplainer: Generating Explanations for Graph Neural Networks”论文的GNN-Explainer模型,用于识别在GNN预测中起关键作用的紧凑子图结构和节点特征。

注意

edge_size 系数在每次迭代时乘以解释中的节点数量,并将结果值作为正则化项添加到损失中,目的是生成紧凑的解释。 较高的值将推动算法生成元素较少的解释。 根据数据集中平均节点度调整 edge_size 系数,特别是如果该值大于原始论文中使用的数据集中的值。

Parameters:
  • epochs (int, optional) – 训练的轮数。 (默认: 100)

  • lr (float, optional) – 应用的学习率。 (默认: 0.01)

  • **kwargs (可选) – 用于覆盖默认设置的其他超参数 在 coeffs中。

forward(model: Module, x: Tensor, edge_index: Tensor, *, target: Tensor, index: Optional[Union[int, Tensor]] = None, **kwargs) Explanation[source]

计算解释。

Parameters:
  • 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: None)

  • **kwargs (optional) – Additional keyword arguments passed to model.

Return type:

Explanation

supports() bool[source]

Checks if the explainer supports the user-defined settings provided in self.explainer_config, self.model_config.

Return type:

bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。