# torch_geometric.nn.conv.GCNConv

class GCNConv(in_channels: int, out_channels: int, improved: bool = False, cached: bool = False, add_self_loops: = None, normalize: bool = True, bias: bool = True, **kwargs)[source]

Bases: MessagePassing

The graph convolutional operator from the “Semi-supervised Classification with Graph Convolutional Networks” paper.

$\mathbf{X}^{\prime} = \mathbf{\hat{D}}^{-1/2} \mathbf{\hat{A}} \mathbf{\hat{D}}^{-1/2} \mathbf{X} \mathbf{\Theta},$

where $$\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}$$ denotes the adjacency matrix with inserted self-loops and $$\hat{D}_{ii} = \sum_{j=0} \hat{A}_{ij}$$ its diagonal degree matrix. The adjacency matrix can include other values than 1 representing edge weights via the optional edge_weight tensor.

Its node-wise formulation is given by:

$\mathbf{x}^{\prime}_i = \mathbf{\Theta}^{\top} \sum_{j \in \mathcal{N}(i) \cup \{ i \}} \frac{e_{j,i}}{\sqrt{\hat{d}_j \hat{d}_i}} \mathbf{x}_j$

with $$\hat{d}_i = 1 + \sum_{j \in \mathcal{N}(i)} e_{j,i}$$, where $$e_{j,i}$$ denotes the edge weight from source node j to target node i (default: 1.0)

Parameters:
Shapes:
• input: node features $$(|\mathcal{V}|, F_{in})$$, edge indices $$(2, |\mathcal{E}|)$$ or sparse matrix $$(|\mathcal{V}|, |\mathcal{V}|)$$, edge weights $$(|\mathcal{E}|)$$ (optional)

• output: node features $$(|\mathcal{V}|, F_{out})$$

forward(x: Tensor, edge_index: Union[Tensor, SparseTensor], edge_weight: = None) [source]

Runs the forward pass of the module.

reset_parameters()[source]

Resets all learnable parameters of the module.