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
