Skip to main content

Graph Neural Network library for PyTorch

Project description

ptgnn: A PyTorch GNN Library PyPI

This is a library containing pyTorch code for creating graph neural network (GNN) models. The library provides some sample implementations.

If you are interested in using this library, please read about its architecture and how to define GNN models or follow this tutorial.

Note that ptgnn takes care of defining the whole pipeline, including data wrangling tasks, such as data loading and tensorization. It also defines PyTorch nn.Modules for the neural network operations. These are independent of the AbstractNeuralModels and can be used as all other PyTorch's nn.Modules, if one wishes to do so.

The library is mainly engineered to be fast for sparse graphs. For example, for the Graph2Class task (discussed below) on a V100 with the default hyperparameters and architecture ptgnn can process about 82 graphs/sec (209k nodes/sec and 1,129k edges/sec) during training and about 200 graph/sec (470k nodes/sec and 2,527k edges/sec) during testing.

Implemented Tasks

All task implementations can be found in the ptgnn.implementations package. Detailed instructions on the data and the training steps can be found here. We welcome external contributions. The following GNN-based tasks are implemented:

The tutorial gives a step-by-step example for coding the Graph2Class model.

Installation

This code was tested with PyTorch 1.4 and depends on pytorch-scatter. Please install the appropriate versions of these libraries based on your CUDA setup following their instructions. (Note that the pytorch-scatter binaries built for CUDA 10.1 also work for CUDA 10.2).

  1. To install PyTorch 1.4, use the up-to-date command from PyTorch Get Started, selecting the appropriate options, e.g. for Linux, pip, and CUDA 10.1 it's currently:

    pip install torch torchvision
    
  2. To install pytorch-scatter, follow the instructions from the GitHub repo, choosing the appropriate CUDA option, e.g., for CUDA 10.1:

    pip install torch-scatter==2.0.4+cu101 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
    
  3. To install pt-gnn as a package, including all other dependencies:

    pip install -e .
    

To check that installation was successful and run the unit tests:

python setup.py test

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Developing ptgnn

Run Tests Code style: black

To contribute to this library, first follow the next steps:

  • Install the requirements.
  • Install the pre-commit hooks:
    • Run pip3 install pre-commit
    • Install the hooks pre-commit install
Conda Instructions

If you are using conda, then download the correct torch-scatter wheel. If using torch==1.5.0 and Python 3.7, you can use the environment.yml included in the repo, with the following steps:

$ conda env create -f environment.yml
$ conda activate ptgnn-env
$ pip install torch_scatter-2.0.4+cu102-cp37-cp37m-linux_x86_64.whl
$ pip install -e .
$ python setup.py test
$ pip install pre-commit
$ pre-commit install

Project details


Download files

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

Source Distribution

ptgnn-0.7.7.tar.gz (65.5 kB view details)

Uploaded Source

Built Distribution

ptgnn-0.7.7-py3-none-any.whl (70.2 kB view details)

Uploaded Python 3

File details

Details for the file ptgnn-0.7.7.tar.gz.

File metadata

  • Download URL: ptgnn-0.7.7.tar.gz
  • Upload date:
  • Size: 65.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for ptgnn-0.7.7.tar.gz
Algorithm Hash digest
SHA256 65cfaef3ff0e3481bc906f52da3b88f1d43bd1b9f58b0bce4511242ca555e067
MD5 7a020ae867b085de59eb7177b3353a18
BLAKE2b-256 d9e7be9d3a60496a71afc1a80742bca2e4f9c9d7f78d6a171a718448bf1624b7

See more details on using hashes here.

File details

Details for the file ptgnn-0.7.7-py3-none-any.whl.

File metadata

  • Download URL: ptgnn-0.7.7-py3-none-any.whl
  • Upload date:
  • Size: 70.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for ptgnn-0.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7ae982ad15275dc091177af0af161a42577d22abcfbd1e7a12d8ce2f6446689b
MD5 902aab2a1d2225e5aedee9bd906dcb14
BLAKE2b-256 4f534a23da4784a43030b0863697c5a1c7928fcaf4a0962c57b66a199c9fafe9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page