
    2Vh                         d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ  ed       G d dej                               Z	 ed	       G d
 dej                               Z
 ed       G d dej                               Zy)    )keras_export)categorical_hinge)hinge)squared_hinge)reduction_metricszkeras.metrics.Hingec                   *     e Zd ZdZd fd	Zd Z xZS )Hingeao  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.

    Examples:

    >>> 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
    c                 @    t         |   t        ||       d| _        y N)fnnamedtypedown)super__init__r   
_directionselfr   r   	__class__s      O/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/metrics/hinge_metrics.pyr   zHinge.__init__    s    EE:     c                 4    | j                   | j                  dS Nr   r   r   r   s    r   
get_configzHinge.get_config%       		DJJ77r   )r   N__name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r	   r	          ,!
8r   r	   zkeras.metrics.SquaredHingec                   *     e Zd ZdZd fd	Zd Z xZS )SquaredHingeaw  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.

    Example:

    >>> 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
    c                 @    t         |   t        ||       d| _        y r   )r   r   r   r   r   s      r   r   zSquaredHinge.__init__A   s    MEB r   c                 4    | j                   | j                  dS r   r   r   s    r   r   zSquaredHinge.get_configF   r   r   )r   Nr   r$   s   @r   r'   r'   )   r%   r   r'   zkeras.metrics.CategoricalHingec                   *     e Zd ZdZd fd	Zd Z xZS )CategoricalHingea  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.

    Example:
    >>> 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
    c                 @    t         |   t        ||       d| _        y r   )r   r   r   r   r   s      r   r   zCategoricalHinge.__init__^   s    -DF r   c                 4    | j                   | j                  dS r   r   r   s    r   r   zCategoricalHinge.get_configc   r   r   )r   Nr   r$   s   @r   r+   r+   J   s    $!
8r   r+   N)keras.src.api_exportr   keras.src.losses.lossesr   r   r   keras.src.metricsr   MeanMetricWrapperr	   r'   r+    r   r   <module>r3      s    - 5 ) 1 / #$8// 8 %8@ *+8$66 8 ,8@ ./8(:: 8 08r   