2017-09-28 130 views
0

我想導出tensorflow模型像出口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) 
時「無法推斷從形狀NUM」

我不知道?從哪裏來,我猜是從tf.parse_example。我在這裏做錯了什麼想法?

回答

0

不知道完整的原因,該代碼似乎工作不錯

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)()