deepof.model_utils.select_contrastive_loss

deepof.model_utils.select_contrastive_loss(history, future, similarity, loss_fn='nce', temperature=0.1, tau=0.1, beta=0.1, elimination_topk=0.1, attraction=False)

Select and applies the contrastive loss function to be used in the Contrastive embedding models.

Parameters:
  • history – Tensor of shape (batch_size, seq_len, embedding_dim).

  • future – Tensor of shape (batch_size, seq_len, embedding_dim).

  • similarity – Function that computes the similarity between two tensors.

  • loss_fn – String indicating the loss function to be used.

  • temperature – Float indicating the temperature to be used in the specified loss function.

  • tau – Float indicating the tau value to be used if DCL or hard DLC are selected.

  • beta – Float indicating the beta value to be used if hard DLC is selected.

  • elimination_topk – Float indicating the top-k value to be used if FC is selected.

  • attraction – Boolean indicating whether to use attraction in FC.