o
    7?e                     @   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dd|i| d| _|| _|| _d S )NseedT )super__init__Zsupports_maskingstddevr   )selfr   r   kwargs	__class__r   o/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/keras/src/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)Z_random_generatorZrandom_normaltfr   r   r   r   inputsr   r   r   noised@   s   z"GaussianNoise.call.<locals>.noised)training)r   Z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   configZbase_configr   r   r   r   J   s   
zGaussianNoise.get_configc                 C   s   |S Nr   )r   Zinput_shaper   r   r   compute_output_shapeO   s   z"GaussianNoise.compute_output_shaper   )__name__
__module____qualname____doc__r
   r   r   r   Zshape_type_conversionr    __classcell__r   r   r   r   r      s    
r   )r$   Ztensorflow.compat.v2compatv2r   Z	keras.srcr   Zkeras.src.enginer   Zkeras.src.utilsr   Z tensorflow.python.util.tf_exportr   ZBaseRandomLayerr   r   r   r   r   <module>   s   