espnet2.tts.prodiff.loss.SSimLoss
Less than 1 minute
espnet2.tts.prodiff.loss.SSimLoss
class espnet2.tts.prodiff.loss.SSimLoss(bias: float = 6.0, window_size: int = 11, channels: int = 1, reduction: str = 'none')
Bases: Module
SSimLoss.
This is an implementation of structural similarity (SSIM) loss. This code is modified from https://github.com/Po-Hsun-Su/pytorch-ssim.
Initialization.
- Parameters:
- bias (float , optional) – value of the bias. Defaults to 6.0.
- window_size (int , optional) – Window size. Defaults to 11.
- channels (int , optional) – Number of channels. Defaults to 1.
- reduction (str , optional) – Type of reduction during the loss calculation. Defaults to “none”.
forward(outputs: Tensor, target: Tensor)
Calculate forward propagation.
- Parameters:
- outputs (torch.Tensor) – Batch of output sequences generated by the model (batch, time, mels).
- target (torch.Tensor) – Batch of sequences with true states (batch, time, mels).
- Returns: Loss scalar value.
- Return type: Tensor
ssim(tensor1: Tensor, tensor2: Tensor)
Calculate SSIM loss.
- Parameters:
- tensor1 (torch.Tensor) – Generated output.
- tensor2 (torch.Tensor) – Groundtruth output.
- Returns: Loss scalar value.
- Return type: Tensor