mindspore.ops.nextafter

View Source On Gitee
mindspore.ops.nextafter(input, other)[source]

Returns the next representable floating-point value after input towards other element-wise.

\[\begin{split}out_i = \begin{cases} & input_i + eps, & \text{if } input_i < other_i \\ & input_i - eps, & \text{if } input_i > other_i \\ & input_i, & \text{if } input_i = other_i \end{cases}\end{split}\]

Where eps is the smallest representable increment value for the input tensor's dtype.

For more detailed information, refer to A Self Regularized Non-Monotonic Neural Activation Function.

Parameters
  • input (Tensor) – The first input tensor.

  • other (Tensor) – The second input tensor.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.tensor([0.0], mindspore.float32)
>>> other = mindspore.tensor([0.1], mindspore.float32)
>>> output = mindspore.ops.nextafter(input, other)
>>> print(output)
[1.e-45]