sup3r.utilities.loss_metrics.LowResLoss#
- class LowResLoss(s_enhance=1, t_enhance=1, t_method='average', tf_loss='MeanSquaredError', ex_loss=None, **kwargs)[source]#
Bases:
Sup3rLossContent loss that is calculated by coarsening the synthetic and true high-resolution data pairs and then performing the pointwise content loss on the low-resolution fields
Initialize the loss with given weight
- Parameters:
s_enhance (int) – factor by which to coarsen spatial dimensions. 1 will keep the spatial axes as high-res
t_enhance (int) – factor by which to coarsen temporal dimension. 1 will keep the temporal axes as high-res
t_method (str) – Accepted options: [subsample, average] Subsample will take every t_enhance-th time step, average will average over t_enhance time steps
tf_loss (str) – The tensorflow loss function to operate on the low-res fields. Must be the name of a loss class that can be retrieved from
tf.keras.lossese.g., “MeanSquaredError” or “MeanAbsoluteError”ex_loss (None | str) – Optional additional loss metric evaluating the spatial or temporal extremes of the high-res data. Can be “SpatialExtremesLoss” or “TemporalExtremesLoss” (keys in
EX_LOSS_METRICS).
Methods
call(x_true, x_gen)Custom content loss calculated on re-coarsened low-res fields
from_config(config)get_config()Attributes
EX_LOSS_METRICSdtype- call(x_true, x_gen)[source]#
Custom content loss calculated on re-coarsened low-res fields
- Parameters:
x_true (tf.tensor) – True high resolution data, shape is either of these: (n_obs, spatial_1, spatial_2, features) (n_obs, spatial_1, spatial_2, temporal, features)
x_gen (tf.tensor) – Synthetic high-res generator output, shape is either of these: (n_obs, spatial_1, spatial_2, features) (n_obs, spatial_1, spatial_2, temporal, features)
- Returns:
tf.tensor – 0D tensor loss value
- __call__(y_true, y_pred, sample_weight=None)#
Call self as a function.