Shortcuts

CosineSimilarityLoss

class mmpretrain.models.losses.CosineSimilarityLoss(shift_factor=0.0, scale_factor=1.0)[源代码]

Cosine similarity loss function.

Compute the similarity between two features and optimize that similarity as loss.

参数:
  • shift_factor (float) – The shift factor of cosine similarity. Default: 0.0.

  • scale_factor (float) – The scale factor of cosine similarity. Default: 1.0.

forward(pred, target, mask=None)[源代码]

Forward function of cosine similarity loss.

参数:
返回:

The cosine similarity loss.

返回类型:

torch.Tensor