o
    Me[                     @   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 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)serialization)generic_utils)
tf_inspect)tf2)init_ops)keras_exportc                     sv  t tdsi t_dt_tjrtjtjj krd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|< qnIt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_OBJECTSNZ
ConstantV2ZGlorotNormalV2ZGlorotUniformV2Z
HeNormalV2ZHeUniformV2Z
IdentityV2ZLecunNormalV2ZLecunUniformV2ZOnesV2ZOrthogonalV2ZRandomNormalV2ZRandomUniformV2ZTruncatedNormalV2ZVarianceScalingV2ZZerosV2Zglorot_normalV2Zglorot_uniformV2Zhe_normalV2Zhe_uniformV2Zlecun_normalV2Zlecun_uniformV2c                    s   t | o	t|  S N)inspectisclass
issubclass)xZbase_cls KD:\Projects\ConvertPro\env\Lib\site-packages\keras/initializers/__init__.py<lambda>Z   s    z1populate_deserializable_objects.<locals>.<lambda>)Z
obj_filter)ConstantGlorotNormalGlorotUniformIdentityOnes
OrthogonalVarianceScalingZerosHeNormal	HeUniformLecunNormalLecunUniformRandomNormalRandomUniformTruncatedNormalZrandom_normalnormalZrandom_uniformuniformZonesoneZzeroszero))hasattrLOCALr
   ZGENERATED_WITH_V2tfZ__internal__r   enabledr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r   r   ZInitializerr   Z!populate_dict_with_module_objectsitemsZto_snake_casecompatv1Zconstant_initializerZglorot_normal_initializerZglorot_uniform_initializerZinitializersidentityZones_initializerZorthogonal_initializerZvariance_scaling_initializerZzeros_initializerr   )Zv2_objskeyvalueZv1_objsr   r   r   populate_deserializable_objects%   s   




r1   zkeras.initializers.serializec                 C   s
   t | S r   )r   Zserialize_keras_object)initializerr   r   r   	serialize   s   
r3   zkeras.initializers.deserializec                 C   s   t   tj| tj|ddS )z/Return an `Initializer` object from its config.r2   )Zmodule_objectscustom_objectsZprintable_module_name)r1   r   Zdeserialize_keras_objectr(   r
   )configr4   r   r   r   deserialize   s   r6   zkeras.initializers.getc                 C   sd   | du rdS t | trt| S t | trt| } t| S t| r*t| r(|  } | S tdt|  )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dictr6   strcallabler   r   
ValueError)
identifierr   r   r   get   s   "



r=   r   )__doc__	threadingZtensorflow.compat.v2r,   v2r)   Zkeras.initializersr   r   Zkeras.saving.legacyr   Zkeras.utilsr   r   r   Ztensorflow.pythonr   Ztensorflow.python.opsr   Z tensorflow.python.util.tf_exportr	   localr(   r1   globalsupdater
   r3   r6   r=   r   r   r   r   <module>   s*   ]
