o
    2h                     @   s   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 dejZ	ed	G d
d dejZ
edG d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d	Zdd Z  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                       t  jt||d d| _d S N)fnnamedtypedown)super__init__r   
_directionselfr   r   	__class__ Z/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/metrics/hinge_metrics.pyr          
zHinge.__init__c                 C      | j | jdS Nr   r   r   r   r   r   r   
get_config%      zHinge.get_config)r   N__name__
__module____qualname____doc__r   r   __classcell__r   r   r   r   r          r   zkeras.metrics.SquaredHingec                       r   )	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                    r	   r
   )r   r   r   r   r   r   r   r   r   A   r   zSquaredHinge.__init__c                 C   r   r   r   r   r   r   r   r   F   r   zSquaredHinge.get_config)r   Nr   r   r   r   r   r&   )   r%   r&   zkeras.metrics.CategoricalHingec                       r   )	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                    r	   r
   )r   r   r   r   r   r   r   r   r   ^   r   zCategoricalHinge.__init__c                 C   r   r   r   r   r   r   r   r   c   r   zCategoricalHinge.get_config)r   Nr   r   r   r   r   r'   J   s    r'   N)keras.src.api_exportr   keras.src.losses.lossesr   r   r   keras.src.metricsr   MeanMetricWrapperr   r&   r'   r   r   r   r   <module>   s      