Documentation  External Resources  Datasets
PyTorch Geometric Temporal is a temporal (dynamic) extension library for PyTorch Geometric.
The library consists of various dynamic and temporal geometric deep learning, embedding, and spatiotemporal regression methods from a variety of published research papers. Moreover, it comes with an easytouse dataset loader, traintest splitter and temporal snaphot iterator for dynamic and temporal graphs. The framework naturally provides GPU support. It also comes with a number of benchmark datasets from the epidemological forecasting, sharing economy, energy production and web traffic management domains. Finally, you can also create your own datasets.
The package interfaces well with Pytorch Lightning which allows training on CPUs, single and multiple GPUs outofthebox. Take a look at this introductory example of using PyTorch Geometric Temporal with Pytorch Lighning.
We also provide detailed examples for each of the recurrent models.
Case Study Tutorials
We provide indepth case study tutorials in the Documentation, each covers an aspect of PyTorch Geometric Temporal’s functionality.
Incremental Training: Epidemiological Forecasting Case Study
Cumulative Training: Web Traffic Management Case Study
Citing
If you find PyTorch Geometric Temporal and the new datasets useful in your research, please consider adding the following citation:
@misc{rozemberczki2021pytorch,
author = {Benedek Rozemberczki and Paul Scherer and Yixuan He and George Panagopoulos and Alexander Riedel and Maria Astefanoaei and Oliver Kiss and Ferenc Beres and Guzman Lopez and Nicolas Collignon and Rik Sarkar},
title = {{PyTorch Geometric Temporal: Spatiotemporal Signal Processing with Neural Machine Learning Models}},
year = {2021},
eprint = {arXiv:2104.07788},
}
A simple example
PyTorch Geometric Temporal makes implementing Dynamic and Temporal Graph Neural Networks quite easy  see the accompanying tutorial. For example, this is all it takes to implement a recurrent graph convolutional network with two consecutive graph convolutional GRU cells and a linear layer:
import torch
import torch.nn.functional as F
from torch_geometric_temporal.nn.recurrent import GConvGRU
class RecurrentGCN(torch.nn.Module):
def __init__(self, node_features, num_classes):
super(RecurrentGCN, self).__init__()
self.recurrent_1 = GConvGRU(node_features, 32, 5)
self.recurrent_2 = GConvGRU(32, 16, 5)
self.linear = torch.nn.Linear(16, num_classes)
def forward(self, x, edge_index, edge_weight):
x = self.recurrent_1(x, edge_index, edge_weight)
x = F.relu(x)
x = F.dropout(x, training=self.training)
x = self.recurrent_2(x, edge_index, edge_weight)
x = F.relu(x)
x = F.dropout(x, training=self.training)
x = self.linear(x)
return F.log_softmax(x, dim=1)
Methods Included
In detail, the following temporal graph neural networks were implemented.
Recurrent Graph Convolutions

DCRNN from Li et al.: Diffusion Convolutional Recurrent Neural Network: DataDriven Traffic Forecasting (ICLR 2018)

GConvGRU from Seo et al.: Structured Sequence Modeling with Graph Convolutional Recurrent Networks (ICONIP 2018)

GConvLSTM from Seo et al.: Structured Sequence Modeling with Graph Convolutional Recurrent Networks (ICONIP 2018)

GCLSTM from Chen et al.: GCLSTM: Graph Convolution Embedded LSTM for Dynamic Link Prediction (CoRR 2018)

LRGCN from Li et al.: Predicting Path Failure In TimeEvolving Graphs (KDD 2019)

DyGrEncoder from Taheri et al.: Learning to Represent the Evolution of Dynamic Graphs with Recurrent Models

EvolveGCNH from Pareja et al.: EvolveGCN: Evolving Graph Convolutional Networks for Dynamic Graphs

EvolveGCNO from Pareja et al.: EvolveGCN: Evolving Graph Convolutional Networks for Dynamic Graphs

TGCN from Zhao et al.: TGCN: A Temporal Graph Convolutional Network for Traffic Prediction

A3TGCN from Zhu et al.: A3TGCN: Attention Temporal Graph Convolutional Network for Traffic Forecasting

AGCRN from Bai et al.: Adaptive Graph Convolutional Recurrent Network for Traffic Forecasting (NeurIPS 2020)

MPNN LSTM from Panagopoulos et al.: Transfer Graph Neural Networks for Pandemic Forecasting (AAAI 2021)
Temporal Graph Convolutions

