o
    7?e                     @   s   d Z 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	 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 )zHinge metrics.    )utils)categorical_hinge)hinge)squared_hinge)base_metric)keras_exportzkeras.metrics.Hingec                       (   e Zd ZdZejd fdd	Z  ZS )Hingea  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 = tf.keras.metrics.Hinge()
    >>> m.update_state([[0, 1], [0, 0]], [[0.6, 0.4], [0.4, 0.6]])
    >>> m.result().numpy()
    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().numpy()
    1.1

    Usage with `compile()` API:

    ```python
    model.compile(
        optimizer='sgd', loss='mse', metrics=[tf.keras.metrics.Hinge()])
    ```
    r   Nc                       t  jt||d d S N)dtype)super__init__r   selfnamer   	__class__ `/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/keras/src/metrics/hinge_metrics.pyr   ;      zHinge.__init__)r   N__name__
__module____qualname____doc__dtensor_utilsZinject_meshr   __classcell__r   r   r   r   r	      s    r	   zkeras.metrics.SquaredHingec                       r   )SquaredHingeaC  Computes the squared 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 = tf.keras.metrics.SquaredHinge()
    >>> m.update_state([[0, 1], [0, 0]], [[0.6, 0.4], [0.4, 0.6]])
    >>> m.result().numpy()
    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().numpy()
    1.46

    Usage with `compile()` API:

    ```python
    model.compile(
        optimizer='sgd',
        loss='mse',
        metrics=[tf.keras.metrics.SquaredHinge()])
    ```
    r   Nc                    r
   r   )r   r   r   r   r   r   r   r   b   r   zSquaredHinge.__init__)r   Nr   r   r   r   r   r   @   s     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.

    Standalone usage:

    >>> m = tf.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().numpy()
    1.2

    Usage with `compile()` API:

    ```python
    model.compile(
        optimizer='sgd',
        loss='mse',
        metrics=[tf.keras.metrics.CategoricalHinge()])
    ```
    r   Nc                    r
   r   )r   r   r   r   r   r   r   r      r   zCategoricalHinge.__init__)r   Nr   r   r   r   r   r   g   s    r   N)r   Zkeras.src.dtensorr   r   Zkeras.src.lossesr   r   r   Zkeras.src.metricsr   Z tensorflow.python.util.tf_exportr   ZMeanMetricWrapperr	   r   r   r   r   r   r   <module>   s   $&