o
    2h
                     @   s@   d dl mZ d dlmZ d dlmZ edG dd deZdS )    )activations)keras_export)Layerzkeras.layers.ReLUc                       s@   e Zd ZdZ	d fdd	Zdd Z fdd	Zd
d Z  ZS )ReLUa  Rectified Linear Unit activation function layer.

    Formula:
    ``` python
    f(x) = max(x,0)
    f(x) = max_value if x >= max_value
    f(x) = x if threshold <= x < max_value
    f(x) = negative_slope * (x - threshold) otherwise
    ```

    Example:
    ``` python
    relu_layer = keras.layers.ReLU(
        max_value=10,
        negative_slope=0.5,
        threshold=0,
    )
    input = np.array([-10, -5, 0.0, 5, 10])
    result = relu_layer(input)
    # result = [-5. , -2.5,  0. ,  5. , 10.]
    ```

    Args:
        max_value: Float >= 0. Maximum activation value. None means unlimited.
            Defaults to `None`.
        negative_slope: Float >= 0. Negative slope coefficient.
            Defaults to `0.0`.
        threshold: Float >= 0. Threshold value for thresholded activation.
            Defaults to `0.0`.
        **kwargs: Base layer keyword arguments, such as `name` and `dtype`.
    N        c                    s   t  jdi | |d ur|dk rtd| |d u s |dk r'td| |d u s/|dk r6td| || _|| _|| _d| _|   d S )Nr   zJmax_value of a ReLU layer cannot be a negative value. Received: max_value=zTnegative_slope of a ReLU layer cannot be a negative value. Received: negative_slope=zJthreshold of a ReLU layer cannot be a negative value. Received: threshold=T )super__init__
ValueError	max_valuenegative_slope	thresholdsupports_masking_build_at_init)selfr   r   r   kwargs	__class__r   \/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/layers/activations/relu.pyr	   (   s0   zReLU.__init__c                 C   s   t j|| j| j| jdS )N)r   r   r   )r   relur   r   r   )r   inputsr   r   r   callC   s   z	ReLU.callc                    s&   t   }|| j| j| jd |S )N)r   r   r   )r   
get_configupdater   r   r   )r   configr   r   r   r   K   s   
zReLU.get_configc                 C   s   |S )Nr   )r   input_shaper   r   r   compute_output_shapeV   s   zReLU.compute_output_shape)Nr   r   )	__name__
__module____qualname____doc__r	   r   r   r   __classcell__r   r   r   r   r      s    !r   N)	keras.srcr   keras.src.api_exportr   keras.src.layers.layerr   r   r   r   r   r   <module>   s
    