def serving_input_receiver_fn():
"""
A function to use for input processing when serving the model.
NOTES:
1) This should still work, but I haven't tested it since using I think TensorFlow 1.2.1
"""
feature_spec = {'str': tf.FixedLenFeature([1], tf.string)}
serialized_tf_example = tf.placeholder(dtype=tf.string, name='input_example_tensor')
receiver_tensors = {'example': serialized_tf_example}
features = tf.parse_example(serialized_tf_example, feature_spec)
# I could probably not do this and handle the data better within the graph
features['str'] = tf.reshape(features['str'], [-1])
data = full_onehot_process_line_as_2d_input(features['str'])
return tf.estimator.export.ServingInputReceiver(data, receiver_tensors)
评论列表
文章目录