mlx.core.nan_to_num#
- nan_to_num(a: scalar | array, nan: float = 0, posinf: float | None = None, neginf: float | None = None, *, stream: None | Stream | Device = None) array #
Replace NaN and Inf values with finite numbers.
- Parameters:
a (array) – Input array
nan (float, optional) – Value to replace NaN with. Default:
0
.posinf (float, optional) – Value to replace positive infinities with. If
None
, defaults to largest finite value for the given data type. Default:None
.neginf (float, optional) – Value to replace negative infinities with. If
None
, defaults to the negative of the largest finite value for the given data type. Default:None
.
- Returns:
Output array with NaN and Inf replaced.
- Return type: