NTMMemory<T>

Models & Types · AiDotNet.MetaLearning.Algorithms

External memory matrix for Neural Turing Machine.

How It Works

Every write replaces the contents with a new tensor rather than mutating them, so a gradient tape keeps each step’s memory and backpropagates through the whole episode.

Constructors

Constructor Summary
NTMMemory(int size, int width, int? randomSeed) Initializes a new instance of NTMMemory.

Properties

Property Summary
Tensor<T> Contents { get; } Gets the memory matrix M_t, [Size, Width].
int Size { get; } Gets the size (number of slots) of the memory.
int Width { get; } Gets the width (dimension) of each memory slot.

Methods

Method Summary
NTMMemory<T> Clone() Clones the memory matrix.
T ComputeSharpnessPenalty() Computes memory sharpness penalty for regularization.
T ComputeUsagePenalty() Computes memory usage penalty for regularization.
T GetValue(int row, int col) Gets the memory value at the specified location.
Tensor<T> Address(NTMAddressingParameters<T> parameters, Tensor<T> previousWeights) Computes a head’s weighting over the memory locations (Graves et al.
Tensor<T> Read(Tensor<T> readWeights) Reads from memory: r_t = sum_i w_t(i) M_t(i) (Graves et al.
Tensor<T> Read(Vector<T> readWeights) Reads from memory: r_t = sum_i w_t(i) M_t(i) (Graves et al.
void InitializeLearned() Initializes memory with learned initialization.
void InitializeRandom() Initializes memory with random values.
void InitializeZeros() Initializes memory with zeros.
void Reset() Resets memory to initial state.
void Write(Tensor<T> writeWeights, Tensor<T> eraseVector, Tensor<T> addVector) Writes to memory: erase then add, M_t = M_{t-1} * (1 - w_t e_t^T) + w_t a_t^T (Graves et al.
void Write(Vector<T> writeWeights, Tensor<T> eraseVector, Tensor<T> addVector) Writes to memory: erase then add, M_t = M_{t-1} * (1 - w_t e_t^T) + w_t a_t^T (Graves et al.