BarlowTwins<T>
Models & Types · AiDotNet.SelfSupervisedLearning
Barlow Twins: Self-Supervised Learning via Redundancy Reduction.
Inheritance: ModelBase<T, Tensor<T>, Tensor<T>> → SelfSupervisedLearningMethodBase<T> → BarlowTwins<T>
For Beginners
Barlow Twins learns representations by making the cross-correlation matrix between embeddings of two augmented views close to the identity matrix. This achieves both invariance (diagonal = 1) and reduces redundancy between features (off-diagonal = 0).
How It Works
Key innovations:
Loss components:
Cross-correlation matrix:
Reference: Zbontar et al., “Barlow Twins: Self-Supervised Learning via Redundancy Reduction” (ICML 2021)
Best for: Interpretable approach, avoiding collapse naturally.
Pros: Interpretable loss, naturally avoids collapse, no negative samples.
Cons: Requires careful scaling of loss terms.
Constructors
| Constructor | Summary |
|---|---|
BarlowTwins(INeuralNetwork<T> encoder, IProjectorHead<T> projector, SelfSupervisedLearningConfig<T> config) |
Initializes a new instance of the BarlowTwins class. |
Properties
| Property | Summary |
|---|---|
SelfSupervisedLearningMethodCategory Category { get; } |
|
bool RequiresMemoryBank { get; } |
|
bool UsesMomentumEncoder { get; } |
|
double Lambda { get; } |
Gets the lambda (redundancy reduction weight) used in the loss. |
string Name { get; } |
Methods
| Method | Summary |
|---|---|
BarlowTwins<T> Create(INeuralNetwork<T> encoder, int encoderOutputDim, int projectionDim, int hiddenDim, double lambda) |
Creates a Barlow Twins instance with default configuration. |