Skip to main content

TorchRecurrent

PyPI codecov Build Docs !python-versions code style: black arXiv

TorchRecurrent is a PyTorch-compatible collection of recurrent neural network cells and layers from across the research literature. It aims to provide a unified, flexible interface that feels like native PyTorch while exposing more customization options.

Installation

pip install torchrecurrent

or on conda-forge

conda install -c conda-forge torchrecurrent

Features

  • 🔄 30+ recurrent cells (e.g. LSTMCell, GRUCell, and many specialized variants).
  • 🏗️ 30+ recurrent layers (e.g. LSTM, GRU, and counterparts for each cell).
  • 🧩 Unified API — all cells/layers follow the PyTorch interface but add extra options for initialization and customization.
  • 📚 Comprehensive documentation including API reference and a catalog of published models.

👉 Full model catalog: torchrecurrent Models

Quick Example

import torch
from torchrecurrent import MGU #minimal gated unit

# sequence: (time_steps, batch, input_size)
inp = torch.randn(5, 3, 10)

# initialize a MGU with hidden_size=20
rnn = MGU(input_size=10, hidden_size=20, num_layers=3)

# forward pass
out, hidden = rnn(inp)

print(out.shape)  # (time_steps, batch, hidden_size)

Citation

If you use TorchRecurrent in your work, please consider citing

@misc{martinuzzi2025unified,
  doi = {10.48550/ARXIV.2510.21252},
  url = {https://arxiv.org/abs/2510.21252},
  author = {Martinuzzi,  Francesco},
  keywords = {Machine Learning (cs.LG),  Software Engineering (cs.SE),  FOS: Computer and information sciences,  FOS: Computer and information sciences},
  title = {Unified Implementations of Recurrent Neural Networks in Multiple Deep Learning Frameworks},
  publisher = {arXiv},
  year = {2025},
  copyright = {Creative Commons Attribution 4.0 International}
}

See also

LuxRecurrentLayers.jl: Provides recurrent layers for Lux.jl in Julia.

RecurrentLayers.jl: Provides recurrent layers for Flux.jl in Julia.

ReservoirComputing.jl: Reservoir computing utilities for scientific machine learning. Essentially gradient free trained recurrent neural networks.

License

This project’s own code is distributed under the MIT License (see LICENSE). The primary intent of this software is academic research.

Third-party Attributions

Some cells are re-implementations of published methods that carry their own licenses:

Please consult each of those licenses for your obligations when using this code in commercial or closed-source settings.

⚠️ Disclaimer: TorchRecurrent is an independent project and is not affiliated with the PyTorch project or Meta AI. The name reflects compatibility with PyTorch, not any official endorsement.

Download files

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

Source Distribution

torchrecurrent-0.2.1.tar.gz (48.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchrecurrent-0.2.1-py3-none-any.whl (104.4 kB view details)

Uploaded Python 3

File details

Details for the file torchrecurrent-0.2.1.tar.gz.

File metadata

  • Download URL: torchrecurrent-0.2.1.tar.gz
  • Upload date:
  • Size: 48.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for torchrecurrent-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d4fd7ba3bd3072a05ccd8ec3551e6fb383886ba75676d1d36adc69640cea4280
MD5 ccf7e15d169ef3a635470a9f709dbc09
BLAKE2b-256 e3eb17217675328a7eaeefec47847f3f3df8f5de9300ee807d7d1ec2032b5712

See more details on using hashes here.

File details

Details for the file torchrecurrent-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: torchrecurrent-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 104.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for torchrecurrent-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b69a325d31dd6e1ffd49b5f1ad66bdcd05c0eee85e061cfa925f174e5aa6b3c
MD5 38e76f939a102382c0d37b9d98a860f7
BLAKE2b-256 322239da2b129ae0b3bf4ab6b4cb31ce4ce2dccf20412712f88c362b01c54075

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.3

2 files

0.2.2

2 files

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page