TemporalMemoryLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

Represents a temporal memory layer that models sequence learning through hierarchical temporal memory concepts.

Inheritance: LayerBase<T> → TemporalMemoryLayer<T>

Implements: IShapeContract

For Beginners

This layer helps the network remember and predict sequences of patterns.

Think of it like learning to anticipate what comes next in a song:

  • The layer organizes memory cells into columns (like musical notes)
  • Each column can have multiple cells (representing different contexts for the same note)
  • When a note plays, the layer activates specific cells based on what came before
  • Over time, it learns which notes typically follow others in different contexts

For example, in a melody, the note “C” might be followed by “D” in the verse but by “G” in the chorus. This layer helps the network learn such context-dependent sequences by remembering not just what happened, but the context in which it happened.

How It Works

A temporal memory layer implements a simplified version of Hierarchical Temporal Memory (HTM) concepts to learn sequential patterns in data. It organizes cells into columns, where cells within the same column represent alternative contexts for the same input pattern. This allows the layer to maintain multiple predictions simultaneously and learn temporal patterns in the input data.

Constructors

Constructor Summary
TemporalMemoryLayer(int columnCount, int cellsPerColumn) Initializes a new instance of the TemporalMemoryLayer class.

Properties

Property Summary
Vector<T> PreviousState { get; set; } Gets or sets the previous input state of the layer.
bool SupportsTraining { get; }

Methods

Method Summary
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
IReadOnlyList<ValueTuple<string, Tensor<T>>> GetRegisteredBuffers()
Vector<T> GetPredictions() Gets the predicted columns based on the current cell states.
void Learn(Vector<T> input, Vector<T> previousState) Updates the cell states based on the current input and previous state.
void ResetState() Resets the internal state of the layer.