我尝试导出tf.estimator.DNNClassifier模型时出错.我怎么能保存这个?

Joh*_*sto 5 python machine-learning python-3.x tensorflow tensorflow-estimator

我创建了我的估算器:

estimator = tf.estimator.DNNClassifier(
   hidden_units=[500, 100],
   feature_columns=[embedded_text_feature_column],
   n_classes=2,
   optimizer=tf.train.AdagradOptimizer(learning_rate=0.003))
Run Code Online (Sandbox Code Playgroud)

并进行以下培训:

estimator.train(input_fn=train_input_fn, steps = 2)
Run Code Online (Sandbox Code Playgroud)

完成这两个步骤后,我想保存我的模型/估算器.我尝试了以下方法:

# NOT SURE IF THE FOLLOWING FUNCTION IS CORRECT
def serving_input_receiver_fn():
  """Build the serving inputs."""
  # The outer dimension (None) allows us to batch up inputs for
  # efficiency. However, it also means that if we want a prediction
  # for a single instance, we'll need to wrap it in an outer list.

  inputs = {"x": tf.placeholder(shape=[None, 4], dtype=tf.float32)}
  return tf.estimator.export.ServingInputReceiver(inputs, inputs)

export_dir = classifier.export_savedmodel(
  export_dir_base="/home/suhail/tensorflow-stubs/",
  serving_input_receiver_fn=serving_input_receiver_fn)
Run Code Online (Sandbox Code Playgroud)

但这引发了一个错误说:Feature sentence if not in features dictionary.我在doc_classification_with_tf_hub中训练了doc中给出的模型

我做错了什么?