
    ~Wh                      *   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
e	j                              Z ed           G d de	j                              Z ed           G 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	            Z x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                 Z    t                                          t          ||           d S N)dtype)super__init__r   selfnamer   	__class__s      a/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/keras/metrics/hinge_metrics.pyr   zHinge.__init__;   s(    E22222    )r   N__name__
__module____qualname____doc__dtensor_utilsinject_meshr   __classcell__r   s   @r   r
   r
      sW         < 3 3 3 3 3 3 3 3 3 3r   r
   zkeras.metrics.SquaredHingec                   >     e Zd ZdZej        d fd	            Z xZS )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                 Z    t                                          t          ||           d S r   )r   r   r   r   s      r   r   zSquaredHinge.__init__b   s(    E:::::r   )r   Nr   r   s   @r   r    r    @   sX         @ ; ; ; ; ; ; ; ; ; ;r   r    zkeras.metrics.CategoricalHingec                   >     e Zd ZdZej        d f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.

    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                 Z    t                                          t          ||           d S r   )r   r   r   r   s      r   r   zCategoricalHinge.__init__   s)    *D>>>>>r   )r   Nr   r   s   @r   r#   r#   g   sW         : ? ? ? ? ? ? ? ? ? ?r   r#   N)r   keras.dtensorr   r   keras.lossesr   r   r   keras.metricsr    tensorflow.python.util.tf_exportr   MeanMetricWrapperr
   r    r#    r   r   <module>r+      sV     0 0 0 0 0 0 * * * * * *       & & & & & & % % % % % % : 9 9 9 9 9 #$$!3 !3 !3 !3 !3K) !3 !3 %$!3H *++#; #; #; #; #;;0 #; #; ,+#;L .// ?  ?  ?  ?  ?{4  ?  ? 0/ ?  ?  ?r   