import torch from torch_geometric.nn import GCNConv # define input feature matrix x = torch.tensor([[1, 2], [2, 3], [3, 4]], dtype=torch.float) # define edge index tensor, indicating the edges of the graph edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]], dtype=torch.long) # define the GCNConv layer conv_layer = GCNConv(2, 4) # apply the conv layer to the input graph output = conv_layer(x, edge_index) # the resulting output graph has 2 nodes and 4 features assert output.size() == (2, 4)
import torch from torch_geometric.nn import GCNConv # define input feature matrix and edge index tensor x = torch.tensor([[1, 2], [2, 3], [3, 4]], dtype=torch.float) edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]], dtype=torch.long) # define the GCNConv layers conv_layer1 = GCNConv(2, 4) conv_layer2 = GCNConv(4, 1) # apply the conv layers to the input graph output = conv_layer2(conv_layer1(x, edge_index), edge_index) # the resulting output graph has 3 nodes and 1 feature assert output.size() == (3, 1)The package library used in this examples is PyTorch Geometric.