credit.losses.spectral#
Classes#
Spectral Loss in 2D. |
Module Contents#
- class credit.losses.spectral.SpectralLoss2D(wavenum_init=20, reduction='none')#
Bases:
torch.nn.ModuleSpectral Loss in 2D.
This loss function compares the spectral (frequency domain) content of the predicted and target outputs using FFT. It is useful for ensuring that the predicted output has similar frequency characteristics as the target.
- Parameters:
wavenum_init (int) – The initial wavenumber to start considering in the loss calculation.
reduction (str) – Specifies the reduction to apply to the output: ‘mean’ | ‘none’. ‘mean’: the output is averaged; ‘none’: no reduction is applied.
- wavenum_init = 20#
- reduction = 'none'#
- forward(output, target, weights=None, fft_dim=-1)#
Forward pass for Spectral Loss 2D.
- Parameters:
output (torch.Tensor) – Predicted tensor.
target (torch.Tensor) – Target tensor.
weights (torch.Tensor, optional) – Latitude weights for the loss.
fft_dim (int) – The dimension to apply FFT.
- Returns:
Spectral loss value.
- Return type:
torch.Tensor