Skip to content

GraphGallery is a gallery for benchmarking Graph Neural Networks (GNNs) and Graph Adversarial Learning with TensorFlow 2.x and PyTorch backend.

License

Notifications You must be signed in to change notification settings

vu1seek/GraphGallery

 
 

Repository files navigation

banner

TensorFLow or PyTorch? Both!

Python tensorflow pytorch pypi license

GraphGallery

GraphGallery is a gallery for benchmarking Graph Neural Networks (GNNs) and Graph Adversarial Learning with TensorFlow 2.x and PyTorch backend. Besides, Pytorch Geometric (PyG) backend and Deep Graph Library (DGL) backend now are available in GraphGallery.

demo

💨 NEWS

We have integrated the Adversarial Attacks in this project, examples please refer to Graph Adversarial Learning examples.

🚀 Installation

pip install -U graphgallery

or

git clone https://github.com/EdisonLeeeee/GraphGallery.git
cd GraphGallery
pip install -e .

GraphGallery has been tested on:

  • CPU, CUDA 10.1, CUDA 11.0
  • TensorFlow 2.1~2.4, 2.1.2 is recommended.
  • PyTorch 1.4~1.7
  • Pytorch Geometric (PyG) 1.6.1
  • DGL 0.5.2, 0.5.3

🤖 Implementations

In detail, the following methods are currently implemented:

Node Classification Task

