o
    7?eQ                     @   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dd|i| d| _|| _|| _d S )NseedT )super__init__Zsupports_maskingrater   )selfr   r   kwargs	__class__r   q/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/keras/src/layers/regularization/gaussian_dropout.pyr
   7   s   
zGaussianDropout.__init__c                    s>   dj   k rdk rn  S  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   Z_random_generatorZrandom_normaltfr   r   )r   inputsr   r   r   noised@   s   z$GaussianDropout.call.<locals>.noised)training)r   r   Z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   configZbase_configr   r   r   r   L   s   
zGaussianDropout.get_configc                 C   s   |S Nr   )r   Zinput_shaper   r   r   compute_output_shapeQ   s   z$GaussianDropout.compute_output_shaper#   )__name__
__module____qualname____doc__r
   r   r   r   Zshape_type_conversionr$   __classcell__r   r   r   r   r      s    
r   )r(   numpyr   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   