Function dfdx::tensor_ops::relu
source · pub fn relu<S: Shape, E: Dtype, D: UnaryKernel<ReLUKernelOp, E>, T: Tape<E, D>>(
t: Tensor<S, E, D, T>
) -> Tensor<S, E, D, T>
Expand description
Rectified Linear Unit (ReLU). max(0, t)
The derivative is the Heaviside function.
Examples:
let t = dev.tensor([-1.0, 0.0, 1.0, 2.0]);
let r = t.relu();
assert_eq!(r.array(), [0.0, 0.0, 1.0, 2.0]);