
    6biO                         S r SSKJr  SSKJr  SSKJr  SSK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\5      5       rg)z2Parametric Rectified Linear Unit activation layer.    )backend)constraints)initializers)regularizers)Layer)	InputSpec)tf_utils)keras_exportzkeras.layers.PReLUc                      ^  \ rS rSrSr    S	U 4S jjr\R                  S 5       rS r	U 4S jr
\R                  S 5       rSrU =r$ )
PReLU   a  Parametric Rectified Linear Unit.

It follows:

```
    f(x) = alpha * x for x < 0
    f(x) = x for x >= 0
```

where `alpha` is a learned array with the same shape as x.

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 the input.

Args:
    alpha_initializer: Initializer function for the weights.
    alpha_regularizer: Regularizer for the weights.
    alpha_constraint: Constraint for the weights.
    shared_axes: The axes along which to share learnable
        parameters for the activation function.
        For example, if the incoming feature maps
        are from a 2D convolution
        with output shape `(batch, height, width, channels)`,
        and you wish to share parameters across space
        so that each filter only has one set of parameters,
        set `shared_axes=[1, 2]`.
c                 T  > [         TU ]  " S0 UD6  SU l        [        R                  " U5      U l        [        R                  " U5      U l        [        R                  " U5      U l	        Uc  S U l
        g [        U[        [        45      (       d	  U/U l
        g [        U5      U l
        g )NT )super__init__supports_maskingr   getalpha_initializerr   alpha_regularizerr   alpha_constraintshared_axes
isinstancelisttuple)selfr   r   r   r   kwargs	__class__s         ^/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/layers/activation/prelu.pyr   PReLU.__init__A   s     	"6" $!-!1!12C!D!-!1!12C!D +0@ A#DK$77 +}D#K0D    c                    [        USS  5      nU R                  b  U R                   H
  nSX#S-
  '   M     U R                  USU R                  U R                  U R
                  S9U l        0 nU R                  (       a3  [        S[        U5      5       H  nX0R                  ;  d  M  X   XC'   M     [        [        U5      US9U l
        SU l        g )N   alpha)shapenameinitializerregularizer
constraint)ndimaxesT)r   r   
add_weightr   r   r   r#   rangelenr   
input_specbuilt)r   input_shapeparam_shapeir*   s        r   buildPReLU.buildU   s    ;qr?+'%%%&E" &__....,, % 

 1c+./,,,)nDG 0 $[)9E
r    c                     [         R                  " U5      nU R                  * [         R                  " U* 5      -  nX#-   $ N)r   relur#   )r   inputsposnegs       r   call
PReLU.callk   s3    ll6"zzkGLL&11yr    c                 n  > [         R                  " U R                  5      [        R                  " U R                  5      [
        R                  " U R                  5      U R                  S.n[        TU ]%  5       n[        [        UR                  5       5      [        UR                  5       5      -   5      $ )N)r   r   r   r   )r   	serializer   r   r   r   r   r   r   
get_configdictr   items)r   configbase_configr   s      r   r?   PReLU.get_configp   s    !-!7!78N8N!O!-!7!78N8N!O + 5 5d6K6K L++	
 g(*D**,-V\\^0DDEEr    c                     U$ r6   r   )r   r0   s     r   compute_output_shapePReLU.compute_output_shapez   s    r    )r#   r   r   r   r/   r.   r   r   )zerosNNN)__name__
__module____qualname____firstlineno____doc__r   r	   shape_type_conversionr3   r;   r?   rF   __static_attributes____classcell__)r   s   @r   r   r      s[    F "1( ## $*
F ## $r    r   N)rM   tf_keras.srcr   r   r   r   tf_keras.src.engine.base_layerr   tf_keras.src.engine.input_specr   tf_keras.src.utilsr	    tensorflow.python.util.tf_exportr
   r   r   r    r   <module>rV      sJ    9 ! $ % % 0 4 ' : "#]E ] $]r    