Suppose we want a GCN that classifies molecules as toxic or harmless.
The network inputs are the adjacency matrix and node embedding matrix .
- The adjacency matrix derives from the molecular structure.
- The columns of the node embedding matrix are one-hot vectors indicating which of the 118 elements of the periodic table are present.
The node embeddings can be transformed to an arbitrary size by the first weight matrix . The network equations are:
where the network output is a single value that determines the probability the molecule is toxic.
Training with batches
Given training graphs and their labels , the parameters can be learned using SGD and binary cross-entropy loss. We can exploit the parallelism of modern hardware to process an entire batch of training examples concurrently. To do this, the batch elements are concatenated into a higher-dimensional tensor.
However, each graph may have a different number of nodes. Hence, the matrices and have different sizes, and there is no way to concatenate them into 3D tensors. Luckily, a simple trick allows us to process the whole batch in parallel. The graphs in the batch are treated as disjoint components of a single large graph. The network can then be run as a single instance of the network equations. The mean pooling is carried out only over the individual graphs to make a single representation per graph that can be fed into the loss function.