HTMNetwork<T>

Models & Types · AiDotNet.NeuralNetworks

Represents a Hierarchical Temporal Memory (HTM) network, a biologically-inspired sequence learning algorithm.

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → VectorModelLayoutBase<T> → HTMNetwork<T>

For Beginners

HTM is a special type of neural network inspired by how the human brain works.

Think of HTM like a system that learns patterns over time:

  • It’s similar to how your brain recognizes songs or predicts what comes next in a familiar sequence
  • It’s especially good at learning from time-series data (information that changes over time)
  • It can recognize patterns even when they contain noise or slight variations

HTM networks have two main parts:

  • Spatial Pooler: This converts incoming data into a special format that highlights important patterns

(like how your brain might focus on the melody of a song rather than background noise)

  • Temporal Memory: This learns sequences and can predict what might come next

(like how you can anticipate the next note in a familiar song)

HTM is particularly useful for:

  • Anomaly detection (finding unusual patterns)
  • Sequence prediction (guessing what comes next)
  • Pattern recognition in noisy data

How It Works

Hierarchical Temporal Memory (HTM) is a machine learning model that mimics the structural and algorithmic properties of the neocortex. It is particularly designed for sequence learning, prediction, and anomaly detection in time-series data. HTM networks consist of two main components: a Spatial Pooler that creates sparse distributed representations of inputs, and a Temporal Memory that learns sequences of these representations.

Example

var architecture = new NeuralNetworkArchitecture<float>(inputFeatures: 8, outputSize: 4);
var input = Tensor<float>.CreateRandom(new[] { 1, 100 });
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 HTMNetwork<float>(architecture))
    .Build(trainX, trainY);
var output = result.Predict(input);

Constructors

Constructor Summary
HTMNetwork() Initializes a new instance of the HTMNetwork class with the specified architecture and parameters.
HTMNetwork(NeuralNetworkArchitecture<T> architecture, ILossFunction<T> lossFunction, HTMNetworkOptions options)

Methods

Method Summary
ModelMetadata<T> GetModelMetadata() Gets metadata about the HTM network.
void Learn(Vector<T> input) Processes an input vector through the network and updates the network’s internal state based on the input.