ConvLSTMLayer class

A Convolutional Long Short-Term Memory (ConvLSTM) layer.

A ConvLSTMLayer is designed for spatiotemporal data, such as a sequence of images (a video). It combines the spatial processing of a Conv2D layer with the temporal memory of an LSTMLayer.

Instead of using matrix multiplications, its internal gates use convolutions. This means its hidden state and cell state are not vectors, but 2D feature maps that preserve spatial information from one timestep to the next.

  • Input: A Tensor<Tensor3D> representing the sequence, with a shape of [sequence_length, height, width].
  • Output: A Tensor<Matrix> representing the final hidden state, which is a feature map of shape [height, width].

Analogy 🌦️

A ConvLSTM is like a meteorologist watching a weather radar loop. It uses convolutions to see the shape of a storm in each frame and its LSTM logic to track how that shape moves and changes over time to predict its next location.

Example

Layer convLstm = ConvLSTMLayer(16, 3); // 16 hidden filters, 3x3 kernel
Inheritance

Constructors

ConvLSTMLayer(int hiddenFilters, int kernelSize)

Properties

b_c Tensor<Matrix>
getter/setter pair
b_f Tensor<Matrix>
getter/setter pair
b_i Tensor<Matrix>
getter/setter pair
b_o Tensor<Matrix>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hiddenFilters int
getter/setter pair
K_hc Tensor<Matrix>
getter/setter pair
K_hf Tensor<Matrix>
getter/setter pair
K_hi Tensor<Matrix>
getter/setter pair
K_ho Tensor<Matrix>
getter/setter pair
K_xc Tensor<Matrix>
getter/setter pair
K_xf Tensor<Matrix>
getter/setter pair
K_xi Tensor<Matrix>
getter/setter pair
K_xo Tensor<Matrix>
getter/setter pair
kernelSize int
getter/setter pair
name String
A user-friendly name for the layer (e.g., 'dense', 'lstm').
getter/setter pairoverride-getter
parameters List<Tensor>
A list of all trainable tensors (weights and biases) in the layer.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(Tensor input) → void
Initializes the 8 kernels and 4 biases for the LSTM gates.
override
call(Tensor input) Tensor
The public, callable interface for the layer.
inherited
forward(Tensor input) Tensor<Matrix>
Performs the forward pass by unrolling the LSTM cell through time.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited