pytorch_geometric

Geometric Deep Learning Extension Library for PyTorch

Github星跟蹤圖


PyPI Version
Build Status
Docs Status
Code Coverage
Contributing

Documentation, Paper, External Resources

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., cpu, cu92, cu100, cu101, -------------, -------, --------, ---------, ---------, Linux, ✅, ✅, ✅, ✅, Windows, ✅, ❌, ❌, ✅, macOS, ✅, To install the binaries, first ensure that PyTorch 1.4.0 is installed, e.g.:

$ python -c "import torch; print(torch.__version__)"
>>> 1.4.0

Then run

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

where ${CUDA} should be replaced by either cpu, cu92, cu100 or cu101 depending on your PyTorch installation.

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

主要指標

概覽
名稱與所有者pyg-team/pytorch_geometric
主編程語言Python
編程語言Python (語言數: 4)
平台
許可證MIT License
所有者活动
創建於2017-10-06 16:03:03
推送於2025-05-20 19:26:27
最后一次提交2025-05-21 01:08:15
發布數42
最新版本名稱2.6.1 (發布於 )
第一版名稱0.1.1 (發布於 )
用户参与
星數22.4k
關注者數254
派生數3.8k
提交數7.8k
已啟用問題?
問題數3664
打開的問題數952
拉請求數2938
打開的拉請求數239
關閉的拉請求數312
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?