logging.info("Exporting prediction graph to %s", output_dir)
with tf.Session(graph=tf.Graph()) as sess:
// Build and save prediction meta graph and trained variable values.
input_signatures, output_signatures = self.build_prediction_graph()
// Remove this if once Tensorflow 0.12 is standard.
try:
init_op = tf.global_variables_initializer()
except AttributeError:
init_op = tf.initialize_all_variables()
sess.run(init_op)
trained_saver = tf.train.Saver()
trained_saver.restore(sess, last_checkpoint)
predict_signature_def = signature_def_utils.build_signature_def(
input_signatures, output_signatures,
signature_constants.PREDICT_METHOD_NAME)
// Create a saver for writing SavedModel training checkpoints.
build = builder.SavedModelBuilder(
os.path.join(output_dir, "saved_model"))
build.add_meta_graph_and_variables(