a
    Sic-                     @   s   d Z ddlZddlm  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 e ad
d Ze  e tj eddd ZeddddZeddd ZdS )z2Keras initializer serialization / deserialization.    N)initializers_v1)initializers_v2)generic_utils)
tf_inspect)tf2)init_ops)keras_exportc                     sz  t tdsi t_dt_tjr2tjtjj kr2dS i t_tjj t_tj	tjd< tj
tjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd	< tjtjd
< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tj
tjd< tjtjd< tjtjd< tjtjd< tjtjd< tjtjd< tjj ri } tj tj| tg fddd |  D ]$\}}|tj|< |tjt|< q|ntjjjtjjj tjjj!tjjj"j#tjjj$tjjj%tjjj&tjjj't(jt(jt(jt(jt(jt(jt(jd}| D ]$\}}|tj|< |tjt|< qtjd tjd< tjd tjd< tjd  tjd!< tjd" tjd#< dS )$z;Populates dict ALL_OBJECTS with every built-in initializer.ALL_OBJECTSN
ConstantV2GlorotNormalV2GlorotUniformV2
HeNormalV2HeUniformV2
IdentityV2LecunNormalV2LecunUniformV2OnesV2OrthogonalV2RandomNormalV2RandomUniformV2TruncatedNormalV2VarianceScalingV2ZerosV2glorot_normalV2glorot_uniformV2he_normalV2he_uniformV2lecun_normalV2lecun_uniformV2c                    s   t | ot|  S N)inspectisclass
issubclass)xbase_cls W/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/initializers/__init__.py<lambda>Y       z1populate_deserializable_objects.<locals>.<lambda>)
obj_filter)ConstantGlorotNormalGlorotUniformIdentityOnes
OrthogonalVarianceScalingZerosHeNormal	HeUniformLecunNormalLecunUniformRandomNormalRandomUniformTruncatedNormalrandom_normalnormalrandom_uniformuniformonesonezeroszero))hasattrLOCALr	   GENERATED_WITH_V2tf__internal__r   enabledr   r+   r,   r-   r3   r4   r.   r5   r6   r/   r0   r7   r8   r9   r1   r2   Initializerr   !populate_dict_with_module_objectsitemsto_snake_casecompatv1constant_initializerglorot_normal_initializerglorot_uniform_initializerinitializersidentityones_initializerorthogonal_initializervariance_scaling_initializerzeros_initializerr   )v2_objskeyvaluev1_objsr&   r$   r'   populate_deserializable_objects$   s    




r[   zkeras.initializers.serializec                 C   s
   t | S r   )r   serialize_keras_object)initializerr&   r&   r'   	serialize   s    r^   zkeras.initializers.deserializec                 C   s   t   tj| tj|ddS )z/Return an `Initializer` object from its config.r]   )module_objectscustom_objectsprintable_module_name)r[   r   deserialize_keras_objectrC   r	   )configr`   r&   r&   r'   deserialize   s    rd   zkeras.initializers.getc                 C   sh   | du rdS t | trt| S t | tr8t| } t| S t| rTt| rP|  } | S tdt|  dS )a/  Retrieve a Keras initializer by the identifier.

    The `identifier` may be the string name of a initializers function or class
    (case-sensitively).

    >>> identifier = 'Ones'
    >>> tf.keras.initializers.deserialize(identifier)
    <...keras.initializers.initializers_v2.Ones...>

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

    >>> cfg = {'class_name': 'Ones', 'config': {}}
    >>> tf.keras.initializers.deserialize(cfg)
    <...keras.initializers.initializers_v2.Ones...>

    In the case that the `identifier` is a class, this method will return a new
    instance of the class by its constructor.

    Args:
      identifier: String or dict that contains the initializer name or
        configurations.

    Returns:
      Initializer instance base on the input identifier.

    Raises:
      ValueError: If the input identifier is not a supported type or in a bad
        format.
    Nz,Could not interpret initializer identifier: )
isinstancedictrd   strcallabler    r!   
ValueError)
identifierr&   r&   r'   get   s    "



rk   )N)__doc__	threadingtensorflow.compat.v2rL   v2rE   Zkeras.initializersr   r   keras.utilsr   r   r    tensorflow.pythonr   tensorflow.python.opsr    tensorflow.python.util.tf_exportr   localrC   r[   globalsupdater	   r^   rd   rk   r&   r&   r&   r'   <module>   s&   ]
