title: Inference result with .pb file does not match with .h5
body: <p>I have trying to deploy my ai-model to GCP's AI-Platform, and looks like I'm succeed, but the inference result is incorrect compare to local h5 model inference result. </p>
  
  <p>I'm using tensorflow==1.2.1, Keras==2.0.6, Python 3.5.3 now.</p>
  
  <p>I used <code>K.set_learning_phase()</code> to distinguish training/inference phase, re-created my model using previous config/weights, saved the new model by SavedModelBuilder.</p>
  
  <pre class="lang-py prettyprint-override"><code>def save_model_for_production(model, version, path='prod_models'):
      K.set_learning_phase(0)  # all new operations will be in test mode from now on
  
      # serialize the model and get its weights, for quick re-building
      config = model.get_config()
      weights = model.get_weights()
  
      # re-build a model where the learning phase is now hard-coded to 0
  
      new_model = model.from_config(config)
      # from keras.models import model_from_config
      # new_model = model_from_config(config)
      # new_model = Model.from_config(config)
      new_model.set_weights(weights)
  
  
      model_input = tf.saved_model.utils.build_tensor_info(new_model.input)   # deprecated
      model_output = tf.saved_model.utils.build_tensor_info(new_model.output)
  
      prediction_signature = (
          tf.saved_model.signature_def_utils.build_signature_def(
              inputs={tf.saved_model.signature_constants.PREDICT_INPUTS: model_input},
              outputs={tf.saved_model.signature_constants.PREDICT_OUTPUTS: model_output},
              method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME))
  
      with K.get_session() as sess:
          sess.run(tf.global_variables_initializer())
          #init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
          #sess.run(init_op)
          #sess.run(tf.saved_model.main_op.main_op())
  
          if not os.path.exists(path):
              os.mkdir(path)
  
          export_path = os.path.join(
              tf.compat.as_bytes(path),
              tf.compat.as_bytes(version))
          builder = tf.saved_model.builder.SavedModelBuilder(export_path)
  
          builder.add_meta_graph_and_variables(
              sess=sess, tags=[tf.saved_model.tag_constants.SERVING],
              signature_def_map={
                  'predict':
                     prediction_signature
              })
          builder.save()
  </code></pre>
  
  <p>I guess that variable was not initialized correctly. I tried several <code>tf.global_variables_initializer()</code>, <code>tf.local_variables_initializer()</code> , etc and the inference result is different each other. (e.g. [1.0], [0.0], [3.2314555e-13])</p>
  
  <p>But I did not get the right results with anything.</p>
  
  <p>If anyone knows how to solve this, I would appreciate your help.</p>