Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/cells.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This page documents all custom recurrent cells provided in the `torchrecurrent.c
torchrecurrent.SGUCell
torchrecurrent.SGRNCell
torchrecurrent.STARCell
torchrecurrent.tauGRUCell
torchrecurrent.UGRNNCell
torchrecurrent.UnICORNNCell
torchrecurrent.WMCLSTMCell
1 change: 1 addition & 0 deletions docs/api/layers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This page documents all custom recurrent layers provided in the `torchrecurrent`
torchrecurrent.SGU
torchrecurrent.SGRN
torchrecurrent.STAR
torchrecurrent.tauGRU
torchrecurrent.UGRNN
torchrecurrent.UnICORNN
torchrecurrent.WMCLSTM
8 changes: 8 additions & 0 deletions docs/generated/torchrecurrent.tauGRU.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
torchrecurrent.tauGRU
=====================

.. currentmodule:: torchrecurrent

.. autoclass:: tauGRU
:members:
:show-inheritance:
8 changes: 8 additions & 0 deletions docs/generated/torchrecurrent.tauGRUCell.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
torchrecurrent.tauGRUCell
=========================

.. currentmodule:: torchrecurrent

.. autoclass:: tauGRUCell
:members:
:show-inheritance:
3 changes: 3 additions & 0 deletions docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ references and official implementations where available.
* - :doc:`STAR <generated/torchrecurrent.STAR>`
- `TPAMI 2022 <https://arxiv.org/abs/1911.11033>`__
- `0zgur0/STAckable-Recurrent-network <https://github.com/0zgur0/STAckable-Recurrent-network>`__
* - :doc:`tauGRU <generated/torchrecurrent.tauGRU>`
- `AISTATS 2025 <https://arxiv.org/abs/2212.00228>`__
- –
* - :doc:`UGRNN <generated/torchrecurrent.UGRNN>`
- `ICLR 2017 <https://arxiv.org/abs/1611.09913>`__
- –
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "torchrecurrent"
version = "0.2.2"
version = "0.2.3"
description = "A package for recurrent neural networks in PyTorch"
readme = "README.md"
authors = [
Expand Down
31 changes: 31 additions & 0 deletions tests/test_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
SGUCell,
SGRNCell,
STARCell,
tauGRUCell,
UGRNNCell,
UnICORNNCell,
WMCLSTMCell,
Expand Down Expand Up @@ -74,6 +75,7 @@
(SGUCell, 3, 5, False),
(SGRNCell, 3, 5, False),
(STARCell, 3, 5, False),
(tauGRUCell, 3, 5, False),
(UGRNNCell, 3, 5, False),
(UnICORNNCell, 3, 5, True),
(WMCLSTMCell, 3, 5, True),
Expand Down Expand Up @@ -132,6 +134,35 @@ def test_reslstm_cell_parameter_shapes():
assert cell.weight_ph.shape == (27,)


def test_taugru_cell_parameter_shapes():
cell = tauGRUCell(4, 9)

assert cell.weight_ih.shape == (36, 4)
assert cell.weight_hh.shape == (36, 9)
assert cell.bias_ih.shape == (36,)
assert cell.bias_hh.shape == (36,)


def test_taugru_cell_uses_delayed_state():
cell = tauGRUCell(1, 1)
with torch.no_grad():
cell.weight_ih.zero_()
cell.weight_hh.zero_()
cell.bias_ih.zero_()
cell.bias_hh.zero_()
cell.weight_hh[1, 0] = 1.0
cell.bias_hh[2] = 20.0
cell.bias_hh[3] = 20.0

x = torch.zeros(1, 1)
h = torch.zeros(1, 1)
delayed = torch.ones(1, 1)

out = cell(x, h, delayed)

assert torch.allclose(out, torch.tanh(delayed), atol=1e-4)


@pytest.mark.parametrize("Cell, in_size, hid_size, _", CELL_CASES)
def test_cell_gradients(Cell, in_size, hid_size, _):
"""A quick smoke test: outputs should be differentiable wrt parameters."""
Expand Down
3 changes: 3 additions & 0 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SGU,
SGRN,
STAR,
tauGRU,
UGRNN,
UnICORNN,
WMCLSTM,
Expand Down Expand Up @@ -63,6 +64,7 @@
SGU,
SGRN,
STAR,
tauGRU,
UGRNN,
UnICORNN,
WMCLSTM,
Expand Down Expand Up @@ -97,6 +99,7 @@
(SGU, False),
(SGRN, False),
(STAR, False),
(tauGRU, False),
(UGRNN, False),
(UnICORNN, True),
(WMCLSTM, True),
Expand Down
4 changes: 4 additions & 0 deletions torchrecurrent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
SGUCell,
SGRNCell,
STARCell,
tauGRUCell,
UGRNNCell,
UnICORNNCell,
WMCLSTMCell,
Expand Down Expand Up @@ -71,6 +72,7 @@
SGU,
SGRN,
STAR,
tauGRU,
UGRNN,
UnICORNN,
WMCLSTM,
Expand Down Expand Up @@ -139,6 +141,8 @@
"SGRNCell",
"STAR",
"STARCell",
"tauGRU",
"tauGRUCell",
"UGRNN",
"UGRNNCell",
"UnICORNN",
Expand Down
3 changes: 3 additions & 0 deletions torchrecurrent/cells/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .sgu_cell import DSGU, DSGUCell, SGU, SGUCell
from .sgrn_cell import SGRN, SGRNCell
from .star_cell import STAR, STARCell
from .taugru_cell import tauGRU, tauGRUCell
from .ugrnn_cell import UGRNN, UGRNNCell
from .unicornn_cell import UnICORNN, UnICORNNCell
from .wmclstm_cell import WMCLSTM, WMCLSTMCell
Expand Down Expand Up @@ -99,6 +100,8 @@
"SGRNCell",
"STAR",
"STARCell",
"tauGRU",
"tauGRUCell",
"UGRNN",
"UGRNNCell",
"UnICORNN",
Expand Down
Loading
Loading