spamosaic.loss
- class spamosaic.loss.CL_loss(*args: Any, **kwargs: Any)[source]
Bases:
ModuleContrastive Loss for multi-view representation alignment.
This loss function is designed to encourage representations from the same sample across multiple modalities to be similar, while pushing apart representations from different samples.
- Parameters:
batch_size (int) – Number of samples in a mini-batch (per modality).
rep (int, optional) – Number of modalities or views (default: 3).
bias (float, optional) – Small constant added to negative sample logits to avoid instability in log computations (default: 0).
- spamosaic.loss.set_diag(matrix, v)[source]
Set the diagonal of a square matrix to a specified value.
- Parameters:
matrix (torch.Tensor) – A 2D square tensor whose diagonal will be modified.
v (float) – Value to set on the diagonal.
- Returns:
The modified tensor with updated diagonal values.
- Return type:
torch.Tensor
Functions
Set the diagonal of a square matrix to a specified value. |
Classes
Contrastive Loss for multi-view representation alignment. |