o
    7?e$                     @   s  d Z ddl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	 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 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 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  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' 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- dd'l$m.Z. dd(l/m0Z0 dd)l/m1Z1 dd*l/m2Z2 dd+l/m3Z3 dd,l/m4Z4 dd-l/m5Z5 dd.l/m6Z6 dd/l/m7Z7 dd0l/m8Z8 dd1l/m9Z9 dd2l/m:Z: dd3l/m;Z; dd4l/m<Z< dd5l/m=Z= dd6l/m>Z> dd7l?m@Z@ dd8l?mAZA dd9l?mBZB dd:l?mCZC dd;l?mDZD dd<l?mEZE dd=l?mFZF dd>l?mGZG dd?l?mHZH dd@l?mIZI ddAl?mJZJ ddBl?mKZK ddClLmMZM ddDlLmNZN ddElOmPZP ddFlOmQZQ ddGlOmRZR ddHlOmSZS ddIlOmTZT ddJlUmVZV ddKlUmWZW ddLlUmXZX ddMlUmYZY ddNlUmZZZ ddOlUm[Z[ e Z\Z]e* Z^Z_e= Z`Zae; ZbZce< ZdZee> ZfZge:Zhe9ZiedPdZdRdSZjedTd[dUdVZkedWdXdY ZldS )\zAll 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.serializeFc                 C   sB   | du rdS t | tstdt|  d |rt| S t| S )zSerializes metric function or `Metric` instance.

    Args:
      metric: A 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   )Zmetricuse_legacy_format rU   [/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/keras/src/metrics/__init__.py	serialize   s   


rW   zkeras.metrics.deserializec                 C   s*   |rt j| t |ddS t| t |ddS )aP  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 Keras `Metric` instance or a metric function.
    zmetric function)Zmodule_objectscustom_objectsZprintable_module_name)rS   r   globals)configrX   rT   rU   rU   rV   deserialize   s   r[   zkeras.metrics.getc                 C   sN   t | trd| v}t| |dS t | trtt| S t| r | S td|  )a  Retrieves a 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 Keras metric as a `function`/ `Metric` class instance.

    Raises:
      ValueError: If `identifier` cannot be interpreted.
    module)rT   z'Could not interpret metric identifier: )rO   dictr[   strcallable
ValueError)
identifierrT   rU   rU   rV   get   s   
"
rb   )F)NF)m__doc__rP   Z tensorflow.python.util.tf_exportr   Zkeras.src.metrics.base_metricr   r   r   r   r   r   r	   r
   r   r   Zkeras.src.saving.legacyr   rS   Z"keras.src.saving.serialization_libr   r   Zkeras.src.metrics.py_metricr   Z"keras.src.metrics.accuracy_metricsr   r   r   r   r   r   r   r   r   r   r   r   Z'keras.src.metrics.probabilistic_metricsr   r   r   r    r!   r"   r#   r$   r%   r&   Z$keras.src.metrics.regression_metricsr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   Z#keras.src.metrics.confusion_metricsr6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   Z!keras.src.metrics.f_score_metricsrB   rC   Zkeras.src.metrics.iou_metricsrD   rE   rF   rG   rH   Zkeras.src.metrics.hinge_metricsrI   rJ   rK   rL   rM   rN   accZACCZbceZBCEZmseZMSEZmaeZMAEZmapeZMAPEZmsleZMSLEZlog_coshZcosine_proximityrW   r[   rb   rU   rU   rU   rV   <module>   s   