torch_geometric.nn.conv.FAConv
- class FAConv(channels: int, eps: float = 0.1, dropout: float = 0.0, cached: bool = False, add_self_loops: bool = True, normalize: bool = True, **kwargs)[source]
Bases:
MessagePassing来自“超越图卷积网络中的低频信息”论文的频率自适应图卷积算子。
\[\mathbf{x}^{\prime}_i= \epsilon \cdot \mathbf{x}^{(0)}_i + \sum_{j \in \mathcal{N}(i)} \frac{\alpha_{i,j}}{\sqrt{d_i d_j}} \mathbf{x}_{j}\]其中 \(\mathbf{x}^{(0)}_i\) 和 \(d_i\) 分别表示节点 \(i\) 的初始特征表示和节点度。 注意力系数 \(\alpha_{i,j}\) 的计算方式如下:
\[\mathbf{\alpha}_{i,j} = \textrm{tanh}(\mathbf{a}^{\top}[\mathbf{x}_i, \mathbf{x}_j])\]基于可训练的参数向量 \(\mathbf{a}\)。
- Parameters:
channels (int) – 每个输入样本的大小,或
-1以从 forward 方法的第一个输入推导大小。eps (float, optional) – \(\epsilon\)-值。 (默认:
0.1)dropout (float, optional) – 归一化系数的丢弃概率,该系数在训练期间将每个节点暴露给随机采样的邻域。(默认值:
0)。cached (bool, optional) – 如果设置为
True,该层将在第一次执行时缓存 \(\sqrt{d_i d_j}\) 的计算结果,并在后续执行中使用缓存版本。 此参数应仅在传导学习场景中设置为True。(默认值:False)add_self_loops (bool, optional) – If set to
False, will not add self-loops to the input graph. (default:True)normalize (bool, optional) – 是否添加自循环(如果
add_self_loops是True)并动态计算 对称归一化系数。 如果设置为False,则需要在层的forward()方法中提供edge_weight。(默认值:True)**kwargs (optional) – Additional arguments of
torch_geometric.nn.conv.MessagePassing.
- Shapes:
input: node features \((|\mathcal{V}|, F)\), initial node features \((|\mathcal{V}|, F)\), edge indices \((2, |\mathcal{E}|)\), edge weights \((|\mathcal{E}|)\) (optional)
输出: 节点特征 \((|\mathcal{V}|, F)\) 或 \(((|\mathcal{V}|, F), ((2, |\mathcal{E}|), (|\mathcal{E}|)))\) 如果
return_attention_weights=True
- forward(x: Tensor, x_0: Tensor, edge_index: Union[Tensor, SparseTensor], edge_weight: Optional[Tensor] = None, return_attention_weights: Optional[Tensor] = None) Tensor[source]
- forward(x: Tensor, x_0: Tensor, edge_index: Tensor, edge_weight: Optional[Tensor] = None, return_attention_weights: bool = None) Tuple[Tensor, Tuple[Tensor, Tensor]]
- forward(x: Tensor, x_0: Tensor, edge_index: SparseTensor, edge_weight: Optional[Tensor] = None, return_attention_weights: bool = None) Tuple[Tensor, SparseTensor]
运行模块的前向传播。
- Parameters:
x (torch.Tensor) – The node features.
x_0 (torch.Tensor) – 初始输入节点特征。
edge_index (torch.Tensor or SparseTensor) – The edge indices.
edge_weight (torch.Tensor, optional) – The edge weights. (default:
None)return_attention_weights (bool, optional) – If set to
True, will additionally return the tuple(edge_index, attention_weights), holding the computed attention weights for each edge. (default:None)
- Return type:
Union[Tensor,Tuple[Tensor,Tuple[Tensor,Tensor]],Tuple[Tensor,SparseTensor]]