MbPAEpisodicMemory<T>

Models & Types · AiDotNet.MetaLearning.Algorithms

MbPA’s episodic memory M = {(h_i, v_i)}: embeddings as keys, observed targets as values, with K-nearest-neighbour retrieval by Euclidean distance.

For Beginners

A notebook of “when the network saw something that looked like THIS, the right answer was THAT”. Looking something up means finding the few most similar entries.

How It Works

From “Memory-based Parameter Adaptation” (Sprechmann et al., arXiv:1802.10542): “Keys {h_i} are given by the embedding network. The values {v_i} correspond to the desired output y_i”, and “Retrieval from the memory M uses K-nearest neighbour search on the keys {h_i} with Euclidean distance to obtain the K most similar keys and associated values.”

Constructors

Constructor Summary
MbPAEpisodicMemory(int capacity) Initializes an episodic memory.

Properties

Property Summary
int Capacity { get; } Gets the maximum number of pairs held before eviction begins.
int Count { get; } Gets the number of stored pairs.

Methods

Method Summary
IReadOnlyList<ValueTuple<Vector<T>, Vector<T>, double>> Retrieve(Vector<T> query, int k, double epsilon, Func<T, double> toDouble) Returns the K entries whose keys are nearest to query in Euclidean distance, together with the kernel weights w_k ~ 1 / (eps + ||h_k - q||^2) normalized to sum to one.
void Clear() Removes every stored pair.
void Write(Vector<T> key, Vector<T> value) Stores one (embedding, target) pair, evicting the oldest when at capacity.