diff options
7 files changed, 31 insertions, 31 deletions
diff --git a/tensorflow/contrib/learn/python/learn/estimators/estimator.py b/tensorflow/contrib/learn/python/learn/estimators/estimator.py index 1c74bfeb29..b7b9930ad8 100644 --- a/tensorflow/contrib/learn/python/learn/estimators/estimator.py +++ b/tensorflow/contrib/learn/python/learn/estimators/estimator.py @@ -1218,7 +1218,7 @@ class Estimator(BaseEstimator): @experimental def export_savedmodel( - self, export_dir_base, input_fn, + self, export_dir_base, serving_input_fn, default_output_alternative_key=None, assets_extra=None, as_text=False): @@ -1227,7 +1227,7 @@ class Estimator(BaseEstimator): Args: export_dir_base: A string containing a directory to write the exported graph and checkpoints. - input_fn: A function that takes no argument and + serving_input_fn: A function that takes no argument and returns an `InputFnOps`. default_output_alternative_key: the name of the head to serve when none is specified. Not needed for single-headed models. @@ -1246,14 +1246,14 @@ class Estimator(BaseEstimator): Raises: ValueError: if an unrecognized export_type is requested. """ - if input_fn is None: - raise ValueError('input_fn must be defined.') + if serving_input_fn is None: + raise ValueError('serving_input_fn must be defined.') with ops.Graph().as_default() as g: contrib_variables.create_global_step(g) - # Call the input_fn and collect the input alternatives. - input_ops = input_fn() + # Call the serving_input_fn and collect the input alternatives. + input_ops = serving_input_fn() input_alternatives, features = ( saved_model_export_utils.get_input_alternatives(input_ops)) diff --git a/tensorflow/contrib/learn/python/learn/estimators/estimator_test.py b/tensorflow/contrib/learn/python/learn/estimators/estimator_test.py index 81d2944c94..ffa2e17aec 100644 --- a/tensorflow/contrib/learn/python/learn/estimators/estimator_test.py +++ b/tensorflow/contrib/learn/python/learn/estimators/estimator_test.py @@ -211,12 +211,12 @@ def _build_estimator_for_export_tests(tmpdir): feature_spec = feature_column_lib.create_feature_spec_for_parsing( feature_columns) - export_input_fn = input_fn_utils.build_parsing_serving_input_fn(feature_spec) + serving_input_fn = input_fn_utils.build_parsing_serving_input_fn(feature_spec) # hack in an op that uses an asset, in order to test asset export. # this is not actually valid, of course. - def export_input_fn_with_asset(): - features, labels, inputs = export_input_fn() + def serving_input_fn_with_asset(): + features, labels, inputs = serving_input_fn() vocab_file_name = os.path.join(tmpdir, 'my_vocab_file') vocab_file = gfile.GFile(vocab_file_name, mode='w') @@ -229,7 +229,7 @@ def _build_estimator_for_export_tests(tmpdir): return input_fn_utils.InputFnOps(features, labels, inputs) - return est, export_input_fn_with_asset + return est, serving_input_fn_with_asset class CheckCallsMonitor(monitors_lib.BaseMonitor): @@ -821,7 +821,7 @@ class EstimatorTest(test.TestCase): def test_export_savedmodel(self): tmpdir = tempfile.mkdtemp() - est, export_input_fn = _build_estimator_for_export_tests(tmpdir) + est, serving_input_fn = _build_estimator_for_export_tests(tmpdir) extra_file_name = os.path.join( compat.as_bytes(tmpdir), compat.as_bytes('my_extra_file')) @@ -833,7 +833,7 @@ class EstimatorTest(test.TestCase): export_dir_base = os.path.join( compat.as_bytes(tmpdir), compat.as_bytes('export')) export_dir = est.export_savedmodel( - export_dir_base, export_input_fn, assets_extra=assets_extra) + export_dir_base, serving_input_fn, assets_extra=assets_extra) self.assertTrue(gfile.Exists(export_dir_base)) self.assertTrue(gfile.Exists(export_dir)) diff --git a/tensorflow/contrib/learn/python/learn/experiment_test.py b/tensorflow/contrib/learn/python/learn/experiment_test.py index e537b949f9..545ee38fad 100644 --- a/tensorflow/contrib/learn/python/learn/experiment_test.py +++ b/tensorflow/contrib/learn/python/learn/experiment_test.py @@ -113,9 +113,9 @@ class TestEstimator(evaluable.Evaluable, trainable.Trainable): self.monitors = kwargs['monitors'] return [(key, kwargs[key]) for key in sorted(kwargs.keys())] - def export_savedmodel(self, export_dir_base, export_input_fn, **kwargs): + def export_savedmodel(self, export_dir_base, serving_input_fn, **kwargs): tf_logging.info('export_savedmodel called with args: %s, %s, %s' % - (export_dir_base, export_input_fn, kwargs)) + (export_dir_base, serving_input_fn, kwargs)) self.export_count += 1 return os.path.join( compat.as_bytes(export_dir_base), compat.as_bytes('bogus_timestamp')) diff --git a/tensorflow/contrib/learn/python/learn/utils/export_test.py b/tensorflow/contrib/learn/python/learn/utils/export_test.py index caae60029a..ce1d73256a 100644 --- a/tensorflow/contrib/learn/python/learn/utils/export_test.py +++ b/tensorflow/contrib/learn/python/learn/utils/export_test.py @@ -112,7 +112,7 @@ class ExportTest(test.TestCase): def testExportMonitorInputFeatureKeyMissing(self): random.seed(42) - def _export_input_fn(): + def _serving_input_fn(): return { _X_KEY: random_ops.random_uniform( @@ -123,7 +123,7 @@ class ExportTest(test.TestCase): monitor = learn.monitors.ExportMonitor( every_n_steps=1, export_dir=tempfile.mkdtemp() + 'export/', - input_fn=_export_input_fn, + input_fn=_serving_input_fn, input_feature_key=input_feature_key, exports_to_keep=2, signature_fn=export.generic_signature_fn) @@ -135,13 +135,13 @@ class ExportTest(test.TestCase): random.seed(42) input_feature_key = 'my_example_key' - def _export_input_fn(): + def _serving_input_fn(): return {input_feature_key: None}, None monitor = learn.monitors.ExportMonitor( every_n_steps=1, export_dir=tempfile.mkdtemp() + 'export/', - input_fn=_export_input_fn, + input_fn=_serving_input_fn, input_feature_key=input_feature_key, exports_to_keep=2, signature_fn=export.generic_signature_fn) @@ -154,7 +154,7 @@ class ExportTest(test.TestCase): random.seed(42) input_feature_key = 'my_example_key' - def _export_input_fn(): + def _serving_input_fn(): return { input_feature_key: None, @@ -166,7 +166,7 @@ class ExportTest(test.TestCase): monitor = learn.monitors.ExportMonitor( every_n_steps=1, export_dir=tempfile.mkdtemp() + 'export/', - input_fn=_export_input_fn, + input_fn=_serving_input_fn, input_feature_key=input_feature_key, exports_to_keep=2, signature_fn=export.generic_signature_fn) @@ -178,7 +178,7 @@ class ExportTest(test.TestCase): random.seed(42) input_feature_key = 'my_example_key' - def _export_input_fn(): + def _serving_input_fn(): return { input_feature_key: array_ops.placeholder( @@ -188,7 +188,7 @@ class ExportTest(test.TestCase): monitor = learn.monitors.ExportMonitor( every_n_steps=1, export_dir=tempfile.mkdtemp() + 'export/', - input_fn=_export_input_fn, + input_fn=_serving_input_fn, input_feature_key=input_feature_key, exports_to_keep=2, signature_fn=export.generic_signature_fn) @@ -200,7 +200,7 @@ class ExportTest(test.TestCase): random.seed(42) input_feature_key = 'my_example_key' - def _export_input_fn(): + def _serving_input_fn(): return { input_feature_key: array_ops.placeholder( @@ -214,7 +214,7 @@ class ExportTest(test.TestCase): monitor = learn.monitors.ExportMonitor( every_n_steps=1, export_dir=export_dir, - input_fn=_export_input_fn, + input_fn=_serving_input_fn, input_feature_key=input_feature_key, exports_to_keep=2, signature_fn=export.generic_signature_fn) diff --git a/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils.py b/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils.py index 594a533936..e3315f2107 100644 --- a/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils.py +++ b/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils.py @@ -271,7 +271,7 @@ def garbage_collect_exports(export_dir_base, exports_to_keep): gfile.DeleteRecursively(p.path) -def make_export_strategy(export_input_fn, +def make_export_strategy(serving_input_fn, default_output_alternative_key='default', assets_extra=None, as_text=False, @@ -280,7 +280,7 @@ def make_export_strategy(export_input_fn, """Create an ExportStrategy for use with Experiment. Args: - export_input_fn: A function that takes no arguments and returns an + serving_input_fn: A function that takes no arguments and returns an `InputFnOps`. default_output_alternative_key: the name of the head to serve when an incoming serving request does not explicitly request a specific head. @@ -318,7 +318,7 @@ def make_export_strategy(export_input_fn, """ export_result = estimator.export_savedmodel( export_dir_base, - export_input_fn, + serving_input_fn, default_output_alternative_key=default_output_alternative_key, assets_extra=assets_extra, as_text=as_text) diff --git a/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils_test.py b/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils_test.py index d39c8ec45b..61c76e9d0d 100644 --- a/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils_test.py +++ b/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils_test.py @@ -299,10 +299,10 @@ class SavedModelExportUtilsTest(test.TestCase): def test_make_export_strategy(self): """Only tests that an ExportStrategy instance is created.""" - def _export_input_fn(): + def _serving_input_fn(): return array_ops.constant([1]), None export_strategy = saved_model_export_utils.make_export_strategy( - export_input_fn=_export_input_fn, + serving_input_fn=_serving_input_fn, default_output_alternative_key="default", assets_extra={"from/path": "to/path"}, as_text=False, diff --git a/tensorflow/contrib/tensor_forest/client/random_forest.py b/tensorflow/contrib/tensor_forest/client/random_forest.py index 4f7dda0e5b..99abe06683 100644 --- a/tensorflow/contrib/tensor_forest/client/random_forest.py +++ b/tensorflow/contrib/tensor_forest/client/random_forest.py @@ -358,13 +358,13 @@ class TensorForestEstimator(evaluable.Evaluable, trainable.Trainable): @experimental def export_savedmodel(self, export_dir_base, - input_fn, + serving_input_fn, default_output_alternative_key=None, assets_extra=None, as_text=False): return self._estimator.export_savedmodel( export_dir_base, - input_fn, + serving_input_fn, default_output_alternative_key=default_output_alternative_key, assets_extra=assets_extra, as_text=as_text) |