a
    Sic                     @   sd   d 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 edG dd	 d	ejZdS )
z!Contains the GaussianNoise layer.    N)backend)
base_layer)tf_utils)keras_exportzkeras.layers.GaussianNoisec                       sF   e Zd ZdZd fdd	ZdddZ fddZejd	d
 Z	  Z
S )GaussianNoisea  Apply additive zero-centered Gaussian noise.

    This is useful to mitigate overfitting
    (you could see it as a form of random data augmentation).
    Gaussian Noise (GS) is a natural choice as corruption process
    for real valued inputs.

    As it is a regularization layer, it is only active at training time.

    Args:
      stddev: Float, standard deviation of the noise distribution.
      seed: Integer, optional random seed to enable deterministic behavior.

    Call arguments:
      inputs: Input tensor (of any rank).
      training: Python boolean indicating whether the layer should behave in
        training mode (adding noise) or in inference mode (doing nothing).

    Input shape:
      Arbitrary. Use the keyword argument `input_shape`
      (tuple of integers, does not include the samples axis)
      when using this layer as the first layer in a model.

    Output shape:
      Same shape as input.
    Nc                    s,   t  jf d|i| d| _|| _|| _d S )NseedT)super__init__supports_maskingstddevr   )selfr   r   kwargs	__class__ f/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/layers/regularization/gaussian_noise.pyr	   9   s    zGaussianNoise.__init__c                    s    fdd}t j| |dS )Nc                      s"    j jt dj jd S )Ng        )shapemeanr   dtype)_random_generatorrandom_normaltfr   r   r   r   inputsr   r   r   noised@   s    z"GaussianNoise.call.<locals>.noised)training)r   in_train_phase)r   r   r   r   r   r   r   call?   s    zGaussianNoise.callc                    s4   | j | jd}t  }tt| t|  S )N)r   r   )r   r   r   
get_configdictlistitems)r   configbase_configr   r   r   r   J   s    
zGaussianNoise.get_configc                 C   s   |S )Nr   )r   input_shaper   r   r   compute_output_shapeO   s    z"GaussianNoise.compute_output_shape)N)N)__name__
__module____qualname____doc__r	   r   r   r   shape_type_conversionr%   __classcell__r   r   r   r   r      s   
r   )r)   tensorflow.compat.v2compatv2r   kerasr   keras.enginer   keras.utilsr    tensorflow.python.util.tf_exportr   BaseRandomLayerr   r   r   r   r   <module>   s   