espnet2.svs.discrete.loss.DiscreteLoss
Less than 1 minute
espnet2.svs.discrete.loss.DiscreteLoss
class espnet2.svs.discrete.loss.DiscreteLoss(use_masking=True, use_weighted_masking=False, predict_pitch=False)
Bases: Module
Loss function module for feed-forward Transformer.
Initialize feed-forward Transformer loss module.
- Parameters:
- use_masking (bool) – Whether to apply masking for padded part in loss calculation.
- use_weighted_masking (bool) – Whether to weighted masking in loss calculation.
- predict_pitch (bool) – Whether to predict pitch and calculate pitch loss.
forward(after_outs: Tensor, before_outs: Tensor, d_outs: Tensor, ys: Tensor, ds: Tensor, ilens: Tensor, olens: Tensor, p_outs: Tensor | None = None, ps: Tensor | None = None, plens: Tensor | None = None)
Calculate forward propagation.
- Parameters:
- after_outs (Tensor) – Batch of outputs after postnets (B, Lmax, odim).
- before_outs (Tensor) – Batch of outputs before postnets (B, Lmax, odim).
- d_outs (Tensor) – Batch of outputs of duration predictor (B, Tmax).
- ys (Tensor) – Batch of target features (B, Lmax, odim).
- ds (Tensor) – Batch of durations (B, Tmax).
- ilens (LongTensor) – Batch of the lengths of each input (B,).
- olens (LongTensor) – Batch of the lengths of each target (B,).
- p_outs (Tensor) – Batch of outputs of log_f0 (B, T_text, 1).
- ps (Tensor) – Batch of target log_f0 (B, T_text, 1).
- Returns: L1 loss value. Tensor: Duration predictor loss value. Tensor: Pitch loss value.
- Return type: Tensor