GCN on the real karate network
Actually train a GCN on small real data with few labelled nodes, then read the accuracy and the confusion matrix honestly.
Run the experimentNode Classification Lab
Actually train GCN, GraphSAGE, GAT or GIN in your browser on the real karate network or a synthetic graph, with a training, validation and test split, the confusion matrix, accuracy, precision, recall and F1, and a comparison of runs.
Node classification is usually a transductive, semi-supervised task: we know the class of some nodes and want the class of the rest. The loss is computed on the training nodes only, the best epoch is chosen by validation accuracy, and the test set is touched only once at the end. Try the number of labelled nodes, the layers, dropout and the learning rate, and compare with an MLP that does not see the graph to learn what the structure added.
\hat{y}_i=\arg\max_c\ \mathrm{softmax}\!\left(f_\theta(X,A)\right)_{ic}\mathrm{Acc}=\frac{1}{|T|}\sum_{i\in T}\mathbb{1}[\hat{y}_i=y_i],\quad F_1=\frac{2PR}{P+R}Loading the interactive lab…
Actually train a GCN on small real data with few labelled nodes, then read the accuracy and the confusion matrix honestly.
Run the experimentTo see the gap between training accuracy and test accuracy when there are very few labelled nodes and the model is large and unregularised.
Run the experimentTo measure the effect of adding GCN layers on accuracy and on the similarity of node representations.
Run the experimentTrain a GAT, then show the attention coefficients of a chosen node as the thickness of the edges.
Run the experimentCompare a model that distinguishes relation types (R-GCN) with a model that treats them all the same (GCN) on a small knowledge graph.
Run the experimentWe know the labels of a few nodes and want the labels of the rest. The whole graph (including the unlabelled nodes) is used in message passing, but the loss is computed on the labelled nodes only. This is the setup of Kipf & Welling (2017) on Cora.
Do not use the labels of the validation or test nodes in the loss or in feature selection, choose the hyperparameters on validation, not on test, and do not normalise the features with statistics computed from the test set. Having the test nodes in the graph during training is acceptable in the transductive setup, because their labels are hidden.
Because the test set is small: the karate network has about 20 test nodes, so each error changes the accuracy by about 5 points. Always report the mean and the standard deviation over several seeds, and do not conclude from a single run.
The row is the true class and the column is the predicted class. The diagonal holds the correct predictions. A cell (i,j) off the diagonal means that nodes of class i were wrongly classified as j. Precision, recall and F1 for each class are computed from it.
Overall accuracy hides the model's weakness on small classes. Macro-F1 computes the F1 of each class and then averages them equally, so it reveals whether the model ignores a rare class.
When training accuracy reaches nearly 100% while validation accuracy stalls or drops, and the training loss falls while the validation loss rises. Remedies: dropout, L2 regularisation, a smaller hidden size, and early stopping on validation.
Transductive: the whole graph, including the test nodes, is available during training, with their labels hidden (the standard Cora). Inductive: the model must work on nodes or graphs it has never seen, as with GraphSAGE on new graphs.
You can use the identity matrix (a one-hot vector for each node), as in the karate experiment, but it does not generalise to new nodes. Alternatives: the degree, structural measures, Node2Vec embeddings, or the same constant vector for all nodes.
Real training with backpropagation in the browser, up to 400 nodes. On small graphs the results change a lot with the seed and the split; run several seeds before drawing any conclusion. Cora and others run through the optional Python server.
Sections
No section has this name. Press “Search” to search all site content.
Favourites
My results & certificates
My academy progressMy quiz resultsKids’ progressAcademy certificatesQuiz certificatesStart any lesson or quiz and it will show up here so you can get back to it quickly.
Settings
I am the graph neural network assistant. Ask me about a concept, an algorithm or a dataset, or ask for an experiment or a project, and I will answer from the lab's content, citing the sources.
It answers from the lab's knowledge base only, with no external language model and without sending your question to any outside party.
The assistant can make mistakes, so check the attached sources.