Skip to main content

logo

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.

💨 NEWS

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

🚀 Installation

pip install -U graphgallery

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

Please refer to the examples directory. (The examples are updating...)

⚡ Quick Start on GNNs

Datasets

more details please refer to GraphData.

Example of GCN

from graphgallery.gallery import GCN

# initialize a GNN trainer
trainer = GCN(graph)
# process your inputs, such as converting to tensors
trainer.process()
# build your GCN trainer with default hyper-parameters
trainer.build()
# train your trainer. here splits.train_nodes and splits.val_nodes are numpy arrays
# verbose takes 0, 1, 2, 3, 4
history = trainer.train(splits.train_nodes, splits.val_nodes, verbose=1, epochs=100)
# test your trainer
# verbose takes 0, 1, 2
results = trainer.test(splits.nodes, verbose=1)
print(f'Test loss {results.loss:.5}, Test accuracy {results.accuracy:.2%}')

Other models in the gallery are the same.

Using Other Backend

>>> import graphgallery
>>> graphgallery.backend()
TensorFlow 2.1.2 Backend

>>> graphgallery.set_backend("pytorch")
PyTorch 1.6.0+cu101 Backend

# DGL PyTorch backend
>>> graphgallery.set_backend("dgl")

# 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!

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.7.2.tar.gz (136.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.7.2-py3-none-any.whl (276.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: graphgallery-0.7.2.tar.gz
  • Upload date:
  • Size: 136.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.6.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.3

File hashes

Hashes for graphgallery-0.7.2.tar.gz
Algorithm Hash digest
SHA256 6e287f9f04bcd76e2c5539331d0d16aa9c3355f445bdad469aefaf077110b787
MD5 164fd25258845c268a4b32c382d2e09b
BLAKE2b-256 510f9aa0fecef94b7cfb3c9cfb09fd05d9e7d25307693bf6634a97f6662b14f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: graphgallery-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 276.6 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.6.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.3

File hashes

Hashes for graphgallery-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 557814d2fac734ee047e23d72e9d4c777c57d9ca41a85266a2569ef09eec15a5
MD5 88986b288b78a799e27b78e519564877
BLAKE2b-256 39a8877cd30b08606938104edcb1af83e09f07e4b5266e0bbb0207777e40b8a7

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.0

2 files

This release

0.7.2 This release

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

0.1.4

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