mlx.core.nan_to_num

目录

mlx.core.nan_to_num#

nan_to_num(a: 标量 | 数组, nan: 浮点数 = 0, posinf: 浮点数 | None = None, neginf: 浮点数 | None = None, *, stream: None | | 设备 = None) 数组#

将 NaN 和 Inf 值替换为有限数。

参数:
  • a (数组) – 输入数组

  • nan (浮点数, 可选) – 用于替换 NaN 的值。默认值: 0

  • posinf (浮点数, 可选) – 用于替换正无穷大的值。如果为 None,则默认为给定数据类型的最大有限值。默认值: None

  • neginf (浮点数, 可选) – 用于替换负无穷大的值。如果为 None,则默认为给定数据类型的最大有限值的负数。默认值: None

返回值:

替换了 NaN 和 Inf 的输出数组。

返回类型:

数组