
    :|hd                         d dl mZ d dl mZ d dl 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
e
             Zy)    )activations)constraints)initializers)regularizers)keras_export)	InputSpec)Layerzkeras.layers.PReLUc                   H     e Zd ZdZ	 	 	 	 d fd	Zd Zd Z fdZd Z xZ	S )PReLUao  Parametric Rectified Linear Unit activation layer.

    Formula:
    ``` python
    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.

    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]`.
        **kwargs: Base layer keyword arguments, such as `name` and `dtype`.
    c                 @   t        |   di | d| _        t        j                  |      | _        t        j                  |      | _        t        j                  |      | _	        |d | _
        y t        |t        t        f      s	|g| _
        y t        |      | _
        y )NT )super__init__supports_maskingr   getalpha_initializerr   alpha_regularizerr   alpha_constraintshared_axes
isinstancelisttuple)selfr   r   r   r   kwargs	__class__s         a/var/www/html/test/engine/venv/lib/python3.12/site-packages/keras/src/layers/activations/prelu.pyr   zPReLU.__init__"   s     	"6" $!-!1!12C!D!-!1!12C!D +0@ A#DK$7 +}D#K0D    c                    t        |dd        }| j                  | j                  D ]
  }d||dz
  <    | j                  |d| j                  | j                  | j
                        | _        i }| j                  r1t        dt        |            D ]  }|| j                  vs||   ||<    t        t        |      |      | _
        y )N   alpha)shapenameinitializerregularizer
constraint)ndimaxes)r   r   
add_weightr   r   r   r    rangelenr   
input_spec)r   input_shapeparam_shapeir'   s        r   buildzPReLU.build6   s    ;qr?+'%% '%&AE"'__....,, % 

 1c+./ -D,,,)!nDG- $[)9Er   c                 ~    t        j                  |      }| j                   t        j                  |       z  }||z   S N)r   relur    )r   inputsposnegs       r   callz
PReLU.callJ   s9    v&zzkK,,fW55Syr   c                    t         |          }|j                  t        j                  | j
                        t        j                  | j                        t        j                  | j                        | j                  d       |S )N)r   r   r   r   )r   
get_configupdater   	serializer   r   r   r   r   r   )r   configr   s     r   r8   zPReLU.get_configO   s|    #%%1%;%;**& &2%;%;**& %0$9$9))%  $//	
 r   c                     |S r1   r   )r   r,   s     r   compute_output_shapezPReLU.compute_output_shapea   s    r   )ZerosNNN)
__name__
__module____qualname____doc__r   r/   r6   r8   r=   __classcell__)r   s   @r   r   r   
   s0    0 "1(F(
$r   r   N)	keras.srcr   r   r   r   keras.src.api_exportr   keras.src.layers.input_specr   keras.src.layers.layerr	   r   r   r   r   <module>rH      s>    ! ! " " - 1 ( "#WE W $Wr   