
    ~Wh                         d 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	 ddl
mZ dd	lmZ  ed
           G d de                      ZdS )z2Parametric Rectified Linear Unit activation layer.    )backend)constraints)initializers)regularizers)Layer)	InputSpec)tf_utils)keras_exportzkeras.layers.PReLUc                   |     e Zd ZdZ	 	 	 	 d	 fd	Zej        d             Zd Z fdZ	ej        d             Z
 xZS )
PReLUa  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]`.
    zerosNc                 h    t                      j        di | d| _        t          j        |          | _        t          j        |          | _        t          j        |          | _	        |	d | _
        d S t          |t          t          f          s
|g| _
        d S t          |          | _
        d S )NT )super__init__supports_maskingr   getalpha_initializerr   alpha_regularizerr   alpha_constraintshared_axes
isinstancelisttuple)selfr   r   r   r   kwargs	__class__s         c/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/keras/layers/activation/prelu.pyr   zPReLU.__init__A   s     	""6""" $!-!12C!D!D!-!12C!D!D +0@ A A#DK$77 	1 +}D#K00D    c                    t          |dd                    }| j        | j        D ]
}d||dz
  <   |                     |d| j        | j        | j                  | _        i }| j        r4t          dt          |                    D ]}|| j        vr||         ||<   t          t          |          |          | _
        d| _        d S )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   buildzPReLU.buildU   s    ;qrr?++'% ' '%&AE""__.., % 
 

  	-1c+..// - -D,,,)!nDG#[)9)9EEE


r   c                 p    t          j        |          }| j         t          j        |           z  }||z   S N)r   relur"   )r   inputsposnegs       r   callz
PReLU.callk   s5    l6""zkGL&111Syr   c                    t          j        | j                  t          j        | j                  t          j        | j                  | j        d}t                      	                                }t          t          |                                          t          |                                          z             S )N)r   r   r   r   )r   	serializer   r   r   r   r   r   r   
get_configdictr   items)r   configbase_configr   s      r   r<   zPReLU.get_configp   s    !-!78N!O!O!-!78N!O!O + 5d6K L L+	
 
 gg((**D**,,--V\\^^0D0DDEEEr   c                     |S r4   r   )r   r/   s     r   compute_output_shapezPReLU.compute_output_shapez   s    r   )r   NNN)__name__
__module____qualname____doc__r   r	   shape_type_conversionr2   r9   r<   rB   __classcell__)r   s   @r   r   r      s         F "1 1 1 1 1 1( #  $#*  
F F F F F #  $#    r   r   N)rF   kerasr   r   r   r   keras.engine.base_layerr   keras.engine.input_specr   keras.utilsr	    tensorflow.python.util.tf_exportr
   r   r   r   r   <module>rN      s    9 8                         ) ) ) ) ) ) - - - - - -             : 9 9 9 9 9 "##] ] ] ] ]E ] ] $#] ] ]r   