aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/estimator/training.py
diff options
context:
space:
mode:
authorGravatar Jianwei Xie <xiejw@google.com>2017-10-02 22:03:17 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-10-02 22:06:51 -0700
commitb3d6b40f7efa41d0c41c7156d21c3dda3feae2f0 (patch)
tree49578ad65e46db954e2a74059d3c95837cf23134 /tensorflow/python/estimator/training.py
parent0466135756ff23ddb86ca90d975d66b69c0f750d (diff)
Adds strong validation on eval metrics returnes by `Estimator.evaluate`
PiperOrigin-RevId: 170804185
Diffstat (limited to 'tensorflow/python/estimator/training.py')
-rw-r--r--tensorflow/python/estimator/training.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tensorflow/python/estimator/training.py b/tensorflow/python/estimator/training.py
index 638ac74bc5..f4ccea6806 100644
--- a/tensorflow/python/estimator/training.py
+++ b/tensorflow/python/estimator/training.py
@@ -485,6 +485,10 @@ class _TrainingExecutor(object):
Returns:
Evaluation results. Returns `None` if current round of evaluation is
skipped.
+
+ Raises:
+ RuntimeError: for any unexpected internal error.
+ TypeError: if evaluation result has wrong type.
"""
latest_ckpt_path = self._estimator.latest_checkpoint()
if not latest_ckpt_path:
@@ -506,8 +510,17 @@ class _TrainingExecutor(object):
hooks=self._eval_spec.hooks)
if not eval_result:
- self._log_err_msg('Estimator evaluate returns empty result.')
- return None
+ raise RuntimeError(
+ 'Internal error: `Estimator.evaluate` should never return empty '
+ 'result.')
+ if not isinstance(eval_result, dict):
+ raise TypeError(
+ '`Estimator.evaluate` should return dict. Given {}.'.format(
+ type(eval_result)))
+ if ops.GraphKeys.GLOBAL_STEP not in eval_result:
+ raise RuntimeError(
+ 'Internal error: `Estimator.evaluate` result should have '
+ '`global_step` in result. Given {}'.format(eval_result))
self._export_eval_result(eval_result, latest_ckpt_path)