title: TF Estimator: Can't Load *.pb from Saved Model
body: <p>I create a simple model using TF Estimator and save the model using <code>export_savedmodel</code> function. I use a simple Iris dataset which has 4 features.</p>
  
  <pre><code>num_epoch = 50
  num_train = 120
  num_test = 30
  
  # 1 Define input function
  def input_function(x, y, is_train):
      dict_x = {
          "thisisinput" : x,
      }
  
      dataset = tf.data.Dataset.from_tensor_slices((
          dict_x, y
      ))
  
      if is_train:
          dataset = dataset.shuffle(num_train).repeat(num_epoch).batch(num_train)
      else:   
          dataset = dataset.batch(num_test)
  
      return dataset
  
  def my_serving_input_fn():
      input_data = {
          "thisisinput" : tf.placeholder(tf.float32, [None, 4], name='inputtensors')
      }
      return tf.estimator.export.ServingInputReceiver(input_data, input_data)
  
  def main(argv):
      tf.set_random_seed(1103) # avoiding different result of random
  
      # 2 Define feature columns
      feature_columns = [
          tf.feature_column.numeric_column(key="thisisinput",shape=4),
      ]
  
      # 3 Define an estimator
      classifier = tf.estimator.DNNClassifier(
          feature_columns=feature_columns,
          hidden_units=[10],
          n_classes=3,
          optimizer=tf.train.GradientDescentOptimizer(0.001),
          activation_fn=tf.nn.relu,
          model_dir = 'modeliris2/'
      )
  
      # Train the model
      classifier.train(
          input_fn=lambda:input_function(xtrain, ytrain, True)
      )
  
      # Evaluate the model
      eval_result = classifier.evaluate(
          input_fn=lambda:input_function(xtest, ytest, False)
      )
  
      print('\nTest set accuracy: {accuracy:0.3f}\n'.format(**eval_result))
      print('\nSaving models...')
      classifier.export_savedmodel("modeliris2pb", my_serving_input_fn)
  
  if __name__ == "__main__":
      os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 
      tf.app.run(main)
  </code></pre>
  
  <p>After running the program, it produces a folder which contains <code>saved_model.pb</code>. I see many tutorials suggest to use <code>contrib.predictor</code> to load <code>saved_model.pb</code> but I can't. I've use <code>contrib.predictor</code> function to load the model:</p>
  
  <pre><code>def main(a):
      with tf.Session() as sess:
          PB_PATH= "modeliris2pb/1536219836/"
          predict_fn = predictor.from_saved_model(PB_PATH)
  
  if __name__=="__main__":
      main()
  </code></pre>
  
  <p>But it yields an error:</p>
  
  <blockquote>
    <p>ValueError: Got signature_def_key "serving_default". Available
    signatures are ['predict']. Original error: No SignatureDef with key
    'serving_default' found in MetaGraphDef.</p>
  </blockquote>
  
  <p>Is there another way that is better to load *.pb files? Why does this error happen? I'm suspicious it is because the <code>my_serving_input_fn()</code> function, but I don't know why</p>