Skip to main content

Implementation of the bistable recurrent cell (BRC) in PyTorch

Project description

brc-pytorch

PyTorch implementation of the bistable recurrent cell (BRC) from the paper A bio-inspired bistable recurrent cell allows for long-lasting memory (Vecoven et al., 2020).

Install

pip install brc-pytorch

Usage

import torch
from brc_pytorch.modules import BRC, NBRC, StackedRNN

brc = StackedRNN(
    cell=BRC,  # NBRC for the neuromodulated version
    input_size=128,
    hidden_size=256,
    num_layers=3
)

# [ seq_len, batch_size, dim ]
x = torch.randn(64, 32, 128)

init_hidden = brc.init_hidden(batch_size=32)
out, hidden = brc(x, init_hidden)

Performance

The implementation is provided in TorchScript and makes use of the PyTorch JIT compiler. In my not really statistically significant experiments, the implementation seems to be about half as fast as the cuDNN based reference LSTM implementation with modest batch sizes and sequence lengths which can be considered pretty solid for a non-CUDA implementation.

References

@misc{vecoven2020bioinspired,
    title={A bio-inspired bistable recurrent cell allows for long-lasting memory},
    author={Nicolas Vecoven and Damien Ernst and Guillaume Drion},
    year={2020},
    eprint={2006.05252},
    archivePrefix={arXiv},
    primaryClass={cs.NE}
}

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

brc-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

brc-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file brc-0.1.1.tar.gz.

File metadata

  • Download URL: brc-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.0b4

File hashes

Hashes for brc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4a2efac06c26e9969ce9e88740ffde367d4bbdc0ec5c0ac96b56b6666b724888
MD5 3657619dd143677d37a6790f2ca2c5a5
BLAKE2b-256 ca515149a1c990ebd8a31000cb15aae4c2bd4a94f980e9495d4a9dbc44b97ce8

See more details on using hashes here.

File details

Details for the file brc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: brc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.0b4

File hashes

Hashes for brc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67018382c4bab1ca704129cf464e94344cb0d0a88f975da0fd89c644f76113a1
MD5 5d41474355d5eb58cf7527edc5ff63c9
BLAKE2b-256 e5e37575b3e142fb41816dd04bae8506f365d60f13088268fbc933d3d076973b

See more details on using hashes here.

Supported by

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