computes the hinge metric between ytrue and ypred ytrue values are expected to be 1 or 1 if binary 0 or 1 labels are provided we will convert them to 1 or 1 args name optional string name of the metric instance dtype optional data type of the metric result standalone usage m keras metrics hinge m updatestate0 1 0 0 0 6 0 4 0 4 0 6 m result 1 3 m resetstate m updatestate0 1 0 0 0 6 0 4 0 4 0 6 sampleweight1 0 m result 1 1 metric should be minimized during optimization computes the hinge metric between ytrue and ypred ytrue values are expected to be 1 or 1 if binary 0 or 1 labels are provided we will convert them to 1 or 1 args name optional string name of the metric instance dtype optional data type of the metric result standalone usage m keras metrics squaredhinge m updatestate0 1 0 0 0 6 0 4 0 4 0 6 m result 1 86 m resetstate m updatestate0 1 0 0 0 6 0 4 0 4 0 6 sampleweight1 0 m result 1 46 metric should be minimized during optimization computes the categorical hinge metric between ytrue and ypred args name optional string name of the metric instance dtype optional data type of the metric result standalone usage m keras metrics categoricalhinge m updatestate0 1 0 0 0 6 0 4 0 4 0 6 m result numpy 1 4000001 m resetstate m updatestate0 1 0 0 0 6 0 4 0 4 0 6 sampleweight1 0 m result 1 2 metric should be minimized during optimization computes the hinge metric between y_true and y_pred 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 args name optional string name of the metric instance dtype optional data type of the metric result standalone usage m keras metrics hinge m update_state 0 1 0 0 0 6 0 4 0 4 0 6 m result 1 3 m reset_state m update_state 0 1 0 0 0 6 0 4 0 4 0 6 sample_weight 1 0 m result 1 1 metric should be minimized during optimization computes the hinge metric between y_true and y_pred 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 args name optional string name of the metric instance dtype optional data type of the metric result standalone usage m keras metrics squaredhinge m update_state 0 1 0 0 0 6 0 4 0 4 0 6 m result 1 86 m reset_state m update_state 0 1 0 0 0 6 0 4 0 4 0 6 sample_weight 1 0 m result 1 46 metric should be minimized during optimization computes the categorical hinge metric between y_true and y_pred args name optional string name of the metric instance dtype optional data type of the metric result standalone usage m keras metrics categoricalhinge m update_state 0 1 0 0 0 6 0 4 0 4 0 6 m result numpy 1 4000001 m reset_state m update_state 0 1 0 0 0 6 0 4 0 4 0 6 sample_weight 1 0 m result 1 2 metric should be minimized during optimization
from keras.api_export import keras_export
from keras.losses.losses import categorical_hinge
from keras.losses.losses import hinge
from keras.losses.losses import squared_hinge
from keras.metrics import reduction_metrics


@keras_export("keras.metrics.Hinge")
class Hinge(reduction_metrics.MeanMetricWrapper):
    

    def __init__(self, name="hinge", dtype=None):
        super().__init__(fn=hinge, name=name, dtype=dtype)
        
        self._direction = "down"

    def get_config(self):
        return {"name": self.name, "dtype": self.dtype}


@keras_export("keras.metrics.SquaredHinge")
class SquaredHinge(reduction_metrics.MeanMetricWrapper):
    

    def __init__(self, name="squared_hinge", dtype=None):
        super().__init__(fn=squared_hinge, name=name, dtype=dtype)
        
        self._direction = "down"

    def get_config(self):
        return {"name": self.name, "dtype": self.dtype}


@keras_export("keras.metrics.CategoricalHinge")
class CategoricalHinge(reduction_metrics.MeanMetricWrapper):
    

    def __init__(self, name="categorical_hinge", dtype=None):
        super().__init__(fn=categorical_hinge, name=name, dtype=dtype)
        
        self._direction = "down"

    def get_config(self):
        return {"name": self.name, "dtype": self.dtype}