
    6bi$                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  \" S5       " S	 S
\	R                  5      5       r\" S5       " S S\	R                  5      5       r\" S5       " S S\	R                  5      5       rg)zHinge metrics.    )utils)categorical_hinge)hinge)squared_hinge)base_metric)keras_exportzkeras.metrics.Hingec                   N   ^  \ rS rSrSr\R                  SU 4S jj5       rSrU =r	$ )Hinge   a  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()])
```
c                 *   > [         TU ]  [        XS9  g N)dtype)super__init__r   selfnamer   	__class__s      \/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/metrics/hinge_metrics.pyr   Hinge.__init__;   s    2     )r   N
__name__
__module____qualname____firstlineno____doc__dtensor_utilsinject_meshr   __static_attributes____classcell__r   s   @r   r
   r
      s"    < 3 3r   r
   zkeras.metrics.SquaredHingec                   N   ^  \ rS rSrSr\R                  SU 4S jj5       rSrU =r	$ )SquaredHinge@   a  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()])
```
c                 *   > [         TU ]  [        XS9  g r   )r   r   r   r   s      r   r   SquaredHinge.__init__b   s    :r   r   )r   Nr   r#   s   @r   r%   r%   @   s#    @ ; ;r   r%   zkeras.metrics.CategoricalHingec                   N   ^  \ rS rSrSr\R                  SU 4S jj5       rSrU =r	$ )CategoricalHingeg   a  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()])
```
c                 *   > [         TU ]  [        XS9  g r   )r   r   r   r   s      r   r   CategoricalHinge.__init__   s    *D>r   r   )r   Nr   r#   s   @r   r*   r*   g   s"    : ? ?r   r*   N)r   tf_keras.src.dtensorr   r   tf_keras.src.lossesr   r   r   tf_keras.src.metricsr    tensorflow.python.util.tf_exportr   MeanMetricWrapperr
   r%   r*   r   r   r   <module>r3      s     7 1 % - , : #$!3K)) !3 %!3H *+#;;00 #; ,#;L ./ ?{44  ? 0 ?r   