activation_relu {keras3}R Documentation

Applies the rectified linear unit activation function.

Description

With default values, this returns the standard ReLU activation: max(x, 0), the element-wise maximum of 0 and the input tensor.

Modifying default parameters allows you to use non-zero thresholds, change the max value of the activation, and to use a non-zero multiple of the input for values below the threshold.

Usage

activation_relu(x, negative_slope = 0, max_value = NULL, threshold = 0)

Arguments

x

Input tensor.

negative_slope

A numeric that controls the slope for values lower than the threshold.

max_value

A numeric that sets the saturation threshold (the largest value the function will return).

threshold

A numeric giving the threshold value of the activation function below which values will be damped or set to zero.

Value

A tensor with the same shape and dtype as input x.

Examples

x <- c(-10, -5, 0, 5, 10)
activation_relu(x)
## tf.Tensor([ 0.  0.  0.  5. 10.], shape=(5), dtype=float32)

activation_relu(x, negative_slope = 0.5)
## tf.Tensor([-5.  -2.5  0.   5.  10. ], shape=(5), dtype=float32)

activation_relu(x, max_value = 5)
## tf.Tensor([0. 0. 0. 5. 5.], shape=(5), dtype=float32)

activation_relu(x, threshold = 5)
## tf.Tensor([-0. -0.  0.  0. 10.], shape=(5), dtype=float32)

See Also

Other activations:
activation_elu()
activation_exponential()
activation_gelu()
activation_hard_sigmoid()
activation_leaky_relu()
activation_linear()
activation_log_softmax()
activation_mish()
activation_relu6()
activation_selu()
activation_sigmoid()
activation_silu()
activation_softmax()
activation_softplus()
activation_softsign()
activation_tanh()


[Package keras3 version 1.1.0 Index]