Class ExternalMemory<T>
- Namespace
- AiDotNet.MetaLearning.Algorithms
- Assembly
- AiDotNet.dll
External memory matrix for MANN.
public class ExternalMemory<T>
Type Parameters
TThe numeric type.
- Inheritance
-
ExternalMemory<T>
- Inherited Members
Remarks
Stores key-value pairs that can be read and written by the MANN controller. Uses attention-based reading and LRU-based writing.
Constructors
ExternalMemory(int, int, int, INumericOperations<T>)
Initializes a new instance of the ExternalMemory.
public ExternalMemory(int size, int keySize, int valueSize, INumericOperations<T> numOps)
Parameters
Properties
KeySize
Gets the key dimension.
public int KeySize { get; }
Property Value
Size
Gets the memory size.
public int Size { get; }
Property Value
ValueSize
Gets the value dimension.
public int ValueSize { get; }
Property Value
Methods
ClearRecent(double)
Clears recent memories based on retention ratio.
public void ClearRecent(double retentionRatio)
Parameters
retentionRatiodouble
ClearSlot(int)
Clears a specific memory slot.
public void ClearSlot(int location)
Parameters
locationint
Clone()
Clones the external memory.
public ExternalMemory<T> Clone()
Returns
ComputeUsagePenalty()
Computes memory usage penalty for regularization.
public T ComputeUsagePenalty()
Returns
- T
FindLeastRecentlyUsedSlot()
Finds the least recently used memory slot.
public int FindLeastRecentlyUsedSlot()
Returns
FindRarelyUsedSlots(double)
Finds rarely used memory slots.
public List<int> FindRarelyUsedSlots(double threshold)
Parameters
thresholddouble
Returns
GetKey(int)
Gets memory key at specified index.
public Vector<T> GetKey(int index)
Parameters
indexint
Returns
- Vector<T>
Read(Vector<T>)
Reads from memory using attention weights.
public Vector<T> Read(Vector<T> attentionWeights)
Parameters
attentionWeightsVector<T>
Returns
- Vector<T>
Write(int, Vector<T>, Vector<T>)
Writes to memory at specified location.
public void Write(int location, Vector<T> key, Vector<T> value)
Parameters
locationintkeyVector<T>valueVector<T>