Skip to main content

GraphGallery

GraphGallery

A gallery of state-of-the-arts graph neural networks. Implemented with Tensorflow 2.x.

This repo aims to achieve 4 goals:

  • Similar (or higher) performance
  • Faster training and testing
  • Simple and convenient to use, high scalability
  • Easy to read source codes

Requirements

  • python>=3.6
  • tensorflow>=2.1 (2.1 is recommended)
  • networkx==2.3
  • scipy>=1.4.1
  • sklearn>=0.22
  • numpy>=1.18.1
  • numba>=0.48
  • gensim>=3.8.1

Other packages (not necessary):

  • metis==0.2a4 (used for ClusterGCN)
  • texttable

Install

pip install -U graphgallery

Implementation

General models

  • GCN from Semi-Supervised Classification with Graph Convolutional Networks 🌐Paper
  • GAT from Graph Attention Networks 🌐Paper
  • SGC from Simplifying Graph Convolutional Networks 🌐Paper
  • GraphSAGE from Inductive Representation Learning on Large Graphs 🌐Paper
  • GWNN from Graph Wavelet Neural Network 🌐Paper
  • GMNN from Graph Markov Neural Networks 🌐Paper
  • ChebyNet from Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering 🌐Paper
  • ClusterGCN from Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks 🌐Paper
  • FastGCN from FastGCN: Fast Learning with Graph Convolutional Networks via Importance Sampling 🌐Paper
  • LGCN from Large-Scale Learnable Graph Convolutional Networks 🌐Paper

Defense models

  • RGCN from Robust Graph Convolutional Networks Against Adversarial Attacks 🌐Paper
  • SBVAT/OBVAT from Batch Virtual Adversarial Training for Graph Convolutional Networks 🌐Paper

Other models

  • GCN_MIX: Mixture of GCN and MLP
  • GCNF: GCN + feature
  • DenseGCN: Dense version of GCN
  • EdgeGCN: GCN using message passing framework
  • MedianSAGE: GraphSAGE using Median aggregation

Quick Start

Train a GCN model

from graphgallery.nn.models import GCN
# adj is scipy sparse matrix, x is numpy array matrix
model = GCN(adj, x, labels, device='GPU', seed=123)
# build your GCN model with custom hyper-parameters
model.build()
# train your model. here idx_train and idx_val are numpy arrays
his = model.train(idx_train, idx_val, verbose=1, epochs=100)
# test your model
loss, accuracy = model.test(idx_test)
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

On Cora dataset:

loss 1.02, acc 95.00%, val_loss 1.41, val_acc 77.40%: 100%|██████████| 100/100 [00:02<00:00, 37.07it/s]
Test loss 1.4123, Test accuracy 81.20%

Visualization

  • Accuracy
import matplotlib.pyplot as plt
plt.plot(his.history['acc'])
plt.plot(his.history['val_acc'])
plt.legend(['Accuracy', 'Val Accuracy'])
plt.xlabel('Epochs')

visualization

  • Loss
import matplotlib.pyplot as plt
plt.plot(his.history['loss'])
plt.plot(his.history['val_loss'])
plt.legend(['Loss', 'Val Loss'])
plt.xlabel('Epochs')

visualization

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphgallery-0.1.4.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphgallery-0.1.4-py3-none-any.whl (118.2 kB view details)

Uploaded Python 3

File details

Details for the file graphgallery-0.1.4.tar.gz.

File metadata

  • Download URL: graphgallery-0.1.4.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.1

File hashes

Hashes for graphgallery-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9b2875706575e1010b9fdf6fddc43554afb57fb85eb884f803ebff3cd52f5921
MD5 48ca29b70c2df2aa2058ca03941770cd
BLAKE2b-256 273226da4a3ebe371bdc6651d3725fca77736e0441e77616e178ef79620e9667

See more details on using hashes here.

File details

Details for the file graphgallery-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: graphgallery-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 118.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.1

File hashes

Hashes for graphgallery-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 78dc48a93c26298fa9df551341c1609cc1de0545e5d182c0705ee4b7f4542dfe
MD5 d414d509dda7729fd71414331e3d6005
BLAKE2b-256 4ef21a28580eca5cb4ba9c70733b4c4cc512ce9eae93ca35d809ff6916badca7

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.0

2 files

0.7.2

2 files

0.6.0

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page