
    0hI                     N   d Z ddlmc mZ ddlmZ ej                  j                  j                  Z	ej                  j                  j                  Zej                  j                  j                  Zej                  j                  j                  Zej                  j                  j                   Zej                  j                  j$                  j&                  Zej                  j                  j*                  Zej                  j                  j.                  Z  eddgd      e	         edd	gd      e         ed
dgd      e         edgd      e         eddgd      e         eddgd      e         edgd      e         edgd      e        eg d       G d dej                  j                  j2                               Z eg d       G d dej                  j                  j6                               Z eddg       G d dej                  j                  j:                               Z edg       G d d ej                  j                  j                               Z ed!g       G d" d#ej                  j                  j                               Z  ed$g       G d% d&ej                  j                  j                               Z! ed'g       G d( d)ej                  j                  j                               Z"y)*zKeras initializers for TF 1.    N)keras_exportzkeras.initializers.Zeroszkeras.initializers.zerosT)v1allow_multiple_exportszkeras.initializers.Oneszkeras.initializers.oneszkeras.initializers.Constantzkeras.initializers.constantz"keras.initializers.VarianceScalingzkeras.initializers.Orthogonalzkeras.initializers.orthogonalzkeras.initializers.Identityzkeras.initializers.identityz!keras.initializers.glorot_uniformz keras.initializers.glorot_normal)zkeras.initializers.RandomNormalz keras.initializers.random_normalzkeras.initializers.normal)r   c                   @     e Zd ZdZdddej
                  f fd	Z xZS )RandomNormala  Initializer that generates a normal distribution.

    Args:
      mean: a python scalar or a scalar tensor. Mean of the random values to
        generate.
      stddev: a python scalar or a scalar tensor. Standard deviation of the
        random values to generate.
      seed: A Python integer. Used to create random seeds. See
        `tf.compat.v1.set_random_seed` for behavior.
      dtype: Default data type, used if no `dtype` argument is provided when
        calling the initializer. Only floating point types are supported.

    @compatibility(TF2)
    Although it is a legacy compat.v1 api,
    `tf.compat.v1.keras.initializers.RandomNormal` is compatible with eager
    execution and `tf.function`.

    To switch to native TF2, switch to using
    `tf.keras.initializers.RandomNormal` (not from `compat.v1`) and
    if you need to change the default dtype use
    `tf.keras.backend.set_floatx(float_dtype)`
    or pass the dtype when calling the initializer, rather than passing it
    when constructing the initializer.

    Random seed behavior:
    Also be aware that if you pass a seed to the TF2 initializer
    API it will reuse that same seed for every single initialization
    (unlike the TF1 initializer)

    #### Structural Mapping to Native TF2

    Before:

    ```python
    initializer = tf.compat.v1.keras.initializers.RandomNormal(
      mean=mean,
      stddev=stddev,
      seed=seed,
      dtype=dtype)

    weight_one = tf.Variable(initializer(shape_one))
    weight_two = tf.Variable(initializer(shape_two))
    ```

    After:

    ```python
    initializer = tf.keras.initializers.RandomNormal(
      mean=mean,
      # seed=seed,  # Setting a seed in the native TF2 API
                    # causes it to produce the same initializations
                    # across multiple calls of the same initializer.
      stddev=stddev)

    weight_one = tf.Variable(initializer(shape_one, dtype=dtype))
    weight_two = tf.Variable(initializer(shape_two, dtype=dtype))
    ```

    #### How to Map Arguments

    | TF1 Arg Name      | TF2 Arg Name    | Note                       |
    | :---------------- | :-------------- | :------------------------- |
    | `mean`            | `mean`          | No change to defaults |
    | `stddev`          | `stddev`        | No change to defaults |
    | `seed`            | `seed`          | Different random number generation |
    :                   :        : semantics (to change in a :
    :                   :        : future version). If set, the TF2 version :
    :                   :        : will use stateless random number :
    :                   :        : generation which will produce the exact :
    :                   :        : same initialization even across multiple :
    :                   :        : calls of the initializer instance. the :
    :                   :        : `compat.v1` version will generate new :
    :                   :        : initializations each time. Do not set :
    :                   :        : a seed if you need different          :
    :                   :        : initializations each time. Instead    :
    :                   :        : either set a global tf seed with      :
    :                   :        : `tf.random.set_seed` if you need      :
    :                   :        : determinism, or initialize each weight:
    :                   :        : with a separate initializer instance  :
    :                   :        : and a different seed.                 :
    | `dtype`           | `dtype`  | The TF2 native api only takes it    |
    :                   :      : as a `__call__` arg, not a constructor arg. :
    | `partition_info`  | -    |  (`__call__` arg in TF1) Not supported      |

    #### Example of fixed-seed behavior differences

    `compat.v1` Fixed seed behavior:

    >>> initializer = tf.compat.v1.keras.initializers.RandomNormal(seed=10)
    >>> a = initializer(shape=(2, 2))
    >>> b = initializer(shape=(2, 2))
    >>> tf.reduce_sum(a - b) == 0
    <tf.Tensor: shape=(), dtype=bool, numpy=False>

    After:

    >>> initializer = tf.keras.initializers.RandomNormal(seed=10)
    >>> a = initializer(shape=(2, 2))
    >>> b = initializer(shape=(2, 2))
    >>> tf.reduce_sum(a - b) == 0
    <tf.Tensor: shape=(), dtype=bool, numpy=True>

    @end_compatibility
            皙?Nc                 ,    t         |   ||||       y )Nmeanstddevseeddtypesuper__init__selfr   r   r   r   	__class__s        c/var/www/html/engine/venv/lib/python3.12/site-packages/tf_keras/src/initializers/initializers_v1.pyr   zRandomNormal.__init__   s    d6EJ    __name__
__module____qualname____doc__tffloat32r   __classcell__r   s   @r   r   r   @   s%    gR  4rzz K Kr   r   )z keras.initializers.RandomUniformz!keras.initializers.random_uniformzkeras.initializers.uniformc                   @     e Zd ZdZdddej
                  f fd	Z xZS )RandomUniforma?  Initializer that generates tensors with a uniform distribution.

    Args:
      minval: A python scalar or a scalar tensor. Lower bound of the range of
        random values to generate. Defaults to `-0.05`.
      maxval: A python scalar or a scalar tensor. Upper bound of the range of
        random values to generate. Defaults to `0.05`.
      seed: A Python integer. Used to create random seeds. See
        `tf.compat.v1.set_random_seed` for behavior.
      dtype: Default data type, used if no `dtype` argument is provided when
        calling the initializer.

    @compatibility(TF2)
    Although it is a legacy `compat.v1` api,
    `tf.compat.v1.keras.initializers.RandomUniform` is compatible with eager
    execution and `tf.function`.

    To switch to native TF2, switch to using
    `tf.keras.initializers.RandomUniform` (not from `compat.v1`) and
    if you need to change the default dtype use
    `tf.keras.backend.set_floatx(float_dtype)`
    or pass the dtype when calling the initializer, rather than passing it
    when constructing the initializer.

    Random seed behavior:

    Also be aware that if you pass a seed to the TF2 initializer
    API it will reuse that same seed for every single initialization
    (unlike the TF1 initializer)

    #### Structural Mapping to Native TF2

    Before:

    ```python

    initializer = tf.compat.v1.keras.initializers.RandomUniform(
      minval=minval,
      maxval=maxval,
      seed=seed,
      dtype=dtype)

    weight_one = tf.Variable(initializer(shape_one))
    weight_two = tf.Variable(initializer(shape_two))
    ```

    After:

    ```python
    initializer = tf.keras.initializers.RandomUniform(
      minval=minval,
      maxval=maxval,
      # seed=seed,  # Setting a seed in the native TF2 API
                    # causes it to produce the same initializations
                    # across multiple calls of the same initializer.
      )

    weight_one = tf.Variable(initializer(shape_one, dtype=dtype))
    weight_two = tf.Variable(initializer(shape_two, dtype=dtype))
    ```

    #### How to Map Arguments

    | TF1 Arg Name      | TF2 Arg Name    | Note                       |
    | :---------------- | :-------------- | :------------------------- |
    | `minval`            | `minval`          | No change to defaults |
    | `maxval`          | `maxval`        | No change to defaults |
    | `seed`            | `seed`          | Different random number generation |
    :                    :        : semantics (to change in a :
    :                    :        : future version). If set, the TF2 version :
    :                    :        : will use stateless random number :
    :                    :        : generation which will produce the exact :
    :                    :        : same initialization even across multiple :
    :                    :        : calls of the initializer instance. the :
    :                    :        : `compat.v1` version will generate new :
    :                    :        : initializations each time. Do not set :
    :                    :        : a seed if you need different          :
    :                    :        : initializations each time. Instead    :
    :                    :        : either set a global tf seed with
    :                    :        : `tf.random.set_seed` if you need :
    :                    :        : determinism, or initialize each weight :
    :                    :        : with a separate initializer instance  :
    :                    :        : and a different seed.                 :
    | `dtype`           | `dtype`  | The TF2 native api only takes it  |
    :                   :      : as a `__call__` arg, not a constructor arg. :
    | `partition_info`  | -    |  (`__call__` arg in TF1) Not supported      |

    #### Example of fixed-seed behavior differences

    `compat.v1` Fixed seed behavior:

    >>> initializer = tf.compat.v1.keras.initializers.RandomUniform(seed=10)
    >>> a = initializer(shape=(2, 2))
    >>> b = initializer(shape=(2, 2))
    >>> tf.reduce_sum(a - b) == 0
    <tf.Tensor: shape=(), dtype=bool, numpy=False>

    After:

    >>> initializer = tf.keras.initializers.RandomUniform(seed=10)
    >>> a = initializer(shape=(2, 2))
    >>> b = initializer(shape=(2, 2))
    >>> tf.reduce_sum(a - b) == 0
    <tf.Tensor: shape=(), dtype=bool, numpy=True>

    @end_compatibility
    gr	   Nc                 ,    t         |   ||||       y )N)minvalmaxvalr   r   r   )r   r$   r%   r   r   r   s        r   r   zRandomUniform.__init__)  s    vDNr   r   r    s   @r   r"   r"      s%    jX $Dt2:: O Or   r"   z"keras.initializers.TruncatedNormalz#keras.initializers.truncated_normalc                   @     e Zd ZdZdddej
                  f fd	Z xZS )TruncatedNormala  Initializer that generates a truncated normal distribution.

    These values are similar to values from a `random_normal_initializer`
    except that values more than two standard deviations from the mean
    are discarded and re-drawn. This is the recommended initializer for
    neural network weights and filters.

    Args:
      mean: a python scalar or a scalar tensor. Mean of the random values to
        generate.
      stddev: a python scalar or a scalar tensor. Standard deviation of the
        random values to generate.
      seed: A Python integer. Used to create random seeds. See
        `tf.compat.v1.set_random_seed` for behavior.
      dtype: Default data type, used if no `dtype` argument is provided when
        calling the initializer. Only floating point types are supported.

    @compatibility(TF2)
    Although it is a legacy compat.v1 api,
    `tf.compat.v1.keras.initializers.TruncatedNormal` is compatible with eager
    execution and `tf.function`.

    To switch to native TF2, switch to using
    `tf.keras.initializers.TruncatedNormal` (not from `compat.v1`) and
    if you need to change the default dtype use
    `tf.keras.backend.set_floatx(float_dtype)`
    or pass the dtype when calling the initializer, rather than passing it
    when constructing the initializer.

    Random seed behavior:
    Also be aware that if you pass a seed to the TF2 initializer
    API it will reuse that same seed for every single initialization
    (unlike the TF1 initializer)

    #### Structural Mapping to Native TF2

    Before:

    ```python
    initializer = tf.compat.v1.keras.initializers.TruncatedNormal(
      mean=mean,
      stddev=stddev,
      seed=seed,
      dtype=dtype)

    weight_one = tf.Variable(initializer(shape_one))
    weight_two = tf.Variable(initializer(shape_two))
    ```

    After:

    ```python
    initializer = tf.keras.initializers.TruncatedNormal(
      mean=mean,
      # seed=seed,  # Setting a seed in the native TF2 API
                    # causes it to produce the same initializations
                    # across multiple calls of the same initializer.
      stddev=stddev)

    weight_one = tf.Variable(initializer(shape_one, dtype=dtype))
    weight_two = tf.Variable(initializer(shape_two, dtype=dtype))
    ```

    #### How to Map Arguments

    | TF1 Arg Name      | TF2 Arg Name    | Note                       |
    | :---------------- | :-------------- | :------------------------- |
    | `mean`            | `mean`          | No change to defaults |
    | `stddev`          | `stddev`        | No change to defaults |
    | `seed`            | `seed`          | Different random number generation |
    :                    :        : semantics (to change in a :
    :                    :        : future version). If set, the TF2 version :
    :                    :        : will use stateless random number :
    :                    :        : generation which will produce the exact :
    :                    :        : same initialization even across multiple :
    :                    :        : calls of the initializer instance. the :
    :                    :        : `compat.v1` version will generate new :
    :                    :        : initializations each time. Do not set :
    :                    :        : a seed if you need different          :
    :                    :        : initializations each time. Instead    :
    :                    :        : either set a global tf seed with
    :                    :        : `tf.random.set_seed` if you need :
    :                    :        : determinism, or initialize each weight :
    :                    :        : with a separate initializer instance  :
    :                    :        : and a different seed.                 :
    | `dtype`           | `dtype`  | The TF2 native api only takes it  |
    :                   :      : as a `__call__` arg, not a constructor arg. :
    | `partition_info`  | -    |  (`__call__` arg in TF1) Not supported      |

    #### Example of fixed-seed behavior differences

    `compat.v1` Fixed seed behavior:

    >>> initializer = tf.compat.v1.keras.initializers.TruncatedNormal(seed=10)
    >>> a = initializer(shape=(2, 2))
    >>> b = initializer(shape=(2, 2))
    >>> tf.reduce_sum(a - b) == 0
    <tf.Tensor: shape=(), dtype=bool, numpy=False>

    After:

    >>> initializer = tf.keras.initializers.TruncatedNormal(seed=10)
    >>> a = initializer(shape=(2, 2))
    >>> b = initializer(shape=(2, 2))
    >>> tf.reduce_sum(a - b) == 0
    <tf.Tensor: shape=(), dtype=bool, numpy=True>

    @end_compatibility
    r   r	   Nc                 ,    t         |   ||||       y)aM  Initializer that generates a truncated normal distribution.


        Args:
          mean: a python scalar or a scalar tensor. Mean of the random values to
            generate.
          stddev: a python scalar or a scalar tensor. Standard deviation of the
            random values to generate.
          seed: A Python integer. Used to create random seeds. See
            `tf.compat.v1.set_random_seed` for behavior.
          dtype: Default data type, used if no `dtype` argument is provided when
            calling the initializer. Only floating point types are supported.
        r   Nr   r   s        r   r   zTruncatedNormal.__init__  s     	d6EJr   r   r    s   @r   r'   r'   -  s%    l\  4rzz K Kr   r'   zkeras.initializers.lecun_normalc                   &     e Zd Zd fd	Zd Z xZS )LecunNormalc                 ,    t         |   ddd|       y )N      ?fan_intruncated_normalscalemodedistributionr   r   r   r   r   s     r   r   zLecunNormal.__init__      H3ED 	 	
