mindspore.Tensor.nan_to_num
- mindspore.Tensor.nan_to_num(nan=None, posinf=None, neginf=None)
详情请参考
mindspore.ops.nan_to_num()
。- 支持平台:
Ascend
CPU
样例:
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> input = Tensor(np.array([float('nan'), float('inf'), -float('inf'), 5.0]), mindspore.float32) >>> output = input.nan_to_num(1.0, 2.0, 3.0) >>> print(output) [1. 2. 3. 5.0]