o
    2h                     @   sV   d dl 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 )	    N)backend)layers)ops)keras_exportzkeras.layers.GaussianDropoutc                       s@   e Zd ZdZd fdd	ZdddZdd	 Z fd
dZ  ZS )GaussianDropouta\  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).
    Nc                    sj   t  jdi | d|  krdksn td| || _|| _|dkr,tj|| _d| _	| 
  d S )Nr      zcInvalid value received for argument `rate`. Expected a float value between 0 and 1. Received: rate=T )super__init__
ValueErrorrateseedr   randomSeedGeneratorseed_generatorsupports_masking_build_at_init)selfr   r   kwargs	__class__r   k/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/layers/regularization/gaussian_dropout.pyr
      s   zGaussianDropout.__init__Fc                 C   sL   |r$| j dkr$t| j d| j   }|tjjt|d|| j| j	d S |S )Nr   g      ?)shapemeanstddevdtyper   )
r   mathsqrtr   r   normalr   r   compute_dtyper   )r   inputstrainingr   r   r   r   call+   s   zGaussianDropout.callc                 C   s   |S Nr   )r   input_shaper   r   r   compute_output_shape7   s   z$GaussianDropout.compute_output_shapec                    s$   t   }| j| jd}i ||S )N)r   r   )r	   
get_configr   r   )r   base_configconfigr   r   r   r&   :   s
   
zGaussianDropout.get_configr#   )F)	__name__
__module____qualname____doc__r
   r"   r%   r&   __classcell__r   r   r   r   r   	   s    
r   )	r   	keras.srcr   r   r   keras.src.api_exportr   Layerr   r   r   r   r   <module>   s    