ChebyNet from Michaël Defferrard et al, 📝Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering (NeurIPS'16) [:octocat:TensorFLow] [🔥PyTorch]
GCN from Thomas N. Kipf et al, 📝Semi-Supervised Classification with Graph Convolutional Networks (ICLR'17) [:octocat:TensorFLow] [🔥PyTorch] [🔥PyG] [🔥DGL-PyTorch] [:octocat:DGL-TensorFlow]
GraphSAGE from William L. Hamilton et al, 📝Inductive Representation Learning on Large Graphs (NeurIPS'17) [:octocat:TensorFLow] [🔥PyTorch]
FastGCN from Jie Chen et al, 📝FastGCN: Fast Learning with Graph Convolutional Networks via Importance Sampling (ICLR'18) [:octocat:TensorFLow] [🔥PyTorch]
LGCN from Hongyang Gao et al, 📝Large-Scale Learnable Graph Convolutional Networks (KDD'18) [:octocat:TensorFLow] [🔥PyTorch]
GAT from Petar Veličković et al, 📝Graph Attention Networks (ICLR'18) [:octocat:TensorFLow] [🔥PyTorch] [🔥PyG]
SGC from Felix Wu et al, 📝Simplifying Graph Convolutional Networks (ICLR'19) [:octocat:TensorFLow] [🔥PyTorch] [🔥PyG]
GWNN from Bingbing Xu et al, 📝Graph Wavelet Neural Network (ICLR'19) [:octocat:TensorFLow] [🔥PyTorch]
GMNN from Meng Qu et al, 📝Graph Attention Networks (ICLR'19) [:octocat:TensorFLow] [🔥PyTorch]
ClusterGCN from Wei-Lin Chiang et al, 📝Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks (KDD'19) [:octocat:TensorFLow] [🔥PyTorch] [🔥PyG]
DAGNN from Meng Liu et al, 📝Towards Deeper Graph Neural Networks (KDD'20) [:octocat:TensorFLow] [🔥PyTorch]
GDC from Johannes Klicpera et al, 📝Diffusion Improves Graph Learning (NeurIPS'19) [:octocat:TensorFLow] [🔥PyTorch] [🔥PyG]
TAGCN from Du et al, 📝Topology Adaptive Graph Convolutional Networks (arxiv'17) [:octocat:TensorFLow] [🔥PyTorch]
APPNP, PPNP from Johannes Klicpera et al, 📝Predict then Propagate: Graph Neural Networks meet Personalized PageRank (ICLR'19) [:octocat:TensorFLow(APPNP)] [:octocat:TensorFLow(PPNP)] [🔥PyTorch(APPNP)] [🔥PyTorch(PPNP)]
PDN from Benedek Rozemberczki et al, 📝Pathfinder Discovery Networks for Neural Message Passing (ICLR'21) [🔥PyG]
SSGC from Zhu et al, 📝Simple Spectral Graph Convolution (ICLR'21) [:octocat:TensorFLow] [🔥PyTorch]
AGNN from Zhu et al, 📝Attention-based Graph Neural Network for semi-supervised learning (ICLR'18 openreview) [:octocat:TensorFLow] [🔥PyTorch]
ARMA from Bianchi et al., 📝Graph Neural Networks with convolutional ARMA filters (Arxiv'19) [:octocat:TensorFLow] [🔥PyTorch]

Defense models (for Graph Adversarial Learning)

Robust Optimization

RobustGCN from Petar Veličković et al, 📝Robust Graph Convolutional Networks Against Adversarial Attacks (KDD'19) [:octocat:TensorFLow] [🔥PyTorch]
SBVAT from Zhijie Deng et al, 📝Batch Virtual Adversarial Training for Graph Convolutional Networks (ICML'19) [:octocat:TensorFLow] [🔥PyTorch]
OBVAT from Zhijie Deng et al, 📝Batch Virtual Adversarial Training for Graph Convolutional Networks (ICML'19) [:octocat:TensorFLow] [🔥PyTorch]
SimPGCN from Wei Jin et al, 📝Node Similarity Preserving Graph Convolutional Networks (WSDM'21) [🔥PyTorch]

Graph Purification

The graph purification methods are universal for all models, just specify:

graph_transform="purification_method"

so, here we only give the examples of GCN with purification methods, other models should work.

GCN-Jaccard from Huijun Wu et al, 📝Adversarial Examples on Graph Data: Deep Insights into Attack and Defense (IJCAI'19) [:octocat:TensorFLow] [🔥PyTorch]
GCN-SVD from Negin Entezari et al, 📝All You Need Is Low (Rank): Defending Against Adversarial Attacks on Graphs (WSDM'20) [:octocat:TensorFLow] [🔥PyTorch]

Embedding

Deepwalk from Bryan Perozzi et al, 📝DeepWalk: Online Learning of Social Representations (KDD'14) [Example]
Node2vec from Aditya Grover and Jure Leskovec, 📝node2vec: Scalable Feature Learning for Networks (KDD'16) [Example]

⚡ Quick Start on GNNs

Datasets

more details please refer to GraphData.

Example of GCN (Node Classification Task)

It takes just a few lines of code.

from graphgallery.gallery.nodeclas import GCN
trainer = GCN()
trainer.make_data(graph)
trainer.build()
history = trainer.fit(train_nodes, val_nodes)
results = trainer.evaluate(test_nodes)
print(f'Test loss {results.loss:.5}, Test accuracy {results.accuracy:.2%}')

Other models in the gallery are the same.

Other Backends

>>> import graphgallery
# Default: TensorFlow backend
>>> graphgallery.backend()
TensorFlow 2.1.2 Backend
# Switch to PyTorch backend
>>> graphgallery.set_backend("torch")
# Switch to TensorFlow backend
>>> graphgallery.set_backend("tf")
# Switch to PyTorch Geometric backend
>>> graphgallery.set_backend("pyg")
# Switch to DGL PyTorch backend
>>> graphgallery.set_backend("dgl")
# Switch to DGL TensorFlow backend
>>> graphgallery.set_backend("dgl-tf")

But your codes don't even need to change.

❓ How to add your datasets

This is motivated by gnn-benchmark

from graphgallery.data import Graph

# Load the adjacency matrix A, attribute matrix X and labels vector y
# A - scipy.sparse.csr_matrix of shape [num_nodes, num_nodes]
# X - scipy.sparse.csr_matrix or np.ndarray of shape [num_nodes, num_attrs]
# y - np.ndarray of shape [num_nodes]

mydataset = Graph(adj_matrix=A, node_attr=X, node_label=y)
# save dataset
mydataset.to_npz('path/to/mydataset.npz')
# load dataset
mydataset = Graph.from_npz('path/to/mydataset.npz')

⭐ Road Map

  • Add PyTorch trainers support
  • Add other frameworks (PyG and DGL) support
  • Add more GNN trainers (TF and Torch backend)
  • Support for more tasks, e.g., graph Classification and link prediction
  • Support for more types of graphs, e.g., Heterogeneous graph
  • Add Docstrings and Documentation (Building)
  • Comprehensive tutorials

😘 Acknowledgement

This project is motivated by Pytorch Geometric, Tensorflow Geometric, Stellargraph and DGL, etc., and the original implementations of the authors, thanks for their excellent works!

Cite

Please cite our paper (and the respective papers of the methods used) if you use this code in your own work:

@article{li2021graphgallery,
  title={GraphGallery: A Platform for Fast Benchmarking and Easy Development of Graph Neural Networks Based Intelligent Software},
  author={Li, Jintang and Xu, Kun and Chen, Liang and Zheng, Zibin and Liu, Xiao},
  journal={arXiv preprint arXiv:2102.07933},
  year={2021}
}

About

GraphGallery is a gallery for benchmarking Graph Neural Networks (GNNs) and Graph Adversarial Learning with TensorFlow 2.x and PyTorch backend.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 93.8%
  • Jupyter Notebook 6.2%