torch_geometric.explain.algorithm.ExplainerAlgorithm

class ExplainerAlgorithm[source]

Bases: Module

用于实现解释器算法的抽象基类。

abstract forward(model: Module, x: Union[Tensor, Dict[str, Tensor]], edge_index: Union[Tensor, Dict[Tuple[str, str, str], Tensor]], *, target: Tensor, index: Optional[Union[int, Tensor]] = None, **kwargs) Union[Explanation, HeteroExplanation][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:

Union[Explanation, HeteroExplanation]

abstract 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,不需要翻译。因此,翻译后的内容保持不变。

property explainer_config: ExplainerConfig

返回已连接的解释器配置。

Return type:

ExplainerConfig

property model_config: ModelConfig

返回连接的模型配置。

Return type:

ModelConfig

connect(explainer_config: ExplainerConfig, model_config: ModelConfig)[source]

将解释器和模型配置连接到解释器算法。