# tf.keras.callbacks.TerminateOnNaN

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/callbacks.py#L986-L1003) |

Callback that terminates training when a NaN loss is encountered.

Inherits From: [`Callback`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/callbacks/Callback)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

\`tf.compat.v1.keras.callbacks.TerminateOnNaN\`

<br />

    tf.keras.callbacks.TerminateOnNaN()

## Methods

### `set_model`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/callbacks.py#L694-L695)

    set_model(
        model
    )

### `set_params`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/callbacks.py#L691-L692)

    set_params(
        params
    )