LiquidStateMachine<T>

Models & Types · AiDotNet.NeuralNetworks

Represents a Liquid State Machine (LSM), a type of reservoir computing neural network.

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → SequenceModelLayoutBase<T> → LiquidStateMachine<T>

For Beginners

A Liquid State Machine is a neural network inspired by how real brains process information over time.

Think of it like dropping different objects into a pool of water:

  • Each object creates unique ripple patterns when it hits the water
  • The ripples interact with each other in complex ways
  • By observing these ripple patterns, you can determine what objects were dropped in

In a Liquid State Machine:

  • The “reservoir” is like the pool of water with randomly connected neurons
  • Input signals create “ripples” of activity through the connected neurons
  • The network learns to recognize patterns in how these ripples develop over time

LSMs are particularly good at:

  • Processing sequential data (like speech or sensor readings)
  • Handling inputs that change over time
  • Working with noisy or incomplete information
  • Learning temporal patterns without needing extensive training

How It Works

A Liquid State Machine is a form of reservoir computing that uses a recurrent neural network with randomly connected neurons (the “reservoir”) to process temporal information. The reservoir transforms input signals into higher-dimensional representations, which are then processed by trained readout functions. LSMs are particularly effective for processing time-varying inputs and are inspired by the dynamics of biological neural networks.

Example

var input = Tensor<float>.CreateRandom(new[] { 1, 100, 10 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new LiquidStateMachine<float>())
    .Build(trainX, trainY);
var output = result.Predict(input);

Constructors

Constructor Summary
LiquidStateMachine() Initializes a new instance of the LiquidStateMachine class with the specified architecture and parameters.
LiquidStateMachine(NeuralNetworkArchitecture<T> architecture, int reservoirSize, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, LiquidStateMachineOptions options)

Methods

Method Summary
List<Tensor<T>> SimulateTimeSeries(List<Tensor<T>> timeSeriesInput) Simulates the LSM with time-series data, allowing the reservoir state to evolve over time.
ModelMetadata<T> GetModelMetadata() Gets metadata about the Liquid State Machine model.
void ResetState() Resets the state of the Liquid State Machine.
void SetTrainingMode(bool isTraining) Serializes Liquid State Machine-specific data to a binary writer.
void TrainOnTimeSeries(List<Tensor<T>> timeSeriesInput, List<Tensor<T>> timeSeriesExpectedOutput) Performs online learning for time-series data, updating the network after each time step.