torch_geometric.nn.conv.SignedConv

class SignedConv(in_channels: int, out_channels: int, first_aggr: bool, bias: bool = True, **kwargs)[source]

Bases: MessagePassing

The 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_aggr is set to True, 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_aggr is False, the layer expects x to be a tensor where x[:, :in_channels] denotes the positive node features $$\mathbf{X}^{(\textrm{pos})}$$ and x[:, in_channels:] denotes the negative node features $$\mathbf{X}^{(\textrm{neg})}$$.

Parameters:
Shapes:
• input: node features $$(|\mathcal{V}|, F_{in})$$ or $$((|\mathcal{V_s}|, F_{in}), (|\mathcal{V_t}|, F_{in}))$$ if bipartite, positive edge indices $$(2, |\mathcal{E}^{(+)}|)$$, negative edge indices $$(2, |\mathcal{E}^{(-)}|)$$

• outputs: node features $$(|\mathcal{V}|, F_{out})$$ or $$(|\mathcal{V_t}|, F_{out})$$ if bipartite

forward(x: , pos_edge_index: Union[Tensor, SparseTensor], neg_edge_index: Union[Tensor, SparseTensor])[source]

Runs the forward pass of the module.

reset_parameters()[source]

Resets all learnable parameters of the module.