
    6bi                     d    S 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	)
z'Rectified Linear Unit activation layer.    )backend)Layer)tf_utils)keras_exportzkeras.layers.ReLUc                   h   ^  \ rS rSrSr SU 4S jjrS rU 4S jr\R                  S 5       r
SrU =r$ )	ReLU   a=  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                 h  > [         TU ]  " S0 UD6  Ub  US:  a  [        SU 35      eUb  US:  a  [        SU 35      eUb  US:  a  [        SU 35      eSU l        Ub  [        R
                  " U5      nXl        [        R
                  " U5      U l        [        R
                  " U5      U l        g )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        ]/home/james-whalen/.local/lib/python3.13/site-packages/tf_keras/src/layers/activation/relu.pyr   ReLU.__init__L   s     	"6" Y_$$-;0  !^c%9$$2#35  	C$$-;0 
 !% ..y9I"%44^D //	:    c                 l    [         R                  " UU R                  U R                  U R                  S9$ )N)alphar   r   )r   relur   r   r   )r   inputss     r   call	ReLU.callg   s/     ||%%nnnn	
 	
r   c                    > U R                   U R                  U R                  S.n[        TU ]  5       n[        [        UR                  5       5      [        UR                  5       5      -   5      $ )N)r   r   r   )r   r   r   r   
get_configdictlistitems)r   configbase_configr   s      r   r"   ReLU.get_configq   sY    "11

 g(*D**,-V\\^0DDEEr   c                     U$ )Nr   )r   input_shapes     r   compute_output_shapeReLU.compute_output_shapez   s    r   )r   r   r   r   )Nr   r   )__name__
__module____qualname____firstlineno____doc__r   r   r"   r   shape_type_conversionr+   __static_attributes____classcell__)r   s   @r   r   r      s9    .b =@;6
F ## $r   r   N)
r1   tf_keras.srcr   tf_keras.src.engine.base_layerr   tf_keras.src.utilsr    tensorflow.python.util.tf_exportr   r   r   r   r   <module>r9      s>    . ! 0 ' : !"a5 a #ar   