
    &Vf                        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dS )    )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
    r   Nc                 h    t                                          t          ||           d| _        d S N)fnnamedtypedown)super__init__r   
_directionselfr   r   	__class__s      \/var/www/html/software/conda/lib/python3.11/site-packages/keras/src/metrics/hinge_metrics.pyr   zHinge.__init__    s-    EE:::     c                      | j         | j        dS Nr   r   r   r   s    r   
get_configzHinge.get_config%       	DJ777r   )r   N__name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r	   r	      V         ,! ! ! ! ! !
8 8 8 8 8 8 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
    r   Nc                 h    t                                          t          ||           d| _        d S r   )r   r   r   r   r   s      r   r   zSquaredHinge.__init__A   s-    MEBBB r   c                      | 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
    r   Nc                 h    t                                          t          ||           d| _        d S r   )r   r   r   r   r   s      r   r   zCategoricalHinge.__init__^   s.    -DFFF r   c                      | j         | j        dS r   r   r   s    r   r   zCategoricalHinge.get_configc   r   r   )r   Nr   r$   s   @r   r+   r+   J   sV         $! ! ! ! ! !
8 8 8 8 8 8 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 5 5 5 5 5 ) ) ) ) ) ) 1 1 1 1 1 1 / / / / / / #$$8 8 8 8 8/ 8 8 %$8@ *++8 8 8 8 8$6 8 8 ,+8@ .//8 8 8 8 8(: 8 8 0/8 8 8r   