sup3r.utilities.loss_metrics.SpatiotemporalExtremesLoss

class SpatiotemporalExtremesLoss(spatial_weight=1.0, temporal_weight=1.0)[source]

Bases: Loss

Loss class that encourages accuracy of the min/max values across both space and time

Initialize the loss with given weight

Parameters:
  • spatial_weight (float) – Weight for spatial min/max loss terms.

  • temporal_weight (float) – Weight for temporal min/max loss terms.

Methods

call(y_true, y_pred)

Invokes the Loss instance.

from_config(config)

Instantiates a Loss from its config (output of get_config()).

get_config()

Returns the config dictionary for a Loss instance.

Attributes

MAE_LOSS

S_EX_LOSS

T_EX_LOSS

__call__(x1, x2)[source]

Custom content loss that encourages spatiotemporal min/max accuracy.

Parameters:
  • x1 (tf.tensor) – synthetic generator output (n_observations, spatial_1, spatial_2, temporal, features)

  • x2 (tf.tensor) – high resolution data (n_observations, spatial_1, spatial_2, temporal, features)

Returns:

tf.tensor – 0D tensor with loss value

abstract call(y_true, y_pred)

Invokes the Loss instance.

Args:
y_true: Ground truth values. shape = [batch_size, d0, .. dN],

except sparse loss functions such as sparse categorical crossentropy where shape = [batch_size, d0, .. dN-1]

y_pred: The predicted values. shape = [batch_size, d0, .. dN]

Returns:

Loss values with the shape [batch_size, d0, .. dN-1].

classmethod from_config(config)

Instantiates a Loss from its config (output of get_config()).

Args:

config: Output of get_config().

Returns:

A Loss instance.

get_config()

Returns the config dictionary for a Loss instance.