<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/numpy.py#L6504-L6526) |

Replace NaN with zero and infinity with large finite numbers.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.nan_to_num`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/nan_to_num)

<br />

    tf.keras.ops.nan_to_num(
        x, nan=0.0, posinf=None, neginf=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input data. |
| `nan` | Optional float or int. Value to replace `NaN` entries with. |
| `posinf` | Optional float or int. Value to replace positive infinity with. |
| `neginf` | Optional float or int. Value to replace negative infinity with. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `x`, with non-finite values replaced. ||

<br />