Tuesday, September 26, 2017

Loading SavedModel is a lot slower than loading a tf.train.Saver checkpoint

Leave a Comment

I changed from tf.train.Saver to the SavedModel format which surprisingly means loading my model from disk is a lot slower (instead of a couple of seconds it takes minutes). Why is this and what can I do to load the model faster?

I used to do this:

# Save model saver = tf.train.Saver() save_path = saver.save(session, model_path)  # Load model saver = tf.train.import_meta_graph(model_path + '.meta') saver.restore(session, model_path) 

But now I do this:

# Save model builder = tf.saved_model.builder.SavedModelBuilder(model_path) builder.add_meta_graph_and_variables(session, [tf.saved_model.tag_constants.TRAINING]) builder.save()  # Load model tf.saved_model.loader.load(session, [tf.saved_model.tag_constants.TRAINING], model_path) 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment