
    6biI                        S r SSKJs  Jr  SSKJ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\" SS/SS9" \	5        \" SS	/SS9" \5        \" S
S/SS9" \5        \" S/SS9" \5        \" SS/SS9" \5        \" SS/SS9" \5        \" S/SS9" \5        \" S/SS9" \5        \" / SQS9 " S S\R                  R                  R2                  5      5       r\" / SQS9 " S S\R                  R                  R6                  5      5       r\" SS/S9 " S S\R                  R                  R:                  5      5       r\" S/S9 " S S \R                  R                  R                  5      5       r\" S!/S9 " S" S#\R                  R                  R                  5      5       r \" S$/S9 " S% S&\R                  R                  R                  5      5       r!\" S'/S9 " S( S)\R                  R                  R                  5      5       r"g)*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                   L   ^  \ rS rSrSrSSS\R                  4U 4S jjrSrU =r	$ )RandomNormal@   a  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U ]  XX4S9  g )Nmeanstddevseeddtypesuper__init__selfr   r   r   r   	__class__s        c/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/initializers/initializers_v1.pyr   RandomNormal.__init__   s    dJ     
__name__
__module____qualname____firstlineno____doc__tffloat32r   __static_attributes____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                   L   ^  \ rS rSrSrSSS\R                  4U 4S jjrSrU =r	$ )RandomUniform   a  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U ]  XX4S9  g )N)minvalmaxvalr   r   r   )r   r*   r+   r   r   r   s        r   r   RandomUniform.__init__)  s    DNr   r   r   r%   s   @r   r'   r'      s%    jX $Dt2:: O Or   r'   z"keras.initializers.TruncatedNormalz#keras.initializers.truncated_normalc                   L   ^  \ rS rSrSrSSS\R                  4U 4S jjrSrU =r	$ )TruncatedNormali-  a  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U ]  XX4S9  g)a  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   TruncatedNormal.__init__  s     	dJr   r   r   r%   s   @r   r.   r.   -  s%    l\  4rzz K Kr   r.   zkeras.initializers.lecun_normalc                   2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LecunNormali  c                 &   > [         TU ]  SSSUS9  g )N      ?fan_intruncated_normalscalemodedistributionr   r   r   r   r   s     r   r   LecunNormal.__init__      H3ED 	 	
r   c                     SU R                   0$ Nr   r   r   s    r   
get_configLecunNormal.get_config      		""r   r   Nr   r   r   r   r   rB   r#   r$   r%   s   @r   r2   r2         

# #r   r2   z keras.initializers.lecun_uniformc                   2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )LecunUniformi  c                 &   > [         TU ]  SSSUS9  g )Nr4   r5   uniformr7   r   r;   s     r   r   LecunUniform.__init__      H94 	 	
r   c                     SU R                   0$ r?   r@   rA   s    r   rB   LecunUniform.get_config  rD   r   r   rE   rF   r%   s   @r   rI   rI     rG   r   rI   zkeras.initializers.he_normalc                   2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )HeNormali  c                 &   > [         TU ]  SSSUS9  g )N       @r5   r6   r7   r   r;   s     r   r   HeNormal.__init__  r=   r   c                     SU R                   0$ r?   r@   rA   s    r   rB   HeNormal.get_config  rD   r   r   rE   rF   r%   s   @r   rQ   rQ     rG   r   rQ   zkeras.initializers.he_uniformc                   2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )	HeUniformi  c                 &   > [         TU ]  SSSUS9  g )NrS   r5   rK   r7   r   r;   s     r   r   HeUniform.__init__  rM   r   c                     SU R                   0$ r?   r@   rA   s    r   rB   HeUniform.get_config  rD   r   r   rE   rF   r%   s   @r   rX   rX     rG   r   rX   )#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.   r2   rI   rQ   rX   r   r   r   <module>ru      s&   # " ! :		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   