torch_geometric.explain.algorithm.GraphMaskExplainer
- class GraphMaskExplainer(num_layers: int, epochs: int = 100, lr: float = 0.01, penalty_scaling: int = 5, lambda_optimizer_lr: int = 0.01, init_lambda: int = 0.55, allowance: int = 0.03, allow_multiple_explanations: bool = False, log: bool = True, **kwargs)[source]
Bases:
ExplainerAlgorithm来自“Interpreting Graph Neural Networks for NLP With Differentiable Edge Masking”论文的GraphMask-Explainer模型,用于识别在GNN预测中起关键作用的分层紧凑子图结构和节点特征。
注意
有关使用
GraphMaskExplainer的示例, 请参见 examples/explain/graphmask_explainer.py。一个实际运行的实时示例,以部署的应用程序形式存在的
GraphMaskExplainer,可以访问这里。- Parameters:
num_layers (int) – 使用的层数。
epochs (int, optional) – The number of epochs to train. (default:
100)lr (float, optional) – The learning rate to apply. (default:
0.01)penalty_scaling (int, optional) – 惩罚项的缩放值。值必须在0到10之间。(默认值:
5)lambda_optimizer_lr (float, optional) – 用于优化拉格朗日乘数的学习率。(默认值:
1e-2)init_lambda (float, optional) – 拉格朗日乘数。值必须在
0和 1 之间。(默认值:0.55)allowance (float, optional) – 一个介于
0和1之间的浮点值,表示容忍级别。(默认值:0.03)**kwargs (optional) – Additional hyper-parameters to override default settings in
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: