B
    )`yf                 @   sj  d 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d
G dd deZeddg dG dd dejeZeddg dG dd dejeZeddg dG dd deZeddg dG dd dejeZeddg dG d d! d!ejeZed"d#g dG d$d% d%ejeZed&d'g dG d(d) d)ejeZed*d+g dG d,d- d-ejeZed.d/g dG d0d1 d1ejeZed2d3g dG d4d5 d5eZed6d7g dG d8d9 d9eZed:d;g dG d<d= d=eZed>d?g dG d@dA dAeZedBdCg dG dDdE dEeZedFdGg dG dHdI dIeZdJdK ZdLS )MzKeras initializers for TF 2.
    )absolute_import)division)print_function)constant_op)dtypes)backend)init_ops_v2)keras_exportzkeras.initializers.Initializerc               @   s.   e Zd ZdZd	ddZdd Zedd ZdS )
Initializera  Initializer base class: all Keras initializers inherit from this class.

  Initializers should implement a `__call__` method with the following
  signature:

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

  Optionally, you an 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
  import tensorflow as tf

  class ExampleRandomNormal(tf.keras.initializers.Initializer):

    def __init__(self, mean, stddev):
      self.mean = mean
      self.stddev = stddev

    def __call__(self, shape, dtype=None)`:
      return tf.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             C   s   t dS )zReturns a tensor object initialized as specified by the initializer.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor.
    N)NotImplementedError)selfshapedtype r   c/home/dcms/DCMS/lib/python3.7/site-packages/tensorflow/python/keras/initializers/initializers_v2.py__call__G   s    zInitializer.__call__c             C   s   i S )zReturns the configuration of the initializer as a JSON-serializable dict.

    Returns:
      A JSON-serializable Python dict.
    r   )r   r   r   r   
get_configP   s    zInitializer.get_configc             C   s   | dd | f |S )au  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:
      A `tf.keras.initializers.Initializer` instance.
    r   N)pop)clsconfigr   r   r   from_configX   s    zInitializer.from_config)N)__name__
__module____qualname____doc__r   r   classmethodr   r   r   r   r   r
      s   (
	r
   zkeras.initializers.Zeroszkeras.initializers.zeros)Zv1c                   s"   e Zd ZdZd fdd	Z  ZS )Zerosa  Initializer that generates tensors initialized to 0.

  Also available via the shortcut function `tf.keras.initializers.zeros`.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.Zeros()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.Zeros()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)
  Nc                s   t t| j|t|dS )a  Returns a tensor object initialized as specified by the initializer.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only numeric or boolean dtypes are
       supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`).
    )r   )superr   r   
_get_dtype)r   r   r   )	__class__r   r   r      s    
zZeros.__call__)N)r   r   r   r   r   __classcell__r   r   )r   r   r   n   s   r   zkeras.initializers.Oneszkeras.initializers.onesc                   s"   e Zd ZdZd fdd	Z  ZS )Onesa  Initializer that generates tensors initialized to 1.

  Also available via the shortcut function `tf.keras.initializers.ones`.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.Ones()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.Ones()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)
  Nc                s   t t| j|t|dS )a  Returns a tensor object initialized as specified by the initializer.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only numeric or boolean dtypes are
       supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`).
    )r   )r   r!   r   r   )r   r   r   )r   r   r   r      s    
zOnes.__call__)N)r   r   r   r   r   r    r   r   )r   r   r!      s   r!   zkeras.initializers.Constantzkeras.initializers.constantc               @   s,   e Zd ZdZd
ddZdddZdd	 ZdS )Constantaa  Initializer that generates tensors with constant values.

  Also available via the shortcut function `tf.keras.initializers.constant`.

  Only scalar values are allowed.
  The constant value provided must be convertible to the dtype requested
  when calling the initializer.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.Constant(3.)
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.Constant(3.)
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    value: A Python scalar.
  r   c             C   s
   || _ d S )N)value)r   r#   r   r   r   __init__   s    zConstant.__init__Nc             C   s   t j| jt||dS )aM  Returns a tensor object initialized to `self.value`.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. If not specified,
       `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`).
    )r   r   )r   Zconstantr#   r   )r   r   r   r   r   r   r      s    
zConstant.__call__c             C   s
   d| j iS )Nr#   )r#   )r   r   r   r   r      s    zConstant.get_config)r   )N)r   r   r   r   r$   r   r   r   r   r   r   r"      s   

r"   z keras.initializers.RandomUniformz!keras.initializers.random_uniformc                   s"   e Zd ZdZd fdd	Z  ZS )RandomUniforma{  Initializer that generates tensors with a uniform distribution.

  Also available via the shortcut function
  `tf.keras.initializers.random_uniform`.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.RandomUniform(minval=0., maxval=1.)
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.RandomUniform(minval=0., maxval=1.)
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    minval: A python scalar or a scalar tensor. Lower bound of the range of
      random values to generate (inclusive).
    maxval: A python scalar or a scalar tensor. Upper bound of the range of
      random values to generate (exclusive).
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.
  Nc                s   t t| j|t|dS )a  Returns a tensor object initialized as specified by the initializer.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only floating point and integer
      types are supported. If not specified,
        `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`).
    )r   )r   r%   r   r   )r   r   r   )r   r   r   r      s    zRandomUniform.__call__)N)r   r   r   r   r   r    r   r   )r   r   r%      s   r%   zkeras.initializers.RandomNormalz keras.initializers.random_normalc                   s"   e Zd ZdZd fdd	Z  ZS )RandomNormalaG  Initializer that generates tensors with a normal distribution.

  Also available via the shortcut function
  `tf.keras.initializers.random_normal`.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.RandomNormal(mean=0., stddev=1.)
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.RandomNormal(mean=0., stddev=1.)
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  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. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.
  Nc                s   t t| j|t|dS )a}  Returns a tensor object initialized to random normal values.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only floating point types are
       supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`)
    )r   )r   r&   r   r   )r   r   r   )r   r   r   r     s    
zRandomNormal.__call__)N)r   r   r   r   r   r    r   r   )r   r   r&     s   r&   z"keras.initializers.TruncatedNormalz#keras.initializers.truncated_normalc                   s"   e Zd ZdZd fdd	Z  ZS )TruncatedNormala  Initializer that generates a truncated normal distribution.

  Also available via the shortcut function
  `tf.keras.initializers.truncated_normal`.

  The values generated are similar to values from a
  `tf.keras.initializers.RandomNormal` initializer except that values more
  than two standard deviations from the mean are
  discarded and re-drawn.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.TruncatedNormal(mean=0., stddev=1.)
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.TruncatedNormal(mean=0., stddev=1.)
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  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. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.
  Nc                s   t t| j|t|dS )a  Returns a tensor object initialized to random normal values (truncated).

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only floating point types are
       supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`)
    )r   )r   r'   r   r   )r   r   r   )r   r   r   r   L  s    
zTruncatedNormal.__call__)N)r   r   r   r   r   r    r   r   )r   r   r'   +  s   r'   z"keras.initializers.VarianceScalingz#keras.initializers.variance_scalingc                   s"   e Zd ZdZd fdd	Z  ZS )VarianceScalinga  Initializer capable of adapting its scale to the shape of weights tensors.

  Also available via the shortcut function
  `tf.keras.initializers.variance_scaling`.

  With `distribution="truncated_normal" or "untruncated_normal"`, samples are
  drawn from a truncated/untruncated normal distribution with a mean of zero and
  a standard deviation (after truncation, if used) `stddev = sqrt(scale / n)`,
  where `n` is:

  - number of input units in the weight tensor, if `mode="fan_in"`
  - number of output units, if `mode="fan_out"`
  - average of the numbers of input and output units, if `mode="fan_avg"`

  With `distribution="uniform"`, samples are drawn from a uniform distribution
  within `[-limit, limit]`, where `limit = sqrt(3 * scale / n)`.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.VarianceScaling(
  ... scale=0.1, mode='fan_in', distribution='uniform')
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.VarianceScaling(
  ... scale=0.1, mode='fan_in', distribution='uniform')
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    scale: Scaling factor (positive float).
    mode: One of "fan_in", "fan_out", "fan_avg".
    distribution: Random distribution to use. One of "truncated_normal",
      "untruncated_normal" and  "uniform".
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.
  Nc                s   t t| j|t|dS )a  Returns a tensor object initialized as specified by the initializer.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only floating point types are
       supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`)
    )r   )r   r(   r   r   )r   r   r   )r   r   r   r     s    
zVarianceScaling.__call__)N)r   r   r   r   r   r    r   r   )r   r   r(   Y  s   (r(   zkeras.initializers.Orthogonalzkeras.initializers.orthogonalc                   s"   e Zd ZdZd fdd	Z  ZS )
Orthogonala  Initializer that generates an orthogonal matrix.

  Also available via the shortcut function `tf.keras.initializers.orthogonal`.

  If the shape of the tensor to initialize is two-dimensional, it is initialized
  with an orthogonal matrix obtained from the QR decomposition of a matrix of
  random numbers drawn from a normal distribution.
  If the matrix has fewer rows than columns then the output will have orthogonal
  rows. Otherwise, the output will have orthogonal columns.

  If the shape of the tensor to initialize is more than two-dimensional,
  a matrix of shape `(shape[0] * ... * shape[n - 2], shape[n - 1])`
  is initialized, where `n` is the length of the shape vector.
  The matrix is subsequently reshaped to give a tensor of the desired shape.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.Orthogonal()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.Orthogonal()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    gain: multiplicative factor to apply to the orthogonal matrix
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.

  References:
      [Saxe et al., 2014](https://openreview.net/forum?id=_wzZwKpTDF_9C)
      ([pdf](https://arxiv.org/pdf/1312.6120.pdf))
  Nc                s   t t| j|t|dS )a~  Returns a tensor object initialized to an orthogonal matrix.

    Args:
      shape: Shape of the tensor.
      dtype: Optional dtype of the tensor. Only floating point types are
        supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`)
    )r   )r   r)   r   r   )r   r   r   )r   r   r   r     s    
zOrthogonal.__call__)N)r   r   r   r   r   r    r   r   )r   r   r)     s   %r)   zkeras.initializers.Identityzkeras.initializers.identityc                   s"   e Zd ZdZd fdd	Z  ZS )Identitya  Initializer that generates the identity matrix.

  Also available via the shortcut function `tf.keras.initializers.identity`.

  Only usable for generating 2D matrices.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.Identity()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.Identity()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    gain: Multiplicative factor to apply to the identity matrix.
  Nc                s   t t| j|t|dS )a  Returns a tensor object initialized to a 2D identity matrix.

    Args:
      shape: Shape of the tensor. It should have exactly rank 2.
      dtype: Optional dtype of the tensor. Only floating point types are
       supported. If not specified, `tf.keras.backend.floatx()` is used,
       which default to `float32` unless you configured it otherwise
       (via `tf.keras.backend.set_floatx(float_dtype)`)
    )r   )r   r*   r   r   )r   r   r   )r   r   r   r     s    
zIdentity.__call__)N)r   r   r   r   r   r    r   r   )r   r   r*     s   r*   z keras.initializers.GlorotUniformz!keras.initializers.glorot_uniformc                   s*   e Zd ZdZd fdd	Zdd Z  ZS )GlorotUniforma  The Glorot uniform initializer, also called Xavier uniform initializer.

  Also available via the shortcut function
  `tf.keras.initializers.glorot_uniform`.

  Draws samples from a uniform distribution within `[-limit, limit]`, where
  `limit = sqrt(6 / (fan_in + fan_out))` (`fan_in` is the number of input units
  in the weight tensor and `fan_out` is the number of output units).

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.GlorotUniform()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.GlorotUniform()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.

  References:
      [Glorot et al., 2010](http://proceedings.mlr.press/v9/glorot10a.html)
      ([pdf](http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf))
  Nc                s   t t| jddd|d d S )Ng      ?fan_avguniform)scalemodedistributionseed)r   r+   r$   )r   r1   )r   r   r   r$   	  s
    
zGlorotUniform.__init__c             C   s
   d| j iS )Nr1   )r1   )r   r   r   r   r     s    zGlorotUniform.get_config)N)r   r   r   r   r$   r   r    r   r   )r   r   r+     s   r+   zkeras.initializers.GlorotNormalz keras.initializers.glorot_normalc                   s*   e Zd ZdZd fdd	Zdd Z  ZS )GlorotNormala  The Glorot normal initializer, also called Xavier normal initializer.

  Also available via the shortcut function
  `tf.keras.initializers.glorot_normal`.

  Draws samples from a truncated normal distribution centered on 0 with `stddev
  = sqrt(2 / (fan_in + fan_out))` where `fan_in` is the number of input units in
  the weight tensor and `fan_out` is the number of output units in the weight
  tensor.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.GlorotNormal()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.GlorotNormal()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Args:
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.

  References:
      [Glorot et al., 2010](http://proceedings.mlr.press/v9/glorot10a.html)
      ([pdf](http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf))
  Nc                s   t t| jddd|d d S )Ng      ?r,   truncated_normal)r.   r/   r0   r1   )r   r2   r$   )r   r1   )r   r   r   r$   5  s
    
zGlorotNormal.__init__c             C   s
   d| j iS )Nr1   )r1   )r   r   r   r   r   <  s    zGlorotNormal.get_config)N)r   r   r   r   r$   r   r    r   r   )r   r   r2     s   r2   zkeras.initializers.LecunNormalzkeras.initializers.lecun_normalc                   s*   e Zd ZdZd fdd	Zdd Z  ZS )LecunNormala  Lecun normal initializer.

   Also available via the shortcut function
  `tf.keras.initializers.lecun_normal`.

  Initializers allow you to pre-specify an initialization strategy, encoded in
  the Initializer object, without knowing the shape and dtype of the variable
  being initialized.

  Draws samples from a truncated normal distribution centered on 0 with `stddev
  = sqrt(1 / fan_in)` where `fan_in` is the number of input units in the weight
  tensor.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.LecunNormal()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.LecunNormal()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Arguments:
    seed: A Python integer. Used to seed the random generator.

  References:
      - Self-Normalizing Neural Networks,
      [Klambauer et al., 2017]
      (https://papers.nips.cc/paper/6698-self-normalizing-neural-networks)
      ([pdf]
      (https://papers.nips.cc/paper/6698-self-normalizing-neural-networks.pdf))
      - Efficient Backprop,
      [Lecun et al., 1998](http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf)
  Nc                s   t t| jddd|d d S )Ng      ?fan_inr3   )r.   r/   r0   r1   )r   r4   r$   )r   r1   )r   r   r   r$   h  s    
zLecunNormal.__init__c             C   s
   d| j iS )Nr1   )r1   )r   r   r   r   r   l  s    zLecunNormal.get_config)N)r   r   r   r   r$   r   r    r   r   )r   r   r4   @  s   &r4   zkeras.initializers.LecunUniformz keras.initializers.lecun_uniformc                   s*   e Zd ZdZd fdd	Zdd Z  ZS )LecunUniformag  Lecun uniform initializer.

   Also available via the shortcut function
  `tf.keras.initializers.lecun_uniform`.

  Draws samples from a uniform distribution within `[-limit, limit]`,
  where `limit = sqrt(3 / fan_in)` (`fan_in` is the number of input units in the
  weight tensor).

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.LecunUniform()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.LecunUniform()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Arguments:
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.

  References:
      - Self-Normalizing Neural Networks,
      [Klambauer et al., 2017](https://papers.nips.cc/paper/6698-self-normalizing-neural-networks) # pylint: disable=line-too-long
      ([pdf](https://papers.nips.cc/paper/6698-self-normalizing-neural-networks.pdf))
      - Efficient Backprop,
      [Lecun et al., 1998](http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf)
  Nc                s   t t| jddd|d d S )Ng      ?r5   r-   )r.   r/   r0   r1   )r   r6   r$   )r   r1   )r   r   r   r$     s    
zLecunUniform.__init__c             C   s
   d| j iS )Nr1   )r1   )r   r   r   r   r     s    zLecunUniform.get_config)N)r   r   r   r   r$   r   r    r   r   )r   r   r6   p  s   !r6   zkeras.initializers.HeNormalzkeras.initializers.he_normalc                   s*   e Zd ZdZd fdd	Zdd Z  ZS )HeNormala	  He normal initializer.

   Also available via the shortcut function
  `tf.keras.initializers.he_normal`.

  It draws samples from a truncated normal distribution centered on 0 with
  `stddev = sqrt(2 / fan_in)` where `fan_in` is the number of input units in the
  weight tensor.

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.HeNormal()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.HeNormal()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Arguments:
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.

  References:
      [He et al., 2015](https://www.cv-foundation.org/openaccess/content_iccv_2015/html/He_Delving_Deep_into_ICCV_2015_paper.html) # pylint: disable=line-too-long
      ([pdf](https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/He_Delving_Deep_into_ICCV_2015_paper.pdf))
  Nc                s   t t| jddd|d d S )Ng       @r5   r3   )r.   r/   r0   r1   )r   r7   r$   )r   r1   )r   r   r   r$     s    
zHeNormal.__init__c             C   s
   d| j iS )Nr1   )r1   )r   r   r   r   r     s    zHeNormal.get_config)N)r   r   r   r   r$   r   r    r   r   )r   r   r7     s   r7   zkeras.initializers.HeUniformzkeras.initializers.he_uniformc                   s*   e Zd ZdZd fdd	Zdd Z  ZS )	HeUniforma  He uniform variance scaling initializer.

   Also available via the shortcut function
  `tf.keras.initializers.he_uniform`.

  Draws samples from a uniform distribution within `[-limit, limit]`, where
  `limit = sqrt(6 / fan_in)` (`fan_in` is the number of input units in the
  weight tensor).

  Examples:

  >>> # Standalone usage:
  >>> initializer = tf.keras.initializers.HeUniform()
  >>> values = initializer(shape=(2, 2))

  >>> # Usage in a Keras layer:
  >>> initializer = tf.keras.initializers.HeUniform()
  >>> layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

  Arguments:
    seed: A Python integer. An initializer created with a given seed will
      always produce the same random tensor for a given shape and dtype.

  References:
      [He et al., 2015](https://www.cv-foundation.org/openaccess/content_iccv_2015/html/He_Delving_Deep_into_ICCV_2015_paper.html) # pylint: disable=line-too-long
      ([pdf](https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/He_Delving_Deep_into_ICCV_2015_paper.pdf))
  Nc                s   t t| jddd|d d S )Ng       @r5   r-   )r.   r/   r0   r1   )r   r8   r$   )r   r1   )r   r   r   r$     s    
zHeUniform.__init__c             C   s
   d| j iS )Nr1   )r1   )r   r   r   r   r     s    zHeUniform.get_config)N)r   r   r   r   r$   r   r    r   r   )r   r   r8     s   r8   c             C   s   | d krt  } t| S )N)r   Zfloatxr   Zas_dtype)r   r   r   r   r     s    r   N) r   
__future__r   r   r   Ztensorflow.python.frameworkr   r   Ztensorflow.python.kerasr   Ztensorflow.python.opsr   Z tensorflow.python.util.tf_exportr	   objectr
   r   r!   r"   r%   r&   r'   r(   r)   r*   r+   r2   r4   r6   r7   r8   r   r   r   r   r   <module>   s   P+'&+41"()-(%%