Table of Contents

Class NTMMemory<T>

Namespace
AiDotNet.MetaLearning.Algorithms
Assembly
AiDotNet.dll

External memory matrix for Neural Turing Machine.

public class NTMMemory<T>

Type Parameters

T

The numeric type.

Inheritance
NTMMemory<T>
Inherited Members

Constructors

NTMMemory(int, int, int?)

Initializes a new instance of NTMMemory.

public NTMMemory(int size, int width, int? randomSeed = null)

Parameters

size int

Number of memory slots.

width int

Dimension of each memory slot.

randomSeed int?

Optional random seed for reproducibility.

Properties

Size

Gets the size (number of slots) of the memory.

public int Size { get; }

Property Value

int

Width

Gets the width (dimension) of each memory slot.

public int Width { get; }

Property Value

int

Methods

Clone()

Clones the memory matrix.

public NTMMemory<T> Clone()

Returns

NTMMemory<T>

A deep copy of this memory.

ComputeSharpnessPenalty()

Computes memory sharpness penalty for regularization. Measures how focused the attention distribution is and penalizes very sharp attention.

public T ComputeSharpnessPenalty()

Returns

T

The sharpness penalty value (higher = more focused attention).

ComputeUsagePenalty()

Computes memory usage penalty for regularization.

public T ComputeUsagePenalty()

Returns

T

The usage penalty value.

GetValue(int, int)

Gets the memory value at the specified location.

public T GetValue(int row, int col)

Parameters

row int
col int

Returns

T

InitializeLearned()

Initializes memory with learned initialization.

public void InitializeLearned()

InitializeRandom()

Initializes memory with random values.

public void InitializeRandom()

InitializeZeros()

Initializes memory with zeros.

public void InitializeZeros()

Read(Vector<T>)

Reads from memory using attention weights.

public Tensor<T> Read(Vector<T> readWeights)

Parameters

readWeights Vector<T>

The attention weights for reading.

Returns

Tensor<T>

The weighted sum of memory contents.

Reset()

Resets memory to initial state.

public void Reset()

Write(Vector<T>, Tensor<T>, Tensor<T>)

Writes to memory using interpolation.

public void Write(Vector<T> writeWeights, Tensor<T> eraseVector, Tensor<T> addVector)

Parameters

writeWeights Vector<T>

The attention weights for writing.

eraseVector Tensor<T>

The erase vector.

addVector Tensor<T>

The add vector.