
    6bi                         S r SSKJs  Jr  SSKJr  SSKJr  SSK	J
r
  SSKJr  \" S5       " S S	\R                  5      5       rg)
z Contains the AlphaDropout layer.    N)backend)
base_layer)tf_utils)keras_exportzkeras.layers.AlphaDropoutc                   p   ^  \ rS rSrSrS	U 4S jjrS rS
S jrU 4S jr\	R                  S 5       rSrU =r$ )AlphaDropout   a  Applies Alpha Dropout to the input.

Alpha Dropout is a `Dropout` that keeps mean and variance of inputs
to their original values, in order to ensure the self-normalizing property
even after this dropout.
Alpha Dropout fits well to Scaled Exponential Linear Units
by randomly setting activations to the negative saturation value.

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.
c                 \   > [         TU ]  " SSU0UD6  Xl        X l        X0l        SU l        g )NseedT )super__init__ratenoise_shaper   supports_masking)selfr   r   r   kwargs	__class__s        j/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/layers/regularization/alpha_dropout.pyr   AlphaDropout.__init__:   s0    -d-f-	&	 $    c                 h    U R                   (       a  U R                   $ [        R                  " U5      $ N)r   tfshape)r   inputss     r   _get_noise_shapeAlphaDropout._get_noise_shapeA   s$    #'#3#3tI&9IIr   c                    ^ ^ ST R                   s=:  a  S:  a?  O  U$ T R                  U5      mUT R                   4UU 4S jjn[        R                  " X1US9$ U$ )Ng        g      ?c                   > SnSnU* U-  n[         R                  " T
R                  R                  T	5      U5      n[         R                  " XPR
                  5      nSU-
  SXS-  -  -   -  S-  nU* U-  U-  nX-  USU-
  -  -   nXh-  U-   $ )Ng,x?g2֫?      g      )r   greater_equal_random_generatorrandom_uniformcastdtype)r   r   alphascalealpha_pkept_idxabxr   r   s            r   dropped_inputs)AlphaDropout.call.<locals>.dropped_inputsH   s    99 &5.++**99+F 778\\: $h1tqj'8#89dBBL4' %1x<(@@ uqy r   )training)r   r   r   in_train_phase)r   r   r1   r/   r   s   `   @r   callAlphaDropout.callD   sa     S 4 3 //7K&,499 ! !( ))  r   c                    > U R                   U R                  S.n[        TU ]  5       n[	        [        UR                  5       5      [        UR                  5       5      -   5      $ )N)r   r   )r   r   r   
get_configdictlistitems)r   configbase_configr   s      r   r6   AlphaDropout.get_configa   sK    ))TYY7g(*D**,-V\\^0DDEEr   c                     U$ r   r   )r   input_shapes     r   compute_output_shape!AlphaDropout.compute_output_shapef   s    r   )r   r   r   r   )NNr   )__name__
__module____qualname____firstlineno____doc__r   r   r3   r6   r   shape_type_conversionr?   __static_attributes____classcell__)r   s   @r   r   r      s8    8%J:F
 ## $r   r   )rE   tensorflow.compat.v2compatv2r   tf_keras.srcr   tf_keras.src.enginer   tf_keras.src.utilsr    tensorflow.python.util.tf_exportr   BaseRandomLayerr   r   r   r   <module>rQ      sJ    ' " !   * ' : )*K:-- K +Kr   