Back to LNNs Hub

Deconstructing Liquid Neural Networks (LNNs)

Part 3: Benchmarking LNNs vs LSTMs

Introduction

We’ve explored the continuous mathematics (Part 1) and written a custom Liquid Time-Constant (LTC) layer in pure PyTorch (Part 2). Now it is time to prove why Liquid Neural Networks matter.

The defining feature of an LNN is out-of-distribution robustness and extreme parameter efficiency. In this finale, we will benchmark our custom Liquid layer against a standard PyTorch LSTM on a chaotic, noisy time-series prediction task.

The Benchmark Task

We generated a chaotic, noisy time-series trajectory using a summation of various sine distributions offset with standard Gaussian noise. We then trained both models to predict the next time-step given the noisy current time-step.

Model Architectures

We pitted a standard PyTorch nn.LSTM against our custom LiquidLayer. To demonstrate extreme parameter efficiency, we severely constrained our LNN, allowing it only 105 learnable parameters. The standard LSTM, even with a small hidden dimension, required 1,233 parameters—over 10$\times$ the size of our LNN.

Results: Efficiency vs Generalization

To ensure we aren't just measuring memorization, we split the 300-step generated trajectory into a training set (first 200 steps) and a completely unseen test set (final 100 steps). Over 1000 epochs of training on the sequence dataset:

While the massive LSTM precisely memorized the training trajectory at the cost of generalization, our Liquid layer successfully modeled the underlying continuous dynamics themselves. In a real-world edge deployment scenario where robustness to unseen data and memory limits are strictly constrained, the LNN provides a profound mathematical alternative to fixed recurrent weights.

Visualizing the "Liquid" Behavior

If we plot the underlying time-constant $\tau_{sys}$ alongside the input sequence during inference, we can see exactly why the model is "liquid." During relatively smooth portions of the time series, $\tau_{sys}$ remains high, allowing the network state to integrate information slowly and stably.

However, right when a significant, discontinuous jump or chaotic noise spike occurs in the dataset, $\tau_{sys}$ plummets toward zero. The network rapidly drops its old memory, shifting its internal dynamics to immediately respond to the sudden change. The differential equations governing the network actively restructure themselves based on the input!

We have included a plot of our generated benchmark in the repository that visually compares the learning trajectory.

Training loss comparison over 1000 epochs. Our 105-parameter Liquid layer learns the core sequence dynamics comparably to a 1,233-parameter LSTM.

Training loss comparison over 1000 epochs. Our 105-parameter Liquid layer learns the core sequence dynamics comparably to a 1,233-parameter LSTM.

Conclusion

The era of massive, heavily-parameterized, static-weight recursive matrices may be facing tough competition in edge-deployment environments.

Liquid Neural Networks and Liquid Time-Constant (LTC) models prove that if we rethink the mathematical structure of a neuron—shifting from discrete static weight transitions to continuous, state-dependent differential equations—we can extract more intelligence, adaptability, and robustness out of significantly fewer parameters.

By building the LTC step from scratch in PyTorch in Part 2, and benchmarking it here in Part 3, we have seen firsthand how continuous mathematics can run elegantly on discrete hardware.