
    6bi%                     @   S r SSK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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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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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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S'K$J.r.  SS(K/J0r0  SS)K/J1r1  SS*K/J2r2  SS+K/J3r3  SS,K/J4r4  SS-K/J5r5  SS.K/J6r6  SS/K/J7r7  SS0K/J8r8  SS1K/J9r9  SS2K/J:r:  SS3K/J;r;  SS4K/J<r<  SS5K/J=r=  SS6K/J>r>  SS7K?J@r@  SS8K?JArA  SS9K?JBrB  SS:K?JCrC  SS;K?JDrD  SS<K?JErE  SS=K?JFrF  SS>K?JGrG  SS?K?JHrH  SS@K?JIrI  SSAK?JJrJ  SSBK?JKrK  SSCKLJMrM  SSDKLJNrN  SSEKOJPrP  SSFKOJQrQ  SSGKOJRrR  SSHKOJSrS  SSIKOJTrT  SSJKUJVrV  SSKKUJWrW  SSLKUJXrX  SSMKUJYrY  SSNKUJZrZ  SSOKUJ[r[  \=r\r]\*=r^r_\==r`ra\;=rbrc\<=rdre\>=rfrg\:rh\9ri\" SP5      SVSQ j5       rj\" SR5      SWSS j5       rk\" ST5      SU 5       rlg)XzAll TF-Keras metrics.    N)keras_export)Mean)MeanMetricWrapper)
MeanTensor)Metric)Reduce)Sum)SumOverBatchSize)SumOverBatchSizeMetricWrapper)clone_metric)clone_metrics)serialization)deserialize_keras_object)serialize_keras_object)PyMetric)Accuracy)BinaryAccuracy)CategoricalAccuracy)SparseCategoricalAccuracy)SparseTopKCategoricalAccuracy)TopKCategoricalAccuracy)accuracy)binary_accuracy)categorical_accuracy)sparse_categorical_accuracy)!sparse_top_k_categorical_accuracy)top_k_categorical_accuracy)BinaryCrossentropy)CategoricalCrossentropy)KLDivergence)Poisson)SparseCategoricalCrossentropy)binary_crossentropy)categorical_crossentropy)poisson)kullback_leibler_divergence)sparse_categorical_crossentropy)CosineSimilarity)LogCoshError)MeanAbsoluteError)MeanAbsolutePercentageError)MeanRelativeError)MeanSquaredError)MeanSquaredLogarithmicError)RootMeanSquaredError)R2Score)cosine_similarity)logcosh)mean_absolute_error)mean_absolute_percentage_error)mean_squared_error)mean_squared_logarithmic_error)AUC)FalseNegatives)FalsePositives)	Precision)PrecisionAtRecall)Recall)RecallAtPrecision)SensitivityAtSpecificity)SensitivitySpecificityBase)SpecificityAtSensitivity)TrueNegatives)TruePositives)
FBetaScore)F1Score)	BinaryIoU)IoU)MeanIoU)	OneHotIoU)OneHotMeanIoU)CategoricalHinge)Hinge)SquaredHinge)categorical_hinge)squared_hinge)hingezkeras.metrics.serializec                     U c  g[        U [        5      (       d#  [        R                  " S[	        U 5       S35        U(       a  [
        R                  " U 5      $ [        U 5      $ )zSerializes metric function or `Metric` instance.

Args:
  metric: A TF-Keras `Metric` instance or a metric function.

Returns:
  Metric configuration dictionary.
Nz~The `keras.metrics.serialize()` API should only be used for objects of type `keras.metrics.Metric`. Found an instance of type z+, which may lead to improper serialization.)
isinstancer   warningswarntypelegacy_serializationr   )metricuse_legacy_formats     W/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/metrics/__init__.py	serializerY      s]     ~ff%%L>!LN	

 #::6BB!&))    zkeras.metrics.deserializec                 v    U(       a  [         R                  " U [        5       USS9$ [        U [        5       USS9$ )a7  Deserializes a serialized metric class/function instance.

Args:
  config: Metric configuration.
  custom_objects: Optional dictionary mapping names (strings) to custom
    objects (classes and functions) to be considered during deserialization.

Returns:
    A TF-Keras `Metric` instance or a metric function.
zmetric function)module_objectscustom_objectsprintable_module_name)rU   r   globals)configr]   rW   s      rX   deserializera      sE     #<<"9)"3	
 	
 $y%/	 rZ   zkeras.metrics.getc                     [        U [        5      (       a  SU ;  n[        XS9$ [        U [        5      (       a  [        [        U 5      5      $ [	        U 5      (       a  U $ [        SU  35      e)aI  Retrieves a TF-Keras metric as a `function`/`Metric` class instance.

The `identifier` may be the string name of a metric function or class.

>>> metric = tf.keras.metrics.get("categorical_crossentropy")
>>> type(metric)
<class 'function'>
>>> metric = tf.keras.metrics.get("CategoricalCrossentropy")
>>> type(metric)
<class '...metrics.CategoricalCrossentropy'>

You can also specify `config` of the metric to this function by passing dict
containing `class_name` and `config` as an identifier. Also note that the
`class_name` must map to a `Metric` class

>>> identifier = {"class_name": "CategoricalCrossentropy",
...               "config": {"from_logits": True}}
>>> metric = tf.keras.metrics.get(identifier)
>>> type(metric)
<class '...metrics.CategoricalCrossentropy'>

Args:
  identifier: A metric identifier. One of None or string name of a metric
    function/class or metric configuration dictionary or a metric function
    or a metric class instance

Returns:
  A TF-Keras metric as a `function`/ `Metric` class instance.

Raises:
  ValueError: If `identifier` cannot be interpreted.
module)rW   z'Could not interpret metric identifier: )rQ   dictra   strcallable
ValueError)
identifierrW   s     rX   getri      sh    D *d##$J6:KK	J	$	$3z?++	*		B:,OPPrZ   )F)NF)m__doc__rR    tensorflow.python.util.tf_exportr    tf_keras.src.metrics.base_metricr   r   r   r   r   r	   r
   r   r   r   tf_keras.src.saving.legacyr   rU   %tf_keras.src.saving.serialization_libr   r   tf_keras.src.metrics.py_metricr   %tf_keras.src.metrics.accuracy_metricsr   r   r   r   r   r   r   r   r   r   r   r   *tf_keras.src.metrics.probabilistic_metricsr   r   r    r!   r"   r#   r$   r%   r&   r'   'tf_keras.src.metrics.regression_metricsr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   &tf_keras.src.metrics.confusion_metricsr7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   $tf_keras.src.metrics.f_score_metricsrC   rD    tf_keras.src.metrics.iou_metricsrE   rF   rG   rH   rI   "tf_keras.src.metrics.hinge_metricsrJ   rK   rL   rM   rN   rO   accACCbceBCEmseMSEmaeMAEmapeMAPEmsleMSLElog_coshcosine_proximityrY   ra   ri    rZ   rX   <module>r      s     9 2 > 7 3 3 0 = J 9 : L J H 3
 ; @ E K O I : A F M S L J N C > T J O > R
 E @ E O E D O H ; E ; G R F R 7 A A < D 9 D K M K @ @ < 8 7 0 4 6 : @ 4 ; @ < 4  c c c c, ,t, ,t$  '(* )*, )* +4 !")Q #)QrZ   