Skip to main content

Unofficial TensorFlow implementation of a Linear Recurrent Unit, proposed by Google Deepmind.

Project description

Linear Recurrent Units in Tensorflow: An Unofficial Implementation

This repository presents an unofficial implementation of Linear Recurrent Units (LRUs) proposed by Google DeepMind, utilizing Tensorflow. LRUs draw inspiration from Deep State-Space Machines, with a particular focus on S4 and S5 models.

Installation:

$ pip install LRU-tensorflow

Usage:

import tensorflow as tf
from LRU_tensorflow import LRU

# Define model dimensions
state_features = 19  # N: state dimension
input_size     = 5   # H: model (input) dimension

# Create LRU layer
lru = LRU(N=state_features, H=input_size)

# Prepare sample input: (batch_size, seq_length, input_size)
batch_size = 32
seq_length = 50
test_input = tf.random.uniform((batch_size, seq_length, input_size))

# Forward pass
predictions = lru(test_input)

# Output shape: (batch_size, seq_length, input_size)
print(predictions.shape)
# Expected: (32, 50, 5)

Paper:

Resurrecting Recurrent Neural Networks for Long Sequences

Notes:

  • If you require an implementation that supports 3-dimensional input sequences, you may want to refer to github.com/Gothos/LRU-pytorch. However, please be aware that this alternative implementation might be slower due to the absence of associative scans.

Project details


Download files

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

Source Distribution

lru_tensorflow-0.1.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

lru_tensorflow-0.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file lru_tensorflow-0.1.2.tar.gz.

File metadata

  • Download URL: lru_tensorflow-0.1.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for lru_tensorflow-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f685938ebef2850d1f4e34c7a4f79de428fff5c040a6e592b9a4f0b269362f05
MD5 cec95ca0ee9e9c1d7d6f459a1781c63d
BLAKE2b-256 5b7a7a2d014ea6c2abbb74c9fd1374303d57c6b6b90cd6b66da51544233c3769

See more details on using hashes here.

File details

Details for the file lru_tensorflow-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: lru_tensorflow-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for lru_tensorflow-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78f3417c004154d995d479a9c12e4a10896ff1b02ab1e145763c9be4d9dd30fc
MD5 dfacd3f4f7f473df676e4ecc8392f636
BLAKE2b-256 244b0cb2e6adbde577f6a180839c009d56235186173701f540d25c936b3ecdcd

See more details on using hashes here.

Supported by

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