我正在尝试导出一个tensorflow模型,比如
feature_spec = { 'words': tf.FixedLenSequenceFeature([], tf.int64, allow_missing=True) }
def serving_input_receiver_fn():
"""Build the serving inputs."""
serialized_tf_example = tf.placeholder(dtype=tf.string,
shape=[1],
name='input_example_tensor')
features = tf.parse_example(serialized_tf_example, feature_spec)
receiver_tensors = {'words': serialized_tf_example}
return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)
export_dir = classifier.export_savedmodel(export_dir_base=args.job_dir,
serving_input_receiver_fn=serving_input_receiver_fn)但是我收到了这个错误
Cannot infer num from shape (1, ?, 128, 128)我不知道这个?是从哪里来的,我猜它来自tf.parse_example。你知道我哪里做错了吗?
发布于 2017-09-29 01:17:40
在不知道完整原因的情况下,这段代码似乎工作得很好
def serving_input_receiver_fn():
feature_spec = { "words": tf.FixedLenFeature(dtype=tf.int64, shape=[4]) }
return tf.estimator.export.build_parsing_serving_input_receiver_fn(feature_spec)()https://stackoverflow.com/questions/46474151
复制相似问题