Skip to main content

A PyTorch based module for Liquid Networks

Project description

🧠 liquidnn

A PyTorch implementation of Liquid Neural Networks (LNNs) and their hybrids (LTC, CNN, RNN, LSTM variants). This library brings continuous-time dynamics into deep learning architectures using learnable time constants.

✨ Features

🔹 LiquidNeuralNetwork – stacked liquid neurons

🔹 LTCLayer – Liquid Time-Constant layer

🔹 LiquidCNN – CNN + Liquid update

🔹 LiquidRNN – RNN + Liquid update

🔹 LiquidLSTM – LSTM + Liquid update (with bidirectional support)

🔹 Per-neuron learnable τ (time constants) with stability clamping

📦 Installation From PyPI (after publishing): pip install liquidnn

🚀 Quick Start (all models in one script)

Copy-paste this script to test every model in liquidnn:

import torch from liquidnn import ( LiquidNeuralNetwork, LTCLayer, LiquidCNN, LiquidRNN, LiquidLSTM )

1. LiquidNeuralNetwork

x = torch.randn(4, 10, 8) # batch=4, seq_len=10, input_size=8 model = LiquidNeuralNetwork(input_size=8, hidden_size=16, num_layers=2) out = model(x) print("LiquidNeuralNetwork output:", out.shape) # [4, 16]

2. LTCLayer

x = torch.randn(5, 20, 10) # batch=5, seq_len=20, input_size=10 ltc = LTCLayer(input_size=10, hidden_size=32, num_layers=2) out = ltc(x) print("LTCLayer output:", out.shape) # [5, 32]

3. LiquidCNN

x = torch.randn(8, 1, 28, 28) # MNIST-like input model = LiquidCNN(input_channels=1, hidden_size=64, num_layers_liq=2, num_layers_conv=2) out = model(x) print("LiquidCNN output:", out.shape) # [8, 64]

4. LiquidRNN

x = torch.randn(15, 4, 12) # seq_len=15, batch=4, input_size=12 model = LiquidRNN(input_size=12, hidden_size=32, num_layers_liq=2, num_layers_rnn=1) out = model(x) print("LiquidRNN output:", out.shape) # [4, 32]

5. LiquidLSTM

x = torch.randn(3, 12, 10) # batch=3, seq_len=12, input_size=10 model = LiquidLSTM(input_size=10, hidden_size=32, num_layers_liq=2, num_layers_lstm=1, batch_first=True, bidirectional=False) out = model(x) print("LiquidLSTM output:", out.shape) # [3, 32]

📚 Architectures

LiquidNeuralNetwork: Stacked liquid neurons

LTCLayer: Continuous-time RNN update rule

LiquidCNN: Convolutional backbone + LTC dynamics

LiquidRNN: RNN + Liquid refinement

LiquidLSTM: LSTM + Liquid refinement

Install dependencies:

pip install torch

🌟 Contribute

PRs and issues are welcome! If you try new liquidized architectures, feel free to share 🚀

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

liquidnn-1.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

liquidnn-1.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file liquidnn-1.1.0.tar.gz.

File metadata

  • Download URL: liquidnn-1.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for liquidnn-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5b2a6a2c96083f11d9ad109d3ddef8dd2e4c6d86de0613a0c8a2f142b29487b1
MD5 278fd565ab94b89869b41ad18797eee4
BLAKE2b-256 db959a59a328c437d09acb0a50b07de8d5d033ae7450f58bee01ae4c2ecb72ba

See more details on using hashes here.

File details

Details for the file liquidnn-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: liquidnn-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for liquidnn-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e23f5c23e60bb5a88f4eb6fe17f86cd10916296507b6d558703251e0a93750e2
MD5 b553d219856c8e3b9f01f769a75e7717
BLAKE2b-256 0126e2ddd1069cca08be24b36b996fc3ebbfc20380b1b416210ae790964d8968

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