r   c                     d| j                   iS Nr   r   r   s    r   
get_configzLecunNormal.get_config      		""r   Nr   r   r   r   r9   r   r    s   @r   r*   r*         

#r   r*   z keras.initializers.lecun_uniformc                   &     e Zd Zd fd	Zd Z xZS )LecunUniformc                 ,    t         |   ddd|       y )Nr,   r-   uniformr/   r   r3   s     r   r   zLecunUniform.__init__      H94 	 	
r   c                     d| j                   iS r6   r7   r8   s    r   r9   zLecunUniform.get_config  r:   r   r;   r<   r    s   @r   r?   r?     r=   r   r?   zkeras.initializers.he_normalc                   &     e Zd Zd fd	Zd Z xZS )HeNormalc                 ,    t         |   ddd|       y )N       @r-   r.   r/   r   r3   s     r   r   zHeNormal.__init__  r4   r   c                     d| j                   iS r6   r7   r8   s    r   r9   zHeNormal.get_config  r:   r   r;   r<   r    s   @r   rE   rE     r=   r   rE   zkeras.initializers.he_uniformc                   &     e Zd Zd fd	Zd Z xZS )	HeUniformc                 ,    t         |   ddd|       y )NrG   r-   rA   r/   r   r3   s     r   r   zHeUniform.__init__  rB   r   c                     d| j                   iS r6   r7   r8   s    r   r9   zHeUniform.get_config  r:   r   r;   r<   r    s   @r   rJ   rJ     r=   r   rJ   )#r   tensorflow.compat.v2compatv2r    tensorflow.python.util.tf_exportr   r   zeros_initializer_v1_zeros_initializerones_initializer_v1_ones_initializerconstant_initializer_v1_constant_initializervariance_scaling_initializer _v1_variance_scaling_initializerorthogonal_initializer_v1_orthogonal_initializerinitializersidentity_v1_identityglorot_uniform_initializer_v1_glorot_uniform_initializerglorot_normal_initializer_v1_glorot_normal_initializerrandom_normal_initializerr   random_uniform_initializerr"   truncated_normal_initializerr'   r*   r?   rE   rJ    r   r   <module>rf      s6   # " ! :		66 yy||44 99<<<< #%99<<#L#L  YY\\@@ yy||((11!#!H!H  "		 F F "$>? !#<= %'DE ,-d"$')HI %'DE +,T "*+D!
 kK299<<99 kKkK\ nOBIILL;; nOnOb ,-}Kbiill?? }K}K@ 345#")),,;; # 6# 456#299<<<< # 7# 012#ryy||88 # 3# 123#		99 # 4#r   