credit.losses.les_loss#
Attributes#
Classes#
Custom loss function class for 2D geospatial data |
Module Contents#
- credit.losses.les_loss.logger#
- class credit.losses.les_loss.LESLoss2D(conf, validation=False)#
Bases:
torch.nn.ModuleCustom loss function class for 2D geospatial data with optional spectral and power loss components.
This class defines a loss function that combines a base loss (e.g., L1, MSE) with optional spectral and power loss components for 2D geospatial data. The loss function can incorporate latitude and variable-specific weights.
- Parameters:
conf (dict) – Configuration dictionary containing loss function settings and weights.
validation (bool, optional) – If True, the loss function is used in validation mode. Defaults to False.
- conf#
- vars#
- lat_weights = None#
- var_weights = None#
- use_spectral_loss#
- use_power_loss#
- validation = False#
- forward(target, pred)#
Calculate the total loss for the given target and prediction.
This method computes the base loss between the target and prediction, applies latitude and variable weights, and optionally adds spectral and power loss components.
- Parameters:
target (torch.Tensor) – Ground truth tensor.
pred (torch.Tensor) – Predicted tensor.
- Returns:
The computed loss value.
- Return type:
torch.Tensor