class_docstr: Callback that terminates training when a NaN loss is encountered.
class_docstr_tok: ["Callback","that","terminates","training","when","a","NaN","loss","is","encountered","."]
code: def on_batch_end(self, batch, logs=None):
      logs = logs or {}
      loss = logs.get("loss")
      if loss is not None:
          if np.isnan(loss) or np.isinf(loss):
              print(
                  "Batch %d: Invalid loss, terminating training"
                  % (batch)
              )
              self.model.stop_training = True
  
imports: import numpy
  from .callback import Callback
label_desc: Use image node_id 1 for calling the TerminateOnNaN obj's underlying member method code with example usage: obj.on_batch_end(batch, logs) without return types