torch_geometric_signed_directed.nn.signed.SNEAConv

Classes

SNEAConv

The signed graph attentional layers operator from the `"Learning Signed

Module Contents

class SNEAConv(in_dim: int, out_dim: int, first_aggr: bool, bias: bool = True, norm_emb: bool = True, add_self_loops=True, **kwargs)

Bases: torch_geometric.nn.conv.MessagePassing

The signed graph attentional layers operator from the “Learning Signed Network Embedding via Graph Attention” paper

\[ \begin{align}\begin{aligned}\mathbf{h}_{i}^{\mathcal{B}(l)}=\tanh \left(\sum_{j \in \hat{\mathcal{N}}_{i}^{+}, k \in \mathcal{N}_{i}^{-}} \alpha_{i j}^{\mathcal{B}(l)} \mathbf{h}_{j}^{\mathcal{B}(l-1)} \mathbf{W}^{\mathcal{B}(l)} +\alpha_{i k}^{\mathcal{B}(l)} \mathbf{h}_{k}^{\mathcal{U}(l-1)} \mathbf{W}^{\mathcal{B}(l)}\right)\\\mathbf{h}_{i}^{\mathcal{U}(l)}=\tanh \left(\sum_{j \in \hat{\mathcal{N}}_{i}^{+}, k \in \mathcal{N}_{i}^{-}} \alpha_{i j}^{\mathcal{U}(l)} \mathbf{h}_{j}^{\mathcal{U}(l-1)} \mathbf{W}^{\mathcal{U}(l)} +\alpha_{i k}^{\mathcal{U}(l)} \mathbf{h}_{k}^{\mathcal{B}(l-1)} \mathbf{W}^{\mathcal{U}(l)}\right)\end{aligned}\end{align} \]

In case first_aggr is False, the layer expects x to be a tensor where x[:, :in_dim] denotes the positive node features \(\mathbf{X}^{(\textrm{pos})}\) and x[:, in_dim:] denotes the negative node features \(\mathbf{X}^{(\textrm{neg})}\).

Parameters:
  • in_dim (int or tuple) – Size of each input sample, or -1 to 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.

  • bias (bool, optional) – If set to False, the layer will not learn an additive bias. (default: True)

  • **kwargs (optional) – Additional arguments of torch_geometric.nn.conv.MessagePassing.

in_dim
out_dim
first_aggr
add_self_loops = True
norm_emb = True
lin_b
lin_u
alpha_u
alpha_b
reset_parameters()
forward(x: torch.Tensor | torch_geometric.typing.PairTensor, pos_edge_index: torch.LongTensor, neg_edge_index: torch.LongTensor)
message(x1_j: torch.Tensor, x2_j: torch.Tensor, x1_i: torch.Tensor, x2_i: torch.Tensor, edge_p: torch.Tensor, alpha_func, index: torch.Tensor, ptr: torch_geometric.typing.OptTensor, size_i: int | None) torch.Tensor