a
    SicD                     @   sl   d Z ddl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 GaussianDropout layer.    N)backend)
base_layer)tf_utils)keras_exportzkeras.layers.GaussianDropoutc                       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 )GaussianDropouta8  Apply multiplicative 1-centered Gaussian noise.

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

    Args:
      rate: Float, drop probability (as with `Dropout`).
        The multiplicative noise will have
        standard deviation `sqrt(rate / (1 - rate))`.
      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 dropout) 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rater   )selfr   r   kwargs	__class__ h/var/www/html/django/DPS/env/lib/python3.9/site-packages/keras/layers/regularization/gaussian_dropout.pyr	   7   s    zGaussianDropout.__init__c                    s<   dj   k rdk r8n n fdd}tj| |dS  S )Nr      c                     s6   t jdj  }  jjt d|  jd S )Ng      ?)shapemeanstddevdtype)npsqrtr   _random_generatorrandom_normaltfr   r   )r   inputsr   r   r   noised@   s    z$GaussianDropout.call.<locals>.noised)training)r   r   in_train_phase)r   r   r   r   r   r   r   call=   s    	zGaussianDropout.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"   L   s    
zGaussianDropout.get_configc                 C   s   |S )Nr   )r   input_shaper   r   r   compute_output_shapeQ   s    z$GaussianDropout.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-   numpyr   tensorflow.compat.v2compatv2r   kerasr   keras.enginer   keras.utilsr    tensorflow.python.util.tf_exportr   BaseRandomLayerr   r   r   r   r   <module>   s   