Package: graphgallery
TensorFloworPyTorch,both!GraphGalleryGraphGallery is a gallery for benchmarking Graph Neural Networks (GNNs) and Graph Adversarial Learning withTensorFlow 2.xandPyTorchbackend. Besides,Pytorch Geometric (PyG)backend andDeep Graph Library (DGL)backend now are available in GraphGallery.💨 NEWSWe have removed the TensorFlow dependencyand use PyTorch as the default backend for GraphGallery .We have integrated theAdversarial Attacksin this project, examples please refer toGraph Adversarial Learning examples.🚀 Installation# Outdatedpipinstall-Ugraphgalleryor# Recommendedgitclonehttps://github.com/EdisonLeeeee/GraphGallery.git&&cdGraphGallery
pipinstall-e.--verbosewhere-emeans "editable" mode so you don't have to reinstall every time you make changes.🤖 ImplementationsIn detail, the following methods are currently implemented:Node Classification TaskChebyNetfromMichaël Defferrard et al,📝Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering (NeurIPS'16)[:octocat:TensorFLow][🔥PyTorch]GCNfromThomas N. Kipf et al,📝Semi-Supervised Classification with Graph Convolutional Networks (ICLR'17)[:octocat:TensorFLow][🔥PyTorch][🔥PyG][🔥DGL]GraphSAGEfromWilliam L. Hamilton et al,📝Inductive Representation Learning on Large Graphs (NeurIPS'17)[:octocat:TensorFLow][🔥PyTorch]FastGCNfromJie Chen et al,📝FastGCN: Fast Learning with Graph Convolutional Networks via Importance Sampling (ICLR'18)[:octocat:TensorFLow][🔥PyTorch]LGCNfromHongyang Gao et al,📝Large-Scale Learnable Graph Convolutional Networks (KDD'18)[:octocat:TensorFLow][🔥PyTorch]GATfromPetar Veličković et al,📝Graph Attention Networks (ICLR'18)[:octocat:TensorFLow][🔥PyTorch][🔥PyG]SGCfromFelix Wu et al,📝Simplifying Graph Convolutional Networks (ICLR'19)[:octocat:TensorFLow][🔥PyTorch][🔥PyG]GWNNfromBingbing Xu et al,📝Graph Wavelet Neural Network (ICLR'19)[:octocat:TensorFLow][🔥PyTorch]GMNNfromMeng Qu et al,📝Graph Attention Networks (ICLR'19)[:octocat:TensorFLow][🔥PyTorch]ClusterGCNfromWei-Lin Chiang et al,📝Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks (KDD'19)[:octocat:TensorFLow][🔥PyTorch][🔥PyG]DAGNNfromMeng Liu et al,📝Towards Deeper Graph Neural Networks (KDD'20)[:octocat:TensorFLow][🔥PyTorch]GDCfromJohannes Klicpera et al,📝Diffusion Improves Graph Learning (NeurIPS'19)[:octocat:TensorFLow][🔥PyTorch][🔥PyG]TAGCNfromDu et al,📝Topology Adaptive Graph Convolutional Networks (arxiv'17)[:octocat:TensorFLow][🔥PyTorch]APPNP, PPNPfromJohannes Klicpera et al,📝Predict then Propagate: Graph Neural Networks meet Personalized PageRank (ICLR'19)[:octocat:TensorFLow(APPNP)][:octocat:TensorFLow(PPNP)][🔥PyTorch(APPNP)][🔥PyTorch(PPNP)]PDNfromBenedek Rozemberczki et al,📝Pathfinder Discovery Networks for Neural Message Passing (ICLR'21)[🔥PyG]SSGCfromZhu et al,📝Simple Spectral Graph Convolution (ICLR'21)[:octocat:TensorFLow][🔥PyTorch]AGNNfromZhu et al,📝Attention-based Graph Neural Network for semi-supervised learning (ICLR'18 openreview)[:octocat:TensorFLow][🔥PyTorch]ARMAfromBianchi et al.,📝Graph Neural Networks with convolutional ARMA filters (Arxiv'19)[:octocat:TensorFLow][🔥PyTorch]GraphMLPfromYang Hu et al.,📝Graph-MLP: Node Classification without Message Passing in Graph (Arxiv'21)[🔥PyTorch]Defense models (for Graph Adversarial Learning)Robust OptimizationRobustGCNfromPetar Veličković et al,📝Robust Graph Convolutional Networks Against Adversarial Attacks (KDD'19)[:octocat:TensorFLow][🔥PyTorch]SBVATfromZhijie Deng et al,📝Batch Virtual Adversarial Training for Graph Convolutional Networks (ICML'19)[:octocat:TensorFLow][🔥PyTorch]OBVATfromZhijie Deng et al,📝Batch Virtual Adversarial Training for Graph Convolutional Networks (ICML'19)[:octocat:TensorFLow][🔥PyTorch]SimPGCNfromWei Jin et al,📝Node Similarity Preserving Graph Convolutional Networks (WSDM'21)[🔥PyTorch]GCN-VAT, GraphVATfromFuli Feng et al,📝Graph Adversarial Training: Dynamically Regularizing Based on Graph Structure (TKDE'19)[🔥GCN-VAT-PyTorch][🔥GraphVAT-PyTorch]LATGCNfromHongwei Jin et al,📝Latent Adversarial Training of Graph Convolution Networks (ICML@LRGSD'19)[🔥PyTorch]DGATfromWeibo Hu et al,📝Robust graph convolutional networks with directional graph adversarial training (Applied Intelligence'19)[🔥PyTorch]Graph PurificationThe graph purification methods are universal for all models, just specify:graph_transform="purification_method"so, here we only give the examples ofGCNwith purification methods, other models should work.GCN-JaccardfromHuijun Wu et al,📝Adversarial Examples on Graph Data: Deep Insights into Attack and Defense (IJCAI'19)[:octocat:TensorFLow][🔥PyTorch]GCN-SVDfromNegin Entezari et al,📝All You Need Is Low (Rank): Defending Against Adversarial Attacks on Graphs (WSDM'20)[:octocat:TensorFLow][🔥PyTorch]EmbeddingDeepwalkfromBryan Perozzi et al,📝DeepWalk: Online Learning of Social Representations (KDD'14)[Example]Node2vecfromAditya Grover and Jure Leskovec,📝node2vec: Scalable Feature Learning for Networks (KDD'16)[Example]⚡ Quick Start on GNNsDatasetsmore details please refer toGraphData.Example of GCN (Node Classification Task)It takes just a few lines of code.fromgraphgallery.gallery.nodeclasimportGCNtrainer=GCN()trainer.setup_graph(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.If you have any troubles, you can simply runtrainer.help()for more messages.Other Backends>>>importgraphgallery# Default: PyTorch backend>>>graphgallery.backend()PyTorch1.7.0cu101Backend# Switch to TensorFlow backend>>>graphgallery.set_backend("tf")# Switch to PyTorch backend>>>graphgallery.set_backend("th")# Switch to PyTorch Geometric backend>>>graphgallery.set_backend("pyg")# Switch to DGL PyTorch backend>>>graphgallery.set_backend("dgl")But your codes don't even need to change.❓ How to add your datasetsThis is motivated bygnn-benchmarkfromgraphgallery.dataimportGraph# 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 datasetmydataset.to_npz('path/to/mydataset.npz')# load datasetmydataset=Graph.from_npz('path/to/mydataset.npz')⭐ Road MapAdd PyTorch trainers supportAdd other frameworks (PyG and DGL) supportset tensorflow as optional dependency when using graphgalleryAdd more GNN trainers (TF and Torch backend)Support for more tasks, e.g.,graph Classificationandlink predictionSupport for more types of graphs, e.g., Heterogeneous graphAdd Docstrings and Documentation (Building)Comprehensive tutorials❓ FAQ😘 AcknowledgementThis project is motivated byPytorch Geometric,Tensorflow Geometric,StellargraphandDGL, etc., and the original implementations of the authors, thanks for their excellent works!CitePlease cite ourpaper(and the respective papers of the methods used) if you use this code in your own work:@inproceedings{li2021graphgallery,author={Jintang Li and Kun Xu and Liang Chen and Zibin Zheng and Xiao Liu},booktitle={2021 IEEE/ACM 43rd International Conference on Software Engineering: Companion Proceedings (ICSE-Companion)},title={GraphGallery: A Platform for Fast Benchmarking and Easy Development of Graph Neural Networks Based Intelligent Software},year={2021},pages={13-16},publisher={IEEE Computer Society},address={Los Alamitos, CA, USA},}