[![PyPI 版本][pypi-image]][pypi-url]
[![PyPI 下载量][pypi-download-image]][pypi-download-url]
[![Slack][slack-image]][slack-url]
[![贡献指南][contributing-image]][contributing-url]
**[文档](https://pytorch-geometric.readthedocs.io)** |
**[PyG 1.0 论文](https://arxiv.org/abs/1903.02428)** |
**[PyG 2.0 论文](https://arxiv.org/abs/2507.16991)** |
**[Colab 笔记本](https://pytorch-geometric.readthedocs.io/en/latest/get_started/colabs.html)** |
**[外部资源](https://pytorch-geometric.readthedocs.io/en/latest/external/resources.html)** |
**[OGB 示例](https://github.com/snap-stanford/ogb/tree/master/examples)**
PyG (PyTorch Geometric) 是一个基于 PyTorch 构建的库,用于轻松编写和训练图神经网络(GNN),适用于各种与结构化数据相关的应用。
它汇集了来自多篇已发表论文的方法,涵盖图及其他非规则结构上的深度学习(即几何深度学习)。
此外,它还提供了易于使用的 mini-batch 加载器(可用于处理大量小图和单个巨型图)、多 GPU 支持、torch.compile 支持、DataPipe 支持、大量常用基准数据集(提供简单接口以便创建自己的数据集),以及实用的数据变换工具,既适用于任意图上的学习,也适用于 3D 网格或点云。
[点击此处加入我们的 Slack 社区!][slack-url]
库亮点
无论你是机器学习研究者,还是首次使用机器学习工具包的用户,以下理由都值得你尝试用 PyG 进行图结构数据的机器学习。
- 易用且统一的 API:
只需 10 到 20 行代码即可开始训练 GNN 模型(参见下一节的快速上手)。
PyG 堪称 PyTorch-on-the-rocks:它采用以张量为中心的 API,并保持与原生 PyTorch 相近的设计原则。
如果你已熟悉 PyTorch,使用 PyG 将会非常轻松。
- 全面且维护良好的 GNN 模型:
大多数最先进的图神经网络架构已由库开发者或研究论文作者实现,可直接应用。
- 出色的灵活性:
现有 PyG 模型可以方便地扩展,以支撑你自己的 GNN 研究。
得益于易用的消息传递 API 以及丰富的算子与工具函数,修改现有模型或创建新架构都非常简单。
- 大规模真实场景 GNN 模型:
我们关注 GNN 在具有挑战性的真实场景中的应用需求,并支持在多种类型的图上学习,包括但不限于:可扩展到数百万节点图的可扩展 GNN;用于随时间进行节点预测的动态 GNN;具有多种节点类型和边类型的异构图 GNN。
新用户快速上手
在本快速上手部分,我们将展示如何仅用几行代码轻松创建并训练一个 GNN 模型。
训练你自己的 GNN 模型
作为 PyG 的初次体验,我们实现一个用于引文图中论文分类的 GNN 训练流程。
为此,我们加载 Cora 数据集,并使用预定义的 GCNConv 创建一个简单的两层 GCN 模型:
import torch
from torch import Tensor
from torch_geometric.nn import GCNConv
from torch_geometric.datasets import Planetoid
dataset = Planetoid(root='.', name='Cora')
class GCN(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super().__init__()
self.conv1 = GCNConv(in_channels, hidden_channels)
self.conv2 = GCNConv(hidden_channels, out_channels)
def forward(self, x: Tensor, edge_index: Tensor) -> Tensor:
# x: 形状为 [num_nodes, in_channels] 的节点特征矩阵
# edge_index: 形状为 [2, num_edges] 的图连接矩阵
x = self.conv1(x, edge_index).relu()
x = self.conv2(x, edge_index)
return x
model = GCN(dataset.num_features, 16, dataset.num_classes)
接下来,我们可以像标准 PyTorch 训练流程那样,在训练循环中优化模型。
import torch.nn.functional as F
data = dataset[0]
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
for epoch in range(200):
pred = model(data.x, data.edge_index)
loss = F.cross_entropy(pred[data.train_mask], data.y[data.train_mask])
# 反向传播
optimizer.zero_grad()
loss.backward()
optimizer.step()
有关评估最终模型性能的更多信息,请参见对应的示例。
创建你自己的 GNN 层
除了轻松应用现有 GNN 之外,PyG 还让实现自定义图神经网络变得简单(配套教程见此处)。
例如,实现 Wang 等人 提出的边卷积层只需以下代码:
$$x_i^{\prime} ~ = ~ \max_{j \in \mathcal{N}(i)} ~ \textrm{MLP}_{\theta} \left( [ ~ x_i, ~ x_j - x_i ~ ] \right)$$
import torch
from torch import Tensor
from torch.nn import Sequential, Linear, ReLU
from torch_geometric.nn import MessagePassing
class EdgeConv(MessagePassing):
def __init__(self, in_channels, out_channels):
super().__init__(aggr="max") # "Max" 聚合。
self.mlp = Sequential(
Linear(2 * in_channels, out_channels),
ReLU(),
Linear(out_channels, out_channels),
)
def forward(self, x: Tensor, edge_index: Tensor) -> Tensor:
# x: 形状为 [num_nodes, in_channels] 的节点特征矩阵
# edge_index: 形状为 [2, num_edges] 的图连接矩阵
return self.propagate(edge_index, x=x) # 形状为 [num_nodes, out_channels]
def message(self, x_j: Tensor, x_i: Tensor) -> Tensor:
# x_j: 形状为 [num_edges, in_channels] 的源节点特征
# x_i: 形状为 [num_edges, in_channels] 的目标节点特征
edge_features = torch.cat([x_i, x_j - x_i], dim=-1)
return self.mlp(edge_features) # 形状为 [num_edges, out_channels]
架构概览
PyG 提供了一个多层框架,使用户既能在低层也能在高层构建图神经网络解决方案。
它由以下组件构成:
- PyG 引擎 依托强大的 PyTorch 深度学习框架,完整支持
torch.compile 和 TorchScript,并加入了用于稀疏数据运算的高效 CPU/CUDA 库,例如 pyg-lib。
- PyG 存储 负责数据处理、变换和加载流程。它能够处理并加工大规模图数据集,并为异构图提供有效解决方案。它还提供了多种采样方案,使得在大规模图上训练 GNN 成为可能。
- PyG 算子 汇集了实现图神经网络所需的核心功能。PyG 支持重要的 GNN 构建模块,这些模块可以组合并应用到 GNN 模型的各个部分,确保 GNN 设计具有充分的灵活性。
- 最后,PyG 提供了丰富的 GNN 模型集,以及展示 GNN 模型在标准图基准上表现的示例。得益于其灵活性,用户可以轻松构建和修改自定义 GNN 模型以满足特定需求。
已实现的 GNN 模型
我们按类别列出当前支持的 PyG 模型、层和算子:
GNN 层:
所有图神经网络层都通过 nn.MessagePassing 接口实现。
GNN 层定义了如何执行消息传递,即通过设计不同的消息、聚合和更新函数(定义见此处)。
这些 GNN 层可以堆叠在一起,构建图神经网络模型。
展开查看所有已实现的 GNN 层……
- **[GCN2Conv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GCN2Conv.html)**,来自 Chen *等人*:[Simple and Deep Graph Convolutional Networks](https://arxiv.org/abs/2007.02133)(ICML 2020)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/gcn2_cora.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/gcn2_ppi.py)\]
- **[SplineConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.SplineConv.html)**,来自 Fey *等人*:[SplineCNN: Fast Geometric Deep Learning with Continuous B-Spline Kernels](https://arxiv.org/abs/1711.08920)(CVPR 2018)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/cora.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/faust.py)\]
- **[NNConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.NNConv.html)**,来自 Gilmer *等人*:[Neural Message Passing for Quantum Chemistry](https://arxiv.org/abs/1704.01212)(ICML 2017)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/qm9_nn_conv.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/mnist_nn_conv.py)\]
- **[CGConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.CGConv.html)**,来自 Xie 和 Grossman:[Crystal Graph Convolutional Neural Networks for an Accurate and Interpretable Prediction of Material Properties](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.120.145301)(Physical Review Letters 120, 2018)
- **[ECConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.ECConv.html)**,来自 Simonovsky 和 Komodakis:[Edge-Conditioned Convolution on Graphs](https://arxiv.org/abs/1704.02901)(CVPR 2017)
- **[EGConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.EGConv.html)**,来自 Tailor *等人*:[Adaptive Filters and Aggregator Fusion for Efficient Graph Convolutions](https://arxiv.org/abs/2104.01481)(GNNSys 2021)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/egc.py)\]
- **[GATv2Conv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GATv2Conv.html)**,来自 Brody *等人*:[How Attentive are Graph Attention Networks?](https://arxiv.org/abs/2105.14491)(ICLR 2022)
- **[TransformerConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.TransformerConv.html)**,来自 Shi *等人*:[Masked Label Prediction: Unified Message Passing Model for Semi-Supervised Classification](https://arxiv.org/abs/2009.03509)(CoRR 2020)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/unimp_arxiv.py)\]
- **[SAGEConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.SAGEConv.html)**,来自 Hamilton *等人*:[Inductive Representation Learning on Large Graphs](https://arxiv.org/abs/1706.02216)(NIPS 2017)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/reddit.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/ogbn_train.py)、[**示例3**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/graph_sage_unsup.py)、[**示例4**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/graph_sage_unsup_ppi.py)\]
- **[GraphConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GraphConv.html)**,来自(例如)Morris *等人*:[Weisfeiler and Leman Go Neural: Higher-order Graph Neural Networks](https://arxiv.org/abs/1810.02244)(AAAI 2019)
- **[GatedGraphConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GatedGraphConv.html)**,来自 Li *等人*:[Gated Graph Sequence Neural Networks](https://arxiv.org/abs/1511.05493)(ICLR 2016)
- **[ResGatedGraphConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.ResGatedGraphConv.html)**,来自 Bresson 和 Laurent:[Residual Gated Graph ConvNets](https://arxiv.org/abs/1711.07553)(CoRR 2017)
- **[GINConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GINConv.html)**,来自 Xu *等人*:[How Powerful are Graph Neural Networks?](https://arxiv.org/abs/1810.00826)(ICLR 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/mutag_gin.py)\]
- **[GINEConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GINEConv.html)**,来自 Hu *等人*:[Strategies for Pre-training Graph Neural Networks](https://arxiv.org/abs/1905.12265)(ICLR 2020)
- **[ARMAConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.ARMAConv.html)**,来自 Bianchi *等人*:[Graph Neural Networks with Convolutional ARMA Filters](https://arxiv.org/abs/1901.01343)(CoRR 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/arma.py)\]
- **[SGConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.SGConv.html)**,来自 Wu *等人*:[Simplifying Graph Convolutional Networks](https://arxiv.org/abs/1902.07153)(CoRR 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/sgc.py)\]
- **[APPNP](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.APPNP.html)**,来自 Klicpera *等人*:[Predict then Propagate: Graph Neural Networks meet Personalized PageRank](https://arxiv.org/abs/1810.05997)(ICLR 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/benchmark/citation/appnp.py)\]
- **[MFConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.MFConv.html)**,来自 Duvenaud *等人*:[Convolutional Networks on Graphs for Learning Molecular Fingerprints](https://arxiv.org/abs/1509.09292)(NIPS 2015)
- **[AGNNConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.AGNNConv.html)**,来自 Thekumparampil *等人*:[Attention-based Graph Neural Network for Semi-Supervised Learning](https://arxiv.org/abs/1803.03735)(CoRR 2017)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/agnn.py)\]
- **[TAGConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.TAGConv.html)**,来自 Du *等人*:[Topology Adaptive Graph Convolutional Networks](https://arxiv.org/abs/1710.10370)(CoRR 2017)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/tagcn.py)\]
- **[PNAConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.PNAConv.html)**,来自 Corso *等人*:[Principal Neighbourhood Aggregation for Graph Nets](https://arxiv.org/abs/2004.05718)(CoRR 2020)\[**[示例](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/pna.py)**\]
- **[FAConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.FAConv.html)**,来自 Bo *等人*:[Beyond Low-Frequency Information in Graph Convolutional Networks](https://arxiv.org/abs/2101.00797)(AAAI 2021)
- **[PDNConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.nn.conv.PDNConv.html)**,来自 Rozemberczki *等人*:[Pathfinder Discovery Networks for Neural Message Passing](https://arxiv.org/abs/2010.12878)(WWW 2021)
- **[RGCNConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.RGCNConv.html)**,来自 Schlichtkrull *等人*:[Modeling Relational Data with Graph Convolutional Networks](https://arxiv.org/abs/1703.06103)(ESWC 2018)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/rgcn.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/rgcn_link_pred.py)\]
- **[RGATConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.RGATConv.html)**,来自 Busbridge *等人*:[Relational Graph Attention Networks](https://arxiv.org/abs/1904.05811)(CoRR 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/rgat.py)\]
- **[FiLMConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.FiLMConv.html)**,来自 Brockschmidt:[GNN-FiLM: Graph Neural Networks with Feature-wise Linear Modulation](https://arxiv.org/abs/1906.12192)(ICML 2020)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/film.py)\]
- **[SignedConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.SignedConv.html)**,来自 Derr *等人*:[Signed Graph Convolutional Network](https://arxiv.org/abs/1808.06354)(ICDM 2018)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/signed_gcn.py)\]
- **[DNAConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.DNAConv.html)**,来自 Fey:[Just Jump: Dynamic Neighborhood Aggregation in Graph Neural Networks](https://arxiv.org/abs/1904.04849)(ICLR-W 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/dna.py)\]
- **[PANConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.PANConv.html)**,来自 Ma *等人*:[Path Integral Based Convolution and Pooling for Graph Neural Networks](https://arxiv.org/abs/2006.16811)(NeurIPS 2020)
- **[PointNetConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.PointNetConv.html)**(包括用于上采样的 **[迭代最远点采样](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.pool.fps.html)**、基于 **[最近邻](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.pool.knn_graph.html)** 或 **[最大距离](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.pool.radius_graph.html)** 的动态图生成,以及 **[k-NN 插值](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.unpool.knn_interpolate.html)**),来自 Qi *等人*:[PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation](https://arxiv.org/abs/1612.00593)(CVPR 2017)和 [PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space](https://arxiv.org/abs/1706.02413)(NIPS 2017)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/pointnet2_classification.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/pointnet2_segmentation.py)\]
- **[EdgeConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.EdgeConv.html)**,来自 Wang *等人*:[Dynamic Graph CNN for Learning on Point Clouds](https://arxiv.org/abs/1801.07829)(CoRR, 2018)\[[**示例1**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/dgcnn_classification.py)、[**示例2**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/dgcnn_segmentation.py)\]
- **[XConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.XConv.html)**,来自 Li *等人*:[PointCNN: Convolution On X-Transformed Points](https://arxiv.org/abs/1801.07791)(NeurIPS 2018)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/benchmark/points/point_cnn.py)\]
- **[PPFConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.PPFConv.html)**,来自 Deng *等人*:[PPFNet: Global Context Aware Local Features for Robust 3D Point Matching](https://arxiv.org/abs/1802.02669)(CVPR 2018)
- **[GMMConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GMMConv.html)**,来自 Monti *等人*:[Geometric Deep Learning on Graphs and Manifolds using Mixture Model CNNs](https://arxiv.org/abs/1611.08402)(CVPR 2017)
- **[FeaStConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.FeaStConv.html)**,来自 Verma *等人*:[FeaStNet: Feature-Steered Graph Convolutions for 3D Shape Analysis](https://arxiv.org/abs/1706.05206)(CVPR 2018)
- **[PointTransformerConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.PointTransformerConv.html)**,来自 Zhao *等人*:[Point Transformer](https://arxiv.org/abs/2012.09164)(2020)
- **[HypergraphConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.HypergraphConv.html)**,来自 Bai *等人*:[Hypergraph Convolution and Hypergraph Attention](https://arxiv.org/abs/1901.08150)(CoRR 2019)
- **[GravNetConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GravNetConv.html)**,来自 Qasim *等人*:[Learning Representations of Irregular Particle-detector Geometry with Distance-weighted Graph Networks](https://arxiv.org/abs/1902.07987)(European Physics Journal C, 2019)
- **[SuperGAT](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.SuperGATConv.html)**,来自 Kim 和 Oh:[How To Find Your Friendly Neighborhood: Graph Attention Design With Self-Supervision](https://openreview.net/forum?id=Wi5KUNlqWty)(ICLR 2021)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/super_gat.py)\]
- **[HGTConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.HGTConv.html)**,来自 Hu *等人*:[Heterogeneous Graph Transformer](https://arxiv.org/abs/2003.01332)(WWW 2020)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/hetero/hgt_dblp.py)\]
- **[HEATConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.HEATonv.html)**,来自 Mo *等人*:[Heterogeneous Edge-Enhanced Graph Attention Network For Multi-Agent Trajectory Prediction](https://arxiv.org/abs/2106.07161)(CoRR 2021)
- **[SSGConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.SSGConv.html)**,来自 Zhu *等人*:[Simple Spectral Graph Convolution](https://openreview.net/forum?id=CYO5T-YjWZV)(ICLR 2021)
- **[FusedGATConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.FusedGATConv.html)**,来自 Zhang *等人*:[Understanding GNN Computational Graph: A Coordinated Computation, IO, and Memory Perspective](https://proceedings.mlsys.org/paper/2022/file/9a1158154dfa42caddbd0694a4e9bdc8-Paper.pdf)(MLSys 2022)
- **[GPSConv](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.conv.GPSConv.html)**,来自 Rampášek *等人*:[Recipe for a General, Powerful, Scalable Graph Transformer](https://arxiv.org/abs/2205.12454)(NeurIPS 2022)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/graph_gps.py)\]
池化层:
图池化层将图中(或子图中)的一组节点的向量表示合并为单个向量表示,以汇总其节点属性。
它通常应用于图级任务,这类任务需要将节点特征组合成单一的图表示。
展开查看所有已实现的池化层……
- **[注意力聚合](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.aggr.AttentionalAggregation.html)**,来自 Li *等人*:[Graph Matching Networks for Learning the Similarity of Graph Structured Objects](https://arxiv.org/abs/1904.12787)(ICML 2019)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/benchmark/kernel/global_attention.py)\]
- **[Set2Set](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.aggr.Set2Set.html)**,来自 Vinyals *等人*:[Order Matters: Sequence to Sequence for Sets](https://arxiv.org/abs/1511.06391)(ICLR 2016)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/benchmark/kernel/set2set.py)\]
- **[排序聚合](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.aggr.SortAggregation.html)**,来自 Zhang *等人*:[An End-to-End Deep Learning Architecture for Graph Classification](https://www.cse.wustl.edu/~muhan/papers/AAAI_2018_DGCNN.pdf)(AAAI 2018)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/benchmark/kernel/sort_pool.py)\]
- **[MinCut 池化](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.dense.dense_mincut_pool.html)**,来自 Bianchi *等人*:[Spectral Clustering with Graph Neural Networks for Graph Pooling](https://arxiv.org/abs/1907.00481)(ICML 2020)\[[**示例**](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/proteins_mincut_pool.py)\]
- **[DMoN 池化](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.dense.DMoNPooling.html)**,来自 Tsitsulin *等人*