speaker_loss#

(s3prl.nn.speaker_loss)

Speaker verification loss

Authors:
  • Haibin Wu 2022

softmax#

class s3prl.nn.speaker_loss.softmax(input_size: int, output_size: int)[source][source]#

Bases: Module

The standard softmax loss in an unified interface for all speaker-related softmax losses

property input_size[source]#
property output_size[source]#
forward(x: Tensor, label: LongTensor)[source][source]#
Parameters:
  • x (torch.Tensor) – (batch_size, input_size)

  • label (torch.LongTensor) – (batch_size, )

Returns:

loss (torch.float) logit (torch.Tensor): (batch_size, )

call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
training: bool[source]#

amsoftmax#

class s3prl.nn.speaker_loss.amsoftmax(input_size: int, output_size: int, margin: float = 0.2, scale: float = 30)[source][source]#

Bases: Module

AMSoftmax

Parameters:
  • input_size (int) – The input feature size

  • output_size (int) – The output feature size

  • margin (float) – Hyperparameter denotes the margin to the decision boundry

  • scale (float) – Hyperparameter that scales the cosine value

property input_size[source]#
property output_size[source]#
forward(x: Tensor, label: LongTensor)[source][source]#
Parameters:
  • x (torch.Tensor) – (batch_size, input_size)

  • label (torch.LongTensor) – (batch_size, )

Returns:

loss (torch.float) logit (torch.Tensor): (batch_size, )

call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
training: bool[source]#