Colabs with my solutions for CS224W: Machine Learning with Graphs (2021 Fall)
Related resoures:
- Course website with all slides and labs: - CS224W | Home (stanford.edu)
- Videos: Stanford CS224W: Machine Learning with Graphs - YouTube or 【双语字幕】斯坦福CS224W《图机器学习》课程(2021) by Jure Leskovec_哔哩哔哩_bilibili
- My notes: Machine Learning in Graphs (notion.site), summarised from CS224W (2021 Winter) videos and slides, which is slightly different from CS224W (2021 Fall)
The following tools/packages are used in these colabs (Python>=3.7):
- NetworkX: to create, manipulate, and mine graphs.
- PyTorch: machine learning framework.
- PyTorch Geometric (PyG): to develop graph deep learning models.
- DeepSNAP: flexible graph manipulation, standard pipeline and heterogeneous graph supports for graph deep learning.
Notes:
- Solutions are not guaranteed to be all correct, which are only for your references.
- Each colab has its own directory, in which CS224W_Colab_{i}.ipynbcontains all solutions andCS224W_Colab_{i} origin.ipynbis the origin empty version downloaded from course website.
- Outputs and other required materials are also contained (although most of them could be generated by codes automatically).
- 
Toy examples for using NetworkX. 
- 
Installation of PyG. 
- 
Example impletementations of graph neural network, including GCN training. 
- 
Use NetworkX APIs, including degree, clustering coefficient, pagerank value and closeness centrality. 
- 
Transfer edges to torch.tensor, including negative edge sampling. 
- 
Train node embeddings for two-way edge classification. 
- 
Use PyG datasets APIs, including getting meta data, labels and edges. 
- 
Use Open Graph Benchmark (OGB) to obtain dataset. 
- 
Design GCN model for node classification, including training, validation and testing. 
- 
Design GCN model for graph classification, including mini-batching, training, validation and testing. 
Implement layer module of GraphSage for node classification task, including forward, message and aggregate function.
Implement layer module of graph attention network (GAT) for node classification task, including forward, message and aggregate function.
- 
Add node types, labels and features as node attributes, add edge types as edge attributes in network X. 
- 
Transform homogenous graphs in networkX to heterogeneous graphs in DeepSNAP. 
- 
Count number of node types and edge types for heterogeneous graphs in DeepSNAP. 
- 
Use PyG and DeepSNAP to implement a GNN model for heterogeneous graph node classification, including heterogeneous message passing layer, wrapper layer, GNN layer, model training and testing.