credit.losses.spectral
======================

.. py:module:: credit.losses.spectral


Classes
-------

.. autoapisummary::

   credit.losses.spectral.SpectralLoss2D


Module Contents
---------------

.. py:class:: SpectralLoss2D(wavenum_init=20, reduction='none')

   Bases: :py:obj:`torch.nn.Module`


   Spectral 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.

   :param wavenum_init: The initial wavenumber to start considering in the loss calculation.
   :type wavenum_init: int
   :param reduction: Specifies the reduction to apply to the output:
                     'mean' | 'none'. 'mean': the output is averaged; 'none': no reduction is applied.
   :type reduction: str


   .. py:attribute:: wavenum_init
      :value: 20



   .. py:attribute:: reduction
      :value: 'none'



   .. py:method:: forward(output, target, weights=None, fft_dim=-1)

      Forward pass for Spectral Loss 2D.

      :param output: Predicted tensor.
      :type output: torch.Tensor
      :param target: Target tensor.
      :type target: torch.Tensor
      :param weights: Latitude weights for the loss.
      :type weights: torch.Tensor, optional
      :param fft_dim: The dimension to apply FFT.
      :type fft_dim: int

      :returns: Spectral loss value.
      :rtype: torch.Tensor



