def after_run(self, run_context, run_values):
    if np.isnan(run_values.results):
        failure_message = 'Model diverged with loss = NaN.'
        if self._fail_on_nan_loss:
            logging.error(failure_message)
            raise NanLossDuringTrainingError
        else:
            logging.warning(failure_message)
            run_context.request_stop()
def after_run(self, run_context, run_values):
    if np.isnan(run_values.results):
        failure_message = 'Model diverged with loss = NaN.'
        if self._fail_on_nan_loss:
            logging.error(failure_message)
            raise NanLossDuringTrainingError
        else:
            logging.warning(failure_message)
            run_context.request_stop()