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:
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 to propagate(). Furthermore, tensors passed to propagate() can be mapped to the respective nodes \(i\) and \(j\) by appending _i or _j to the variable name, .e.g. x_i and x_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:
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 to propagate(). Furthermore, tensors passed to propagate() can be mapped to the respective nodes \(i\) and \(j\) by appending _i or _j to the variable name, .e.g. x_i and x_j.