sup3r.utilities.loss_metrics.MaterialDerivativeLoss#
- class MaterialDerivativeLoss(reduction='auto', name=None)[source]#
Bases:
Loss
Loss class for the material derivative. This is the left hand side of the Navier-Stokes equation and is equal to internal + external forces divided by density.
References
https://en.wikipedia.org/wiki/Material_derivative
Initializes Loss class.
- Args:
- reduction: Type of tf.keras.losses.Reduction to apply to
loss. Default value is AUTO. AUTO indicates that the reduction option will be determined by the usage context. For almost all cases this defaults to SUM_OVER_BATCH_SIZE. When used under a tf.distribute.Strategy, except via Model.compile() and Model.fit(), using AUTO or SUM_OVER_BATCH_SIZE will raise an error. Please see this custom training [tutorial]( https://www.tensorflow.org/tutorials/distribute/custom_training) for more details.
name: Optional name for the instance.
Methods
call
(y_true, y_pred)Invokes the Loss instance.
from_config
(config)Instantiates a Loss from its config (output of get_config()).
Returns the config dictionary for a Loss instance.
Attributes
LOSS_METRIC
- __call__(x1, x2)[source]#
Custom content loss that encourages accuracy of the material derivative. This assumes that the first 2 * N features are N u/v wind components at different hub heights and that the total number of features is either 2 * N or 2 * N + 1
- 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.