Type Hinge
Namespace tensorflow.keras.losses
Parent LossFunctionWrapper
Interfaces IHinge
Computes the hinge loss between `y_true` and `y_pred`. `loss = maximum(1 - y_true * y_pred, 0)` `y_true` values are expected to be -1 or 1. If binary (0 or 1) labels are
provided we will convert them to -1 or 1. Usage:
Usage with the `compile` API:
Show Example
h = tf.keras.losses.Hinge() loss = h([-1., 1., 1.], [0.6, -0.7, -0.5]) # loss = max(0, 1 - y_true * y_pred) = [1.6 + 1.7 + 1.5] / 3 print('Loss: ', loss.numpy()) # Loss: 1.6