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.1.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.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: liquidnn-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c6689f8393e59a9994b5285f4bd71c6759b2e34f6e983e08aae8608369a53546
MD5 98d430595e054ad4927ef4dfb3f1bb19
BLAKE2b-256 8f3fa395243116ba53913b32c19220633c0e96336a4e843c7e5c4f7228e7d269

See more details on using hashes here.

File details

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

File metadata

  • Download URL: liquidnn-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53dba91a38b436abcd5cba7cc1b99c7d7ceabcdf3e1512367161a8cf4967f590
MD5 d15dc427981abf234a9190fb7227b89b
BLAKE2b-256 0a9908d4fb983ea5e6f5170749f8b1ea961f27e85baff0396fa49317ec9d836a

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