Shortcuts

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 (dict) – Config dict for module of loss functions.

  • temperature (float) – The temperature hyper-parameter that controls the concentration level of the distribution. Defaults to 0.1.

  • init_cfg (dict or List[dict], optional) – Initialization config dict. Defaults to None.

loss(pos, neg)[源代码]

Forward function to compute contrastive loss.

参数:
返回:

The contrastive loss.

返回类型:

torch.Tensor

Read the Docs v: latest
Versions
latest
stable
mmcls-1.x
mmcls-0.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.