
    ij                     >    d dl mZ  eddg       G d d             Zy)    )keras_exportzkeras.Initializerzkeras.initializers.Initializerc                   4    e Zd ZdZddZd Zed        Zd Zy)Initializera  Initializer base class: all Keras initializers inherit from this class.

    Initializers should implement a `__call__()` method with one of two possible
    signatures. If your initializer does not handle distribution layouts, it
    should use this signature:

    ```python
    def __call__(self, shape, dtype=None):
        # returns a tensor of shape `shape` and dtype `dtype`
        # containing values drawn using a function of your choice.
    ```

    If your initializer handles distribution layouts, it should use this
    signature. `layout` can either be a `keras.distribution.TensorLayout` or a
    backend-specific layout. If the given `layout` is not `None`, the returned
    value must be distributed according to `layout`.

    ```python
    def __call__(self, shape, dtype=None, layout=None):
        # returns a tensor of shape `shape`, dtype `dtype` and distributed
        # across devices according to the layout `layout`.
        # containing values drawn using a function of your choice.
    ```

    Optionally, you can also implement the method `get_config()` and the class
    method `from_config` in order to support serialization, just like with
    any Keras object.

    Here's a simple example: a random normal initializer.

    ```python
    class ExampleRandomNormal(Initializer):
        def __init__(self, mean, stddev):
            self.mean = mean
            self.stddev = stddev

        def __call__(self, shape, dtype=None):
            return keras.random.normal(
                shape, mean=self.mean, stddev=self.stddev, dtype=dtype
            )

        def get_config(self):  # To support serialization
            return {"mean": self.mean, "stddev": self.stddev}
    ```

    Note that we don't have to implement `from_config()` in the example above
    since the constructor arguments of the class the keys in the config returned
    by `get_config()` are the same. In this case, the default `from_config()`
    works fine.
    Nc                     t        d      )zReturns a tensor object initialized as specified by the initializer.

        Args:
            shape: Shape of the tensor.
            dtype: Optional dtype of the tensor.
        z>Initializer subclasses must implement the `__call__()` method.)NotImplementedError)selfshapedtypes      w/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/keras/src/initializers/initializer.py__call__zInitializer.__call__9   s     "L
 	
    c                     i S )zReturns the initializer's configuration as a JSON-serializable dict.

        Returns:
            A JSON-serializable Python dict.
         r   s    r   
get_configzInitializer.get_configD   s	     	r   c                      | di |S )a  Instantiates an initializer from a configuration dictionary.

        Example:

        ```python
        initializer = RandomUniform(-1, 1)
        config = initializer.get_config()
        initializer = RandomUniform.from_config(config)
        ```

        Args:
            config: A Python dictionary, the output of `get_config()`.

        Returns:
            An `Initializer` instance.
        r   r   )clsconfigs     r   from_configzInitializer.from_configL   s    $ }V}r   c                 T    | j                   j                  | j                               S N)	__class__r   r   r   s    r   clonezInitializer.clone`   s    ~~))$//*;<<r   r   )	__name__
__module____qualname____doc__r   r   classmethodr   r   r   r   r   r   r      s+    1f	
  &=r   r   N)keras.src.api_exportr   r   r   r   r   <module>r       s1    - "$DEF\= \= G\=r   