ContrastiveHead¶
- class mmpretrain.models.heads.ContrastiveHead(loss, temperature=0.1, init_cfg=None)[源代码]¶
Head for contrastive learning.
The contrastive loss is implemented in this head and is used in SimCLR, MoCo, DenseCL, etc.
- 参数:
- loss(pos, neg)[源代码]¶
Forward function to compute contrastive loss.
- 参数:
pos (torch.Tensor) – Nx1 positive similarity.
neg (torch.Tensor) – Nxk negative similarity.
- 返回:
The contrastive loss.
- 返回类型: