torch_geometric_signed_directed.nn.signed.SGCNConv
Classes
The signed graph convolutional operator from the `"Signed Graph |
Module Contents
- class SGCNConv(in_dim: int, out_dim: int, first_aggr: bool, bias: bool = True, norm_emb: bool = False, **kwargs)
Bases:
torch_geometric.nn.conv.MessagePassingThe signed graph convolutional operator from the “Signed Graph Convolutional Network” paper
\[ \begin{align}\begin{aligned}\mathbf{x}_v^{(\textrm{pos})} &= \mathbf{\Theta}^{(\textrm{pos})} \left[ \frac{1}{|\mathcal{N}^{+}(v)|} \sum_{w \in \mathcal{N}^{+}(v)} \mathbf{x}_w , \mathbf{x}_v \right]\\\mathbf{x}_v^{(\textrm{neg})} &= \mathbf{\Theta}^{(\textrm{neg})} \left[ \frac{1}{|\mathcal{N}^{-}(v)|} \sum_{w \in \mathcal{N}^{-}(v)} \mathbf{x}_w , \mathbf{x}_v \right]\end{aligned}\end{align} \]if
first_aggris set toTrue, and\[ \begin{align}\begin{aligned}\mathbf{x}_v^{(\textrm{pos})} &= \mathbf{\Theta}^{(\textrm{pos})} \left[ \frac{1}{|\mathcal{N}^{+}(v)|} \sum_{w \in \mathcal{N}^{+}(v)} \mathbf{x}_w^{(\textrm{pos})}, \frac{1}{|\mathcal{N}^{-}(v)|} \sum_{w \in \mathcal{N}^{-}(v)} \mathbf{x}_w^{(\textrm{neg})}, \mathbf{x}_v^{(\textrm{pos})} \right]\\\mathbf{x}_v^{(\textrm{neg})} &= \mathbf{\Theta}^{(\textrm{pos})} \left[ \frac{1}{|\mathcal{N}^{+}(v)|} \sum_{w \in \mathcal{N}^{+}(v)} \mathbf{x}_w^{(\textrm{neg})}, \frac{1}{|\mathcal{N}^{-}(v)|} \sum_{w \in \mathcal{N}^{-}(v)} \mathbf{x}_w^{(\textrm{pos})}, \mathbf{x}_v^{(\textrm{neg})} \right]\end{aligned}\end{align} \]otherwise. In case
first_aggrisFalse, the layer expectsxto be a tensor wherex[:, :in_dim]denotes the positive node features \(\mathbf{X}^{(\textrm{pos})}\) andx[:, in_dim:]denotes the negative node features \(\mathbf{X}^{(\textrm{neg})}\).- Parameters:
in_dim (int or tuple) – Size of each input sample, or
-1to derive the size from the first input(s) to the forward method. A tuple corresponds to the sizes of source and target dimensionalities.out_dim (int) – Size of each output sample.
first_aggr (bool) – Denotes which aggregation formula to use.
norm_emb (bool, optional) – Whether to normalize embeddings. (default:
False)bias (bool, optional) – If set to
False, the layer will not learn an additive bias. (default:True)norm_emb (bool) – Denotes embedding is normalized or not. (default:
False)**kwargs (optional) – Additional arguments of
torch_geometric.nn.conv.MessagePassing.
- in_dim
- out_dim
- first_aggr
- norm_emb = False
- reset_parameters()
- forward(x: torch.Tensor | torch_geometric.typing.PairTensor, pos_edge_index: torch_geometric.typing.Adj, neg_edge_index: torch_geometric.typing.Adj) torch.Tensor
- message(x_j: torch.Tensor) torch.Tensor
- message_and_aggregate(adj_t: torch_geometric.typing.SparseTensor, x: torch_geometric.typing.PairTensor) torch.Tensor