mindspore.mint.nn.functional.relu_

View Source On Gitee
mindspore.mint.nn.functional.relu_(input)[source]

ReLuComputes ReLU (Rectified Linear Unit activation function) inplace of input tensors element-wise.

It returns \(\max(input,\ 0)\) element-wise. Specially, the neurons with the negative output will be suppressed and the active neurons will stay the same.

\[ReLU(input) = (input)^+ = \max(0, input)\]

ReLU Activation Function Graph:

../../_images/ReLU.png

Warning

This is an experimental API that is subject to change or deletion.

Parameters

input (Tensor) – The input Tensor.

Returns

Tensor, with the same dtype and shape as the input.

Raises
  • TypeError – If dtype of input is not Number type.

  • TypeError – If input is not a Tensor.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> input = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
>>> mint.nn.functional.relu_(input)
>>> print(input)
[[0. 4. 0.]
 [2. 0. 9.]]