relu

tripy.relu(input: Tensor) Tensor[source]

Applies Rectified Linear Unit (RELU) function to each element of the input tensor:

\(\text{relu}(x) = \max(0,x)\)

Parameters:

input (Tensor) – The input tensor.

Returns:

A tensor of the same shape as the input.

Return type:

Tensor

Example
Example
1input = tp.Tensor([1., 2., 3., 4.], dtype=tp.float32)
2output = tp.relu(input)
>>> input
tensor([1.0000, 2.0000, 3.0000, 4.0000], dtype=float32, loc=gpu:0, shape=(4,))
>>> output
tensor([1.0000, 2.0000, 3.0000, 4.0000], dtype=float32, loc=gpu:0, shape=(4,))