tensorflow: DNNClassifier estimator cannot be exported
Please go to Stack Overflow for help and support:
https://stackoverflow.com/questions/tagged/tensorflow
If you open a GitHub issue, here is our policy:
- It must be a bug or a feature request.
- The form below must be filled out.
- It shouldn’t be a TensorBoard issue. Those go here.
Here’s why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.
System information
- tensorflow/tensorflow:latest container
- ubuntu linux
- installed from pip
- TensorFlow version ‘v1.2.0-5-g435cdfc’, ‘1.2.1’:
- Python 2.7:
- Bazel version (if compiling from source):
Exact command to reproduce
classifier = DNNClassifier(feature_columns=feature_columns,
hidden_units=[10, 20, 10],
n_classes=3,
model_dir=model_path)
classifier.export_savedmodel(MODEL_PATH, script.serving_input_receiver_fn)
Describe the problem
Trying to export the model DNNClassifier throws the exception:
Exception during training: A default input_alternative must be provided.
Traceback (most recent call last):
File "algo.py", line 78, in train
nn.export_savedmodel(MODEL_PATH, script.serving_input_receiver_fn, default_output_alternative_key=None)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1280, in export_savedmodel
actual_default_output_alternative_key)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils.py", line 259, in build_all_signature_defs
raise ValueError('A default input_alternative must be provided.')
The problem happens because DNNClassifier constructor creates a head with name None: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/estimators/dnn.py#L365
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 25 (10 by maintainers)
Hello @samithaj
Canned estimator don’t have a lot of documentation yet. Here it go my code:
Hope it helps you!
Cool, @mvsusp .
By the way, if
tf.feature_columnis used,feature_speccan be generated automatically, like:Hi @facaiy
The issue was solved using tf.estimator.export.build_parsing_serving_input_receiver_fn.
Thank you!
@Anmol-Sharma I guess you need to return export_outputs in your model_fn, like
@AKhilGarg91
I got the too many values to unpack on 1.4, too.
a small dig into that I changed
tf.estimator.export.build_parsing_serving_input_receiver_fntotensorflow.contrib.learn.build_parsing_serving_input_fnIn
tensorflow/contrib/learn/python/learn/utils/saved_model_export_utils.pyline 157-161In
InputFnOps, it saysSeems the new class causes the error.
should change to something like
My work around is to use
tensorflow.contrib.learn.build_parsing_serving_input_fninstead for now.thanks @mvsusp Check here anyone looking for complete example: https://github.com/MtDersvan/tf_playground
@mvsusp Can you please post the fixed code for your example ,I’m trying tho export and serve a DNNLinearCombinedRegressor model , and i cant find any working example