tf.keras.losses.MeanSquaredLogarithmicError

Computes the mean squared logarithmic error between y_true and y_pred.

loss = square(log(y_true + 1.) - log(y_pred + 1.))

Standalone usage:

y_true = [[0., 1.], [0., 0.]]
y_pred = [[1., 1.], [1., 0.]]
# Using 'auto'/'sum_over_batch_size' reduction type.
msle = tf.keras.losses.MeanSquaredLogarithmicError()
msle(y_true, y_pred).numpy()
0.240
# Calling with 'sample_weight'.
msle(y_true, y_pred, sample_weight=[0.7, 0.3]).numpy()
0.120
# Using 'sum' reduction type.
msle = tf.keras.losses.MeanSquaredLogarithmicError(
    reduction=tf.keras.losses.Reduction.SUM)
msle(y_true, y_pred).numpy()
0.480
# Using 'none' reduction type.
msle = tf.keras.losses.MeanSquaredLogarithmicError(
    reduction=tf.keras.losses.Reduction.NONE)
msle(y_true, y_pred).numpy()