def export_model(self): """Export a model to tensorflow SavedModel.""" mode = utils.INFER graph = tf.Graph() with graph.as_default(): infer_model = self.build_export_model() infer_model.sess = tf.Session(config=self.session_conf) infer_model.saver = tf.train.Saver() model_path = self.get_model_path(mode) infer_model.saver.restore(infer_model.sess, save_path=model_path) to_saved_model(self.config, infer_model.sess, infer_model.export_inputs, infer_model.output_dict)
def export_model(self): """Export a model to tensorflow SavedModel.""" inputs = self.build_inputs(utils.INFER) self.build() logits = self.model(inputs.input_x_dict) score = tf.nn.softmax(logits) self.session.run(tf.global_variables_initializer()) self.session.run(tf.tables_initializer()) self.session.run(inputs.iterator.initializer) weights_ckpt_dir = tf.train.latest_checkpoint(self.checkpoint_dir) self.model.load_weights(weights_ckpt_dir) output_dict = {"score": score} to_saved_model(self.config, self.session, inputs.input_x_dict, output_dict)