mindspore.ops.nextafter
- 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
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> eps = np.finfo(np.float32).eps >>> input = mindspore.tensor([1.0], mindspore.float32) >>> other = mindspore.tensor([2.0], mindspore.float32) >>> output = mindspore.ops.nextafter(input, other) >>> print(output == eps + 1) [ True] >>> input = mindspore.tensor([1.0, 2.0], mindspore.float32) >>> other = mindspore.tensor([2.0, 1.0], mindspore.float32) >>> output = mindspore.ops.nextafter(input, other) >>> print(output == mindspore.tensor([eps + 1, 2 - eps], mindspore.float32)) [ True True]