ContrastiveLossBase<T>

Base Classes ยท AiDotNet.SelfSupervisedLearning.Losses

Base class for the self-supervised and contrastive objectives.

Implements: IContrastiveLoss<T>

Known derived types: BYOLLoss<T>, BarlowTwinsLoss<T>, DINOLoss<T>, InfoNCELoss<T>, MAEReconstructionLoss<T>, NTXentLoss<T>

How It Works

Supplies the tensor engine the same way every other base in the library does (LossFunctionBase, ActivationFunctionBase, AdversarialAttackBase), so an objective builds its loss from IEngine operations and the result carries tape history.

That matters more here than it looks. These objectives previously assembled their loss from host loops over tensor indexers and returned a bare scalar, which cannot be differentiated โ€” so the whole family could be measured but never trained on, and models wanting a published contrastive objective quietly fell back to a pointwise loss instead.

Methods

Method Summary
Tensor<T> ComputeLoss(Tensor<T> view1, Tensor<T> view2)