Class NTMMemory<T>
- Namespace
- AiDotNet.MetaLearning.Algorithms
- Assembly
- AiDotNet.dll
External memory matrix for Neural Turing Machine.
public class NTMMemory<T>
Type Parameters
TThe 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
sizeintNumber of memory slots.
widthintDimension of each memory slot.
randomSeedint?Optional random seed for reproducibility.
Properties
Size
Gets the size (number of slots) of the memory.
public int Size { get; }
Property Value
Width
Gets the width (dimension) of each memory slot.
public int Width { get; }
Property Value
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
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
readWeightsVector<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
writeWeightsVector<T>The attention weights for writing.
eraseVectorTensor<T>The erase vector.
addVectorTensor<T>The add vector.