MemoryBank<T>

Models & Types · AiDotNet.SelfSupervisedLearning

FIFO memory queue for storing embeddings in contrastive learning.

Implements: IMemoryBank<T>

For Beginners

A memory bank is a queue that stores embeddings from previous batches. This provides a large pool of negative samples for contrastive learning without requiring huge batch sizes.

How It Works

How it works:

Example usage:

Constructors

Constructor Summary
MemoryBank(int capacity, int embeddingDim, int? seed) Initializes a new instance of the MemoryBank class.

Properties

Property Summary
bool IsFull { get; }
int Capacity { get; }
int CurrentSize { get; }
int EmbeddingDimension { get; }

Methods

Method Summary
Tensor<T> GetAll()
Tensor<T> GetAt(int index) Gets the embedding at a specific index.
Tensor<T> Sample(int count)
void Clear()
void Enqueue(Tensor<T> embeddings)
void SetAt(int index, Tensor<T> embedding) Sets the embedding at a specific index.
void UpdateWithMomentum(int[] indices, Tensor<T> newEmbeddings, double momentum)