
    0h                     d    d 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	)
z'Rectified Linear Unit activation layer.    )backend)Layer)tf_utils)keras_exportzkeras.layers.ReLUc                   Z     e Zd ZdZ	 d fd	Zd Z fdZej                  d        Z	 xZ
S )ReLUa  Rectified Linear Unit activation function.

    With default values, it returns element-wise `max(x, 0)`.

    Otherwise, it follows:

    ```
        f(x) = max_value if x >= max_value
        f(x) = x if threshold <= x < max_value
        f(x) = negative_slope * (x - threshold) otherwise
    ```

    Usage:

    >>> layer = tf.keras.layers.ReLU()
    >>> output = layer([-3.0, -1.0, 0.0, 2.0])
    >>> list(output.numpy())
    [0.0, 0.0, 0.0, 2.0]
    >>> layer = tf.keras.layers.ReLU(max_value=1.0)
    >>> output = layer([-3.0, -1.0, 0.0, 2.0])
    >>> list(output.numpy())
    [0.0, 0.0, 0.0, 1.0]
    >>> layer = tf.keras.layers.ReLU(negative_slope=1.0)
    >>> output = layer([-3.0, -1.0, 0.0, 2.0])
    >>> list(output.numpy())
    [-3.0, -1.0, 0.0, 2.0]
    >>> layer = tf.keras.layers.ReLU(threshold=1.5)
    >>> output = layer([-3.0, -1.0, 1.0, 2.0])
    >>> list(output.numpy())
    [0.0, 0.0, 0.0, 2.0]

    Input shape:
        Arbitrary. Use the keyword argument `input_shape`
        (tuple of integers, does not include the batch axis)
        when using this layer as the first layer in a model.

    Output shape:
        Same shape as the input.

    Args:
        max_value: Float >= 0. Maximum activation value. None means unlimited.
            Defaults to `None`.
        negative_slope: Float >= 0. Negative slope coefficient.
            Defaults to `0.`.
        threshold: Float >= 0. Threshold value for thresholded activation.
            Defaults to `0.`.
    c                 T   t        |   di | ||dk  rt        d|       ||dk  rt        d|       ||dk  rt        d|       d| _        |t	        j
                  |      }|| _        t	        j
                  |      | _        t	        j
                  |      | _        y )N        z@max_value of a ReLU layer cannot be a negative value. Received: zEnegative_slope of a ReLU layer cannot be a negative value. Received: z@threshold of a ReLU layer cannot be a negative value. Received: T )	super__init__
ValueErrorsupports_maskingr   cast_to_floatx	max_valuenegative_slope	threshold)selfr   r   r   kwargs	__class__s        ]/var/www/html/engine/venv/lib/python3.12/site-packages/tf_keras/src/layers/activation/relu.pyr   zReLU.__init__L   s     	"6" Y_$$-;0  !^c%9$$2#35  	C$$-;0 
 !% ..y9I"%44^D //	:    c                 p    t        j                  || j                  | j                  | j                        S )N)alphar   r   )r   relur   r   r   )r   inputss     r   callz	ReLU.callg   s/     ||%%nnnn	
 	
r   c                     | j                   | j                  | j                  d}t        |          }t        t        |j                               t        |j                               z         S )N)r   r   r   )r   r   r   r   
get_configdictlistitems)r   configbase_configr   s      r   r   zReLU.get_configq   sY    "11

 g(*D**,-V\\^0DDEEr   c                     |S )Nr   )r   input_shapes     r   compute_output_shapezReLU.compute_output_shapez   s    r   )Nr
   r
   )__name__
__module____qualname____doc__r   r   r   r   shape_type_conversionr'   __classcell__)r   s   @r   r   r      s9    .b =@;6
F ## $r   r   N)
r+   tf_keras.srcr   tf_keras.src.engine.base_layerr   tf_keras.src.utilsr    tensorflow.python.util.tf_exportr   r   r   r   r   <module>r2      s>    . ! 0 ' : !"a5 a #ar   