Skip to content

How can I export the model as serving format? #4

@tcclks

Description

@tcclks

To export estimator m there are four steps:
1.Define estimator's features.

2.Create a feature config.

3.Build an export_input_fn suitable for use in serving.

4.Export the model using export_savedmodel().

I try to use :
export_dir_base = "./serving_save_model"
feature_spec = {
'times': tf.placeholder(tf.float32, name='times')
}
serving_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(feature_spec)

estimator.export_savedmodel(export_dir_base, serving_input_fn)
But I encountered an error like this:

Traceback (most recent call last):
File "E:/MyProject/Py/tensorFlow_time_series_predict/train_lstm_multivariate.py", line 231, in
estimator.export_savedmodel(export_dir_base, serving_input_fn)
File "H:\ProgramFiles\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\estimator\estimator.py", line 504, in export_savedmodel
serving_input_receiver = serving_input_receiver_fn()
File "H:\ProgramFiles\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\estimator\export\export.py", line 142, in serving_input_receiver_fn
features = parsing_ops.parse_example(serialized_tf_example, feature_spec)
File "H:\ProgramFiles\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\parsing_ops.py", line 577, in parse_example
[VarLenFeature, SparseFeature, FixedLenFeature, FixedLenSequenceFeature])
File "H:\ProgramFiles\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\parsing_ops.py", line 291, in _features_to_raw_params
raise ValueError("Invalid feature %s:%s." % (key, feature))
ValueError: Invalid feature times:Tensor("times:0", dtype=float32).

How should I use it correctly?
Thanks so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions