tf.keras.losses.huber  |  TensorFlow v2.16.1 (original) (raw)

tf.keras.losses.huber

Stay organized with collections Save and categorize content based on your preferences.

Computes Huber loss value.

View aliases

Main aliases

tf.keras.metrics.huber

tf.keras.losses.huber(
    y_true, y_pred, delta=1.0
)

Formula:

for x in error:
    if abs(x) <= delta:
        loss.append(0.5 * x^2)
    elif abs(x) > delta:
        loss.append(delta * abs(x) - 0.5 * delta^2)

loss = mean(loss, axis=-1)

See: Huber loss.

Example:

y_true = [[0, 1], [0, 0]] y_pred = [[0.6, 0.4], [0.4, 0.6]] loss = keras.losses.huber(y_true, y_pred) 0.155

Args
y_true tensor of true targets.
y_pred tensor of predicted targets.
delta A float, the point where the Huber loss function changes from a quadratic to linear. Defaults to 1.0.
Returns
Tensor with one scalar loss entry per sample.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.

Last updated 2024-06-07 UTC.