Skip to content

Commit

Permalink
added more checks for experiment.
Browse files Browse the repository at this point in the history
Change: 151366403
  • Loading branch information
Jianwei Xie authored and tensorflower-gardener committed Mar 27, 2017
1 parent b32a1b7 commit 5c65a93
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tensorflow/contrib/learn/python/learn/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ def continuous_train_and_eval(self,
raise ValueError(
"`continuous_eval_predicate_fn` must be a callable, or None.")

if not isinstance(train_steps_per_iteration, int):
raise ValueError(
"`train_steps_per_iteration` must be an integer.")

eval_result = None

# TODO(b/33295821): improve the way to determine the
Expand Down
20 changes: 20 additions & 0 deletions tensorflow/contrib/learn/python/learn/experiment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,26 @@ def predicate_fn(eval_result):
self.assertEqual(0, est.eval_count)
self.assertEqual(1, est.export_count)

def test_continuous_train_and_eval_with_invalid_predicate_fn(self):
for est in self._estimators_for_tests():
ex = experiment.Experiment(
est,
train_input_fn='train_input',
eval_input_fn='eval_input')
with self.assertRaisesRegexp(
ValueError, '`continuous_eval_predicate_fn` must be a callable'):
ex.continuous_train_and_eval(continuous_eval_predicate_fn='fn')

def test_continuous_train_and_eval_with_invalid_train_steps_iterations(self):
for est in self._estimators_for_tests():
ex = experiment.Experiment(
est,
train_input_fn='train_input',
eval_input_fn='eval_input')
with self.assertRaisesRegexp(
ValueError, '`train_steps_per_iteration` must be an integer.'):
ex.continuous_train_and_eval(train_steps_per_iteration='123')

@test.mock.patch.object(server_lib, 'Server')
def test_run_std_server(self, mock_server):
# Arrange.
Expand Down

0 comments on commit 5c65a93

Please sign in to comment.