Github url

pytorch_geometric

by rusty1s

Geometric Deep Learning Extension Library for PyTorch

8.5K Stars 1.4K Forks Last release: 3 days ago (1.6.1) MIT License 3.7K Commits 21 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


PyPI VersionBuild StatusDocs StatusCode CoverageContributing

Documentation | Paper | External Resources | OGB Examples

PyTorch Geometric (PyG) is a geometric deep learning extension library for PyTorch.

It consists of various methods for deep learning on graphs and other irregular structures, also known as geometric deep learning, from a variety of published papers. In addition, it consists of an easy-to-use mini-batch loader for many small and single giant graphs, multi gpu-support, a large number of common benchmark datasets (based on simple interfaces to create your own), and helpful transforms, both for learning on arbitrary graphs as well as on 3D meshes or point clouds.


PyTorch Geometric makes implementing Graph Neural Networks a breeze (see here for the accompanying tutorial). For example, this is all it takes to implement the edge convolutional layer:

import torch from torch.nn import Sequential as Seq, Linear as Lin, ReLU from torch\_geometric.nn import MessagePassing class EdgeConv(MessagePassing): def \_\_init\_\_(self, F\_in, F\_out): super(EdgeConv, self).\_\_init\_\_(aggr='max') # "Max" aggregation. self.mlp = Seq(Lin(2 \* F\_in, F\_out), ReLU(), Lin(F\_out, F\_out)) def forward(self, x, edge\_index): # x has shape [N, F\_in] # edge\_index has shape [2, E] return self.propagate(edge\_index, x=x) # shape [N, F\_out] def message(self, x\_i, x\_j): # x\_i has shape [E, F\_in] # x\_j has shape [E, F\_in] edge\_features = torch.cat([x\_i, x\_j - x\_i], dim=1) # shape [E, 2 \* F\_in] return self.mlp(edge\_features) # shape [E, F\_out]

In detail, the following methods are currently implemented:


Head over to our documentation to find out more about installation, data handling, creation of datasets and a full list of implemented methods, transforms, and datasets. For a quick start, check out our examples in the

examples/

directory.

If you notice anything unexpected, please open an issue and let us know. If you are missing a specific method, feel free to open a feature request. We are motivated to constantly make PyTorch Geometric even better.

Installation

We provide pip wheels for all major OS/PyTorch/CUDA combinations, see here.

PyTorch 1.6.0

To install the binaries for PyTorch 1.6.0, simply run

$ pip install torch-scatter==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.6.0.html $ pip install torch-sparse==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.6.0.html $ pip install torch-cluster==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.6.0.html $ pip install torch-spline-conv==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.6.0.html $ pip install torch-geometric

where

${CUDA}

should be replaced by either

cpu

,

cu92

,

cu101

or

cu102

depending on your PyTorch installation.

| |

cpu

|

cu92

|

cu101

|

cu102

| |-------------|-------|--------|---------|---------| | Linux | ✅ | ✅ | ✅ | ✅ | | Windows | ✅ | ❌ | ✅ | ✅ | | macOS | ✅ | | | |

PyTorch 1.5.0/1.5.1

To install the binaries for PyTorch 1.5.0/1.5.1, simply run

$ pip install torch-scatter==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.5.0.html $ pip install torch-sparse==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.5.0.html $ pip install torch-cluster==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.5.0.html $ pip install torch-spline-conv==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.5.0.html $ pip install torch-geometric

where

${CUDA}

should be replaced by either

cpu

,

cu92

,

cu101

or

cu102

depending on your PyTorch installation.

| |

cpu

|

cu92

|

cu101

|

cu102

| |-------------|-------|--------|---------|---------| | Linux | ✅ | ✅ | ✅ | ✅ | | Windows | ✅ | ❌ | ✅ | ✅ | | macOS | ✅ | | | |

PyTorch 1.4.0

To install the binaries for PyTorch 1.4.0, simply run

$ pip install torch-scatter==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html $ pip install torch-sparse==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html $ pip install torch-cluster==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html $ pip install torch-spline-conv==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html $ pip install torch-geometric

where

${CUDA}

should be replaced by either

cpu

,

cu92

,

cu100

or

cu101

depending on your PyTorch installation.

| |

cpu

|

cu92

|

cu100

|

cu101

| |-------------|-------|--------|---------|---------| | Linux | ✅ | ✅ | ✅ | ✅ | | Windows | ✅ | ❌ | ❌ | ✅ | | macOS | ✅ | | | |

Running examples

$ cd examples $ python gcn.py

Cite

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

@inproceedings{Fey/Lenssen/2019, title={Fast Graph Representation Learning with {PyTorch Geometric}}, author={Fey, Matthias and Lenssen, Jan E.}, booktitle={ICLR Workshop on Representation Learning on Graphs and Manifolds}, year={2019}, }

Feel free to email us if you wish your work to be listed in the external resources.

Running tests

$ python setup.py test

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.