Skip to content

Commit

Permalink
Add a demo for fine-tuning a DGI-trained model (#1587)
Browse files Browse the repository at this point in the history
This adds a demo that uses Deep Graph Infomax and GCN for semi-supervised
training. In particular, it:

- pre-trains a GCN model using Deep Graph Infomax
- fine-tunes the trained model for node classification

It does this in a _very_ data scarce setting: 8 training examples, with one or
two examples of each class.

To validate that using Deep Graph Infomax for pre-training is helpful, the demo
also compares to a GCN model without pretraining, that is just trained on the 8
training examples directly.

See: #1588
  • Loading branch information
huonw committed May 26, 2020
1 parent 9664d0b commit 9204034
Show file tree
Hide file tree
Showing 7 changed files with 887 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Expand Up @@ -115,7 +115,7 @@ steps:
<<: *timeout
key: "test-notebooks"
depends_on: "runner-3_6"
parallelism: 51
parallelism: 52
command: ".buildkite/steps/test-demo-notebooks.sh"
plugins:
<<: *plugins
Expand Down
15 changes: 14 additions & 1 deletion demos/embeddings/deep-graph-infomax-embeddings.ipynb
Expand Up @@ -25,7 +25,9 @@
"source": [
"This demo demonstrates how to perform unsupervised training of a GCN, GAT, APPNP, or GraphSAGE model using the Deep Graph Infomax algorithm (https://arxiv.org/pdf/1809.10341.pdf) on the CORA dataset. \n",
"\n",
"As with all StellarGraph workflows: first we load the dataset, next we create our data generators, and then we train our model. We then take the embeddings created through unsupervised training and predict the node classes using logistic regression."
"As with all StellarGraph workflows: first we load the dataset, next we create our data generators, and then we train our model. We then take the embeddings created through unsupervised training and predict the node classes using logistic regression.\n",
"\n",
"> See [the GCN + Deep Graph Infomax fine-tuning demo](../node-classification/gcn-deep-graph-infomax-fine-tuning-node-classification.ipynb) for semi-supervised training using Deep Graph Infomax, by fine-tuning the base model for node classification using labelled data."
]
},
{
Expand Down Expand Up @@ -603,6 +605,17 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conclusion\n",
"\n",
"This notebook demonstrated how to use the Deep Graph Infomax algorithm to train other algorithms to yield useful embedding vectors for nodes, without supervision. To validate the quality of these vectors, it used logistic regression to perform a supervised node classification task.\n",
"\n",
"See [the GCN + Deep Graph Infomax fine-tuning demo](../node-classification/gcn-deep-graph-infomax-fine-tuning-node-classification.ipynb) for semi-supervised training using Deep Graph Infomax, by fine-tuning the base model for node classification using labelled data."
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions demos/node-classification/README.md
Expand Up @@ -11,6 +11,7 @@ These demos are displayed with detailed descriptions in the documentation: https
| [Node classification with Cluster-GCN](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/cluster-gcn-node-classification.html) | [source](cluster-gcn-node-classification.ipynb) |
| [Node classification with directed GraphSAGE](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/directed-graphsage-node-classification.html) | [source](directed-graphsage-node-classification.ipynb) |
| [Node classification with Graph ATtention Network (GAT)](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/gat-node-classification.html) | [source](gat-node-classification.ipynb) |
| [Semi-supervised node classification via GCN, Deep Graph Infomax and fine-tuning](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/gcn-deep-graph-infomax-fine-tuning-node-classification.html) | [source](gcn-deep-graph-infomax-fine-tuning-node-classification.ipynb) |
| [Node classification with Graph Convolutional Network (GCN)](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/gcn-node-classification.html) | [source](gcn-node-classification.ipynb) |
| [(Moved) Node classification with Graph Convolutional Network (GCN)](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/gcn/gcn-cora-node-classification-example.html) | [source](gcn/gcn-cora-node-classification-example.ipynb) |
| [Inductive node classification and representation learning using GraphSAGE](https://stellargraph.readthedocs.io/en/stable/demos/node-classification/graphsage-inductive-node-classification.html) | [source](graphsage-inductive-node-classification.ipynb) |
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions demos/node-classification/gcn-node-classification.ipynb
Expand Up @@ -1333,6 +1333,8 @@
"2. built a TensorFlow Keras model and data generator with [the StellarGraph library](https://github.com/stellargraph/stellargraph) \n",
"3. trained and evaluated it using TensorFlow and other libraries\n",
"\n",
"For problems with only small amounts of labelled data, model performance can be improved by semi-supervised training. See [the GCN + Deep Graph Infomax fine-tuning demo](gcn-deep-graph-infomax-fine-tuning-node-classification.ipynb) for more details on how to do this.\n",
"\n",
"StellarGraph includes [other algorithms for node classification](README.md) and [algorithms and demos for other tasks](../README.md). Most can be applied with the same basic structure as this GCN demo."
]
},
Expand Down
@@ -0,0 +1,3 @@
{
"path": "../../../demos/node-classification/gcn-deep-graph-infomax-fine-tuning-node-classification.ipynb"
}
8 changes: 8 additions & 0 deletions docs/demos/node-classification/index.rst
Expand Up @@ -119,6 +119,14 @@ This table lists all node classification demos, including the algorithms trained
- yes
-
- yes
* - :doc:`GCN, Deep Graph Infomax and fine-tuning <gcn-deep-graph-infomax-fine-tuning-node-classification>`
- GCN, DeepGraphInfomax, semi-supervised training
- yes
-
-
-
-
- yes


See :doc:`the root README <../../README>` or each algorithm's documentation for the relevant citation(s). See :doc:`the demo index <../index>` for more tasks, and a summary of each algorithm.
Expand Down

0 comments on commit 9204034

Please sign in to comment.