Table of Contents

Class NTMModel<T, TInput, TOutput>

Namespace
AiDotNet.MetaLearning.Algorithms
Assembly
AiDotNet.dll

NTM model for inference with persistent memory.

public class NTMModel<T, TInput, TOutput> : IModel<TInput, TOutput, ModelMetadata<T>>

Type Parameters

T

The numeric type.

TInput

The input data type.

TOutput

The output data type.

Inheritance
NTMModel<T, TInput, TOutput>
Implements
IModel<TInput, TOutput, ModelMetadata<T>>
Inherited Members

Constructors

NTMModel(INTMController<T>, NTMMemory<T>, List<NTMReadHead<T>>, NTMWriteHead<T>, NTMOptions<T, TInput, TOutput>)

Initializes a new instance of the NTMModel class.

public NTMModel(INTMController<T> controller, NTMMemory<T> memory, List<NTMReadHead<T>> readHeads, NTMWriteHead<T> writeHead, NTMOptions<T, TInput, TOutput> options)

Parameters

controller INTMController<T>
memory NTMMemory<T>
readHeads List<NTMReadHead<T>>
writeHead NTMWriteHead<T>
options NTMOptions<T, TInput, TOutput>

Properties

Metadata

public ModelMetadata<T> Metadata { get; }

Property Value

ModelMetadata<T>

Methods

GetModelMetadata()

Retrieves metadata and performance metrics about the trained model.

public ModelMetadata<T> GetModelMetadata()

Returns

ModelMetadata<T>

An object containing metadata and performance metrics about the trained model.

Remarks

This method provides information about the model's structure, parameters, and performance metrics.

For Beginners: Model metadata is like a report card for your machine learning model.

Just as a report card shows how well a student is performing in different subjects, model metadata shows how well your model is performing and provides details about its structure.

This information typically includes:

  • Accuracy measures: How well does the model's predictions match actual values?
  • Error metrics: How far off are the model's predictions on average?
  • Model parameters: What patterns did the model learn from the data?
  • Training information: How long did training take? How many iterations were needed?

For example, in a house price prediction model, metadata might include:

  • Average prediction error (e.g., off by $15,000 on average)
  • How strongly each feature (bedrooms, location) influences the prediction
  • How well the model fits the training data

This information helps you understand your model's strengths and weaknesses, and decide if it's ready to use or needs more training.

GetParameters()

public Vector<T> GetParameters()

Returns

Vector<T>

Predict(TInput)

Uses the trained model to make predictions for new input data.

public TOutput Predict(TInput input)

Parameters

input TInput

A matrix where each row represents a new example to predict and each column represents a feature.

Returns

TOutput

A vector containing the predicted values for each input example.

Remarks

After training, this method applies the learned patterns to new data to predict outcomes.

For Beginners: Prediction is when the model uses what it learned to make educated guesses about new information.

Continuing the fruit identification example:

  • After learning from many examples, the child (model) can now identify new fruits they haven't seen before
  • They look at the color, shape, and size to make their best guess

In machine learning:

  • You give the model new data it hasn't seen during training
  • The model applies the patterns it learned to make predictions
  • The output is the model's best estimate based on its training

For example, in a house price prediction model:

  • You provide features of a new house (square footage, bedrooms, location)
  • The model predicts what price that house might sell for

This method is used after training is complete, when you want to apply your model to real-world data.

Train(TInput, TOutput)

Trains the model using input features and their corresponding target values.

public void Train(TInput inputs, TOutput targets)

Parameters

inputs TInput
targets TOutput

Remarks

This method takes training data and adjusts the model's internal parameters to learn patterns in the data.

For Beginners: Training is like teaching the model by showing it examples.

Imagine teaching a child to identify fruits:

  • You show them many examples of apples, oranges, and bananas (input features x)
  • You tell them the correct name for each fruit (target values y)
  • Over time, they learn to recognize the patterns that distinguish each fruit

In machine learning:

  • The x parameter contains features (characteristics) of your data
  • The y parameter contains the correct answers you want the model to learn
  • During training, the model adjusts its internal calculations to get better at predicting y from x

For example, in a house price prediction model:

  • x would contain features like square footage, number of bedrooms, location
  • y would contain the actual sale prices of those houses

UpdateParameters(Vector<T>)

public void UpdateParameters(Vector<T> parameters)

Parameters

parameters Vector<T>