
    2Vh                        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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/l1m2Z2 h eeeeeee	e
eeeeeeeeeeeeeeee'e-eeeee.e+e)e*e,e"e(e&e%e/e e$e0e!e#Z3e3D  ci c]  } | jh                  |  c} Z5e5jm                  eee'e'e)e)e+e+e*e*e,e,d0        ed1      d2        Z7 ed3      d7d4       Z8 ed5      d6        Z9yc c} w )8    N)keras_export)Loss)CTC)BinaryCrossentropy)BinaryFocalCrossentropy)CategoricalCrossentropy)CategoricalFocalCrossentropy)CategoricalHinge)Circle)CosineSimilarity)Dice)Hinge)Huber)KLDivergence)LogCosh)LossFunctionWrapper)MeanAbsoluteError)MeanAbsolutePercentageError)MeanSquaredError)MeanSquaredLogarithmicError)Poisson)SparseCategoricalCrossentropy)SquaredHinge)Tversky)binary_crossentropy)binary_focal_crossentropy)categorical_crossentropy)categorical_focal_crossentropy)categorical_hinge)circle)cosine_similarity)ctc)dice)hinge)huber)kl_divergence)log_cosh)mean_absolute_error)mean_absolute_percentage_error)mean_squared_error)mean_squared_logarithmic_error)poisson)sparse_categorical_crossentropy)squared_hinge)tversky)serialization_lib)bceBCEkldKLDmaeMAEmseMSEmapeMAPEmsleMSLEzkeras.losses.serializec                 ,    t        j                  |       S )zSerializes loss function or `Loss` instance.

    Args:
        loss: A Keras `Loss` instance or a loss function.

    Returns:
        Loss configuration dictionary.
    )r0   serialize_keras_object)losss    I/home/dcms/DCMS/lib/python3.12/site-packages/keras/src/losses/__init__.py	serializerA      s     33D99    zkeras.losses.deserializec                 :    t        j                  | t        |      S )aZ  Deserializes a serialized loss class/function instance.

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

    Returns:
        A Keras `Loss` instance or a loss function.
    )module_objectscustom_objects)r0   deserialize_keras_objectALL_OBJECTS_DICT)namerE   s     r@   deserializerI      s      55'% rB   zkeras.losses.getc                     | yt        | t              rt        |       }n)t        | t              rt        j                  | d      }n| }t        |      rt        j                  |      r |       }|S t        d|        )a  Retrieves a Keras loss as a `function`/`Loss` class instance.

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

    >>> loss = losses.get("categorical_crossentropy")
    >>> type(loss)
    <class 'function'>
    >>> loss = losses.get("CategoricalCrossentropy")
    >>> type(loss)
    <class '...CategoricalCrossentropy'>

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

    >>> identifier = {"class_name": "CategoricalCrossentropy",
    ...               "config": {"from_logits": True}}
    >>> loss = losses.get(identifier)
    >>> type(loss)
    <class '...CategoricalCrossentropy'>

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

    Returns:
        A Keras loss as a `function`/ `Loss` class instance.
    Nz%Could not interpret loss identifier: )

isinstancedictrI   strrG   getcallableinspectisclass
ValueError)
identifierobjs     r@   rN   rN      st    > *d#*%	J	$"":t4}??3%C
@MNNrB   )N):rP   keras.src.api_exportr   keras.src.losses.lossr   keras.src.losses.lossesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   keras.src.savingr0   ALL_OBJECTS__name__rG   updaterA   rI   rN   )clss   0r@   <module>r]      s#    - & ' 6 ; ; @ 4 * 4 ( ) ) 0 + 7 5 ? 4 ? + A 0 + 7 = < B 5 * 5 ' ( ) ) 1 , 7 B 6 B + C 1 + .:: :
 : : : : : !: ": : :  :   !:" #:$ %:& 
':* 
+:, -:. /:2 	3:4 5:8 9:< =:@ A:B C:D E:F G:H I:J #K:L $M:P Q:R S:T #U:V #W:X Y:Z [:\ 
]:` 
a:b c:d e:h 	i:j k:n o:r s:x 2==#CLL#%=    """"!!....$ &'	: (	: () *&  !,O ",Ok >s   7G