def every_n_step_end(self, step, outputs):
    super(NanLoss, self).every_n_step_end(step, outputs)
    if np.isnan(_extract_output(outputs, self._loss_tensor)):
        failure_message = 'Model diverged with loss = NaN.'
        if self._fail_on_nan_loss:
            logging.error(failure_message)
            raise NanLossDuringTrainingError
        else:
            logging.warning(failure_message)
            return True
def every_n_step_end(self, step, outputs):
    super(NanLoss, self).every_n_step_end(step, outputs)
    if np.isnan(_extract_output(outputs, self._loss_tensor)):
        failure_message = 'Model diverged with loss = NaN.'
        if self._fail_on_nan_loss:
            logging.error(failure_message)
            raise NanLossDuringTrainingError
        else:
            logging.warning(failure_message)
            return True