
    ijY                     T    d dl mZ d dlmZ d dlmZ  ed       G d de             Zy)    )backend)keras_export)Layerzkeras.layers.Dropoutc                   B     e Zd ZdZd fd	Zd ZddZd Z fdZ xZ	S )	DropoutaB  Applies dropout to the input.

    The `Dropout` layer randomly sets input units to 0 with a frequency of
    `rate` at each step during training time, which helps prevent overfitting.
    Inputs not set to 0 are scaled up by `1 / (1 - rate)` such that the sum over
    all inputs is unchanged.

    Note that the `Dropout` layer only applies when `training` is set to `True`
    in `call()`, such that no values are dropped during inference.
    When using `model.fit`, `training` will be appropriately set to `True`
    automatically. In other contexts, you can set the argument explicitly
    to `True` when calling the layer.

    (This is in contrast to setting `trainable=False` for a `Dropout` layer.
    `trainable` does not affect the layer's behavior, as `Dropout` does
    not have any variables/weights that can be frozen during training.)

    Args:
        rate: Float between 0 and 1. Fraction of the input units to drop.
        noise_shape: 1D integer tensor representing the shape of the
            binary dropout mask that will be multiplied with the input.
            For instance, if your inputs have shape
            `(batch_size, timesteps, features)` and
            you want the dropout mask to be the same for all timesteps,
            you can use `noise_shape=(batch_size, 1, features)`.
        seed: A Python integer to use as random seed.

    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).
    c                 "   t        |   di | d|cxk  rdk  sn t        d|       || _        || _        | j                  |      | _        |dkD  r$t        j                  j                  |      | _
        d| _        | j                          y )Nr      zcInvalid value received for argument `rate`. Expected a float value between 0 and 1. Received: rate=T )super__init__
ValueErrorrateseed_validate_noise_shapenoise_shaper   randomSeedGeneratorseed_generatorsupports_masking_build_at_init)selfr   r   r   kwargs	__class__s        |/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/keras/src/layers/regularization/dropout.pyr   zDropout.__init__)   s    "6"D~A~""&) 
 		55kB!8")..">">t"DD $    c                 ~   |y t        |t              rt        d|       t        |t              s	 t        |      }t        |      D ]V  \  }}|	t        |t              s(t        d| d| dt        |      j                   d      |dk  sGt        d| d|        |S # t        $ r t        d|       w xY w)	NzoInvalid value received for argument `noise_shape`. Expected a tuple or list of integers. Received: noise_shape=zInvalid value received for argument `noise_shape`. Expected an iterable of integers (e.g., a tuple or list). Received: noise_shape=z{Invalid value received for argument `noise_shape`. Expected all elements to be integers or None. Received element at index z: z (type: )r   zInvalid value received for argument `noise_shape`. Expected all dimensions to be positive integers or None. Received negative or zero value at index )	
isinstancestrr   tuple	TypeError	enumerateinttype__name__)r   r   idims       r   r   zDropout._validate_noise_shape:   s   k3'))47  +u-#K0  , 	FAs!#s+$556Cr# ?""&s)"4"4!5Q8  !8$D EF3bO 	$ 5   - .9M; s   B$ $B<c                     |rP| j                   dkD  rAt        j                  j                  || j                   | j                  | j
                        S |S )Nr   )r   r   )r   r   r   dropoutr   r   )r   inputstrainings      r   callzDropout.calld   sN    		A>>))		 ,,((	 *   r   c                     |S )Nr
   )r   input_shapes     r   compute_output_shapezDropout.compute_output_shapen   s    r   c                 t    t         |          }| j                  | j                  | j                  d}i ||S )N)r   r   r   )r   
get_configr   r   r   )r   base_configconfigr   s      r   r1   zDropout.get_configq   s@    g(*IIII++

 )+(((r   )NN)F)
r%   
__module____qualname____doc__r   r   r,   r/   r1   __classcell__)r   s   @r   r   r      s(    B"(T) )r   r   N)	keras.srcr   keras.src.api_exportr   keras.src.layers.layerr   r   r
   r   r   <module>r;      s2     - ( $%q)e q) &q)r   