pygod.nn.conv¶
Convolutional Layers for Graph Neural Networks.
- class pygod.nn.conv.GNAConv(in_channels, out_channels)[source]¶
Bases:
MessagePassing
Graph Node Attention Network (GNA) layer. See [YZY+21] for more details.
- forward(s, edge_index)[source]¶
Forward computation.
- Parameters:
s (torch.Tensor) – Input node embeddings.
edge_index (torch.Tensor) – Edge index.
- Returns:
s – Updated node embeddings.
- Return type:
torch.Tensor
- message(s_i, s_j, edge_index)[source]¶
Constructs messages from node \(j\) to node \(i\) in analogy to \(\phi_{\mathbf{\Theta}}\) for each edge in
edge_index
. This function can take any argument as input which was initially passed topropagate()
. Furthermore, tensors passed topropagate()
can be mapped to the respective nodes \(i\) and \(j\) by appending_i
or_j
to the variable name, .e.g.x_i
andx_j
.
- class pygod.nn.conv.NeighDiff[source]¶
Bases:
MessagePassing
Calculate the Euclidean distance between the node features of the central node and its neighbors, reducing by mean.
- forward(h, edge_index)[source]¶
Forward computation.
- Parameters:
h (torch.Tensor) – Input node embeddings.
edge_index (torch.Tensor) – Edge index.
- Returns:
h – Updated node embeddings.
- Return type:
torch.Tensor
- message(h_i, h_j, edge_index)[source]¶
Constructs messages from node \(j\) to node \(i\) in analogy to \(\phi_{\mathbf{\Theta}}\) for each edge in
edge_index
. This function can take any argument as input which was initially passed topropagate()
. Furthermore, tensors passed topropagate()
can be mapped to the respective nodes \(i\) and \(j\) by appending_i
or_j
to the variable name, .e.g.x_i
andx_j
.