espnet2.gan_tts.jets.loss.ForwardSumLoss
Less than 1 minute
espnet2.gan_tts.jets.loss.ForwardSumLoss
class espnet2.gan_tts.jets.loss.ForwardSumLoss
Bases: Module
Forwardsum loss described at https://openreview.net/forum?id=0NQwnnwAORi
This module computes the forwardsum loss for a batch of input sequences. The forwardsum loss is particularly useful in tasks where the alignment between input and target sequences is crucial, such as in speech recognition or text-to-speech systems.
None
- Parameters:
- log_p_attn (Tensor) – Batch of log probability of attention matrix (B, T_feats, T_text).
- ilens (Tensor) – Batch of the lengths of each input (B,).
- olens (Tensor) – Batch of the lengths of each target (B,).
- blank_prob (float) – Blank symbol probability. Default is e^-1.
- Returns: forwardsum loss value.
- Return type: Tensor
####### Examples
>>> model = ForwardSumLoss()
>>> log_p_attn = torch.randn(4, 10, 20) # Example log probabilities
>>> ilens = torch.tensor([10, 9, 8, 7]) # Input lengths
>>> olens = torch.tensor([5, 4, 3, 2]) # Output lengths
>>> loss = model(log_p_attn, ilens, olens)
>>> print(loss)
Initialize forwardsum loss module.
forward(log_p_attn: Tensor, ilens: Tensor, olens: Tensor, blank_prob: float = 0.36787944117144233) → Tensor
Forwardsum loss described at https://openreview.net/forum?id=0NQwnnwAORi
None
- Parameters:
- log_p_attn (Tensor) – Batch of log probability of attention matrix (B, T_feats, T_text).
- ilens (Tensor) – Batch of the lengths of each input (B,).
- olens (Tensor) – Batch of the lengths of each target (B,).
- blank_prob (float) – Blank symbol probability. Default is e^-1.
- Returns: forwardsum loss value.
- Return type: Tensor
####### Examples
>>> model = ForwardSumLoss()
>>> log_p_attn = torch.randn(2, 5, 4) # Example log probabilities
>>> ilens = torch.tensor([4, 3])
>>> olens = torch.tensor([3, 2])
>>> loss = model(log_p_attn, ilens, olens)
>>> print(loss)