# Graph convolution network for variable number of nodes

Is it possible to train a graph convolutional network on graphs with a varying number of nodes? I have a dataset of graphs with a range of 400-1000 nodes, though I could see a higher number of nodes when it's deployed in the real world. I'm using dgl to try and classify each node as one of k classes with a graph convolutional network. However, I can't find a way to do it when the size of my graph varies across my training set. Is there a simple way to do this?

So far I've tried a GCN that looks something like the one from the tutorial

class GCN(nn.Module):
def __init__(self, in_feats, hidden_size, num_classes):
super(GCN, self).__init__()
self.conv1 = GraphConv(in_feats, hidden_size)
self.conv2 = GraphConv(hidden_size, num_classes)

def forward(self, g, inputs):
h = self.conv1(g, inputs)
h = torch.relu(h)
h = self.conv2(g, h)
return h


Of course, this only works if it's possible to find a padding function $$p$$ such that for the given operation $$f$$, $$p^{-1}(f(p(x))) = f(x)$$ modulo some unimportant details. Luckily this is roughly true for almost any operation used in a NN, and it seems to hold true for spatial graph conv as well.