STGCN from Yu et al.: SpatioTemporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting (IJCAI 2018)

ASTGCN from Guo et al.: Attention Based SpatialTemporal Graph Convolutional Networks for Traffic Flow Forecasting (AAAI 2019)

MSTGCN from Guo et al.: Attention Based SpatialTemporal Graph Convolutional Networks for Traffic Flow Forecasting (AAAI 2019)

GMAN from Zheng et al.: GMAN: A Graph MultiAttention Network for Traffic Prediction (AAAI 2020)

MTGNN from Wu et al.: Connecting the Dots: Multivariate Time Series Forecasting with Graph Neural Networks (KDD 2020)

2SAGCN from Shi et al.: TwoStream Adaptive Graph Convolutional Networks for SkeletonBased Action Recognition (CVPR 2019)
Auxiliary Graph Convolutions

TemporalConv from Yu et al.: SpatioTemporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting (IJCAI 2018)

DConv from Li et al.: Diffusion Convolutional Recurrent Neural Network: DataDriven Traffic Forecasting (ICLR 2018)

ChebConvAttention from Guo et al.: Attention Based SpatialTemporal Graph Convolutional Networks for Traffic Flow Forecasting (AAAI 2019)

AVWGCN from Bai et al.: Adaptive Graph Convolutional Recurrent Network for Traffic Forecasting (NeurIPS 2020)
Head over to our documentation to find out more about installation, creation of datasets and a full list of implemented methods and available datasets.
For a quick start, check out the examples in the examples/
directory.
If you notice anything unexpected, please open an issue. If you are missing a specific method, feel free to open a feature request.
Installation
Binaries are provided for Python version <= 3.9.
PyTorch 1.9.0
To install the binaries for PyTorch 1.9.0, simply run
pip install torchscatter f https://pytorchgeometric.com/whl/torch1.9.0+${CUDA}.html
pip install torchsparse f https://pytorchgeometric.com/whl/torch1.9.0+${CUDA}.html
pip install torchcluster f https://pytorchgeometric.com/whl/torch1.9.0+${CUDA}.html
pip install torchsplineconv f https://pytorchgeometric.com/whl/torch1.9.0+${CUDA}.html
pip install torchgeometric
where ${CUDA}
should be replaced by either cpu
, cu102
, or cu111
depending on your PyTorch installation.
cpu 
cu102 
cu111 


Linux  
Windows  
macOS 
PyTorch 1.8.0
To install the binaries for PyTorch 1.8.0, simply run
$ pip install torchscatter f https://pytorchgeometric.com/whl/torch1.8.0+${CUDA}.html
$ pip install torchsparse f https://pytorchgeometric.com/whl/torch1.8.0+${CUDA}.html
$ pip install torchcluster f https://pytorchgeometric.com/whl/torch1.8.0+${CUDA}.html
$ pip install torchsplineconv f https://pytorchgeometric.com/whl/torch1.8.0+${CUDA}.html
$ pip install torchgeometric
$ pip install torchgeometrictemporal
where ${CUDA}
should be replaced by either cpu
, cu101
, cu102
, or cu111
depending on your PyTorch installation.
cpu 
cu101 
cu102 
cu111 


Linux  
Windows  
macOS 
PyTorch 1.7.0
To install the binaries for PyTorch 1.7.0, simply run
$ pip install torchscatter==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.7.0.html
$ pip install torchsparse==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.7.0.html
$ pip install torchcluster==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.7.0.html
$ pip install torchsplineconv==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.7.0.html
$ pip install torchgeometric
$ pip install torchgeometrictemporal
where ${CUDA}
should be replaced by either cpu
, cu92
, cu101
, cu102
or cu110
depending on your PyTorch installation.
cpu 
cu92 
cu101 
cu102 
cu110 


Linux  
Windows  
macOS 
PyTorch 1.6.0
To install the binaries for PyTorch 1.6.0, simply run
$ pip install torchscatter==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.6.0.html
$ pip install torchsparse==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.6.0.html
$ pip install torchcluster==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.6.0.html
$ pip install torchsplineconv==latest+${CUDA} f https://pytorchgeometric.com/whl/torch1.6.0.html
$ pip install torchgeometric
$ pip install torchgeometrictemporal
where ${CUDA}
should be replaced by either cpu
, cu92
, cu101
or cu102
depending on your PyTorch installation.
cpu 
cu92 
cu101 
cu102 


Linux  
Windows  
macOS 
Running tests
$ python setup.py test
License