Table of Contents

Class ExternalMemory<T>

Namespace
AiDotNet.MetaLearning.Algorithms
Assembly
AiDotNet.dll

External memory matrix for MANN.

public class ExternalMemory<T>

Type Parameters

T

The 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

size int
keySize int
valueSize int
numOps INumericOperations<T>

Properties

KeySize

Gets the key dimension.

public int KeySize { get; }

Property Value

int

Size

Gets the memory size.

public int Size { get; }

Property Value

int

ValueSize

Gets the value dimension.

public int ValueSize { get; }

Property Value

int

Methods

ClearRecent(double)

Clears recent memories based on retention ratio.

public void ClearRecent(double retentionRatio)

Parameters

retentionRatio double

ClearSlot(int)

Clears a specific memory slot.

public void ClearSlot(int location)

Parameters

location int

Clone()

Clones the external memory.

public ExternalMemory<T> Clone()

Returns

ExternalMemory<T>

ComputeUsagePenalty()

Computes memory usage penalty for regularization.

public T ComputeUsagePenalty()

Returns

T

FindLeastRecentlyUsedSlot()

Finds the least recently used memory slot.

public int FindLeastRecentlyUsedSlot()

Returns

int

FindRarelyUsedSlots(double)

Finds rarely used memory slots.

public List<int> FindRarelyUsedSlots(double threshold)

Parameters

threshold double

Returns

List<int>

GetKey(int)

Gets memory key at specified index.

public Vector<T> GetKey(int index)

Parameters

index int

Returns

Vector<T>

Read(Vector<T>)

Reads from memory using attention weights.

public Vector<T> Read(Vector<T> attentionWeights)

Parameters

attentionWeights Vector<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

location int
key Vector<T>
value Vector<T>