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

后端 未结 2 1230
陌清茗
陌清茗 2021-02-01 03:40

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

2条回答
  •  深忆病人
    2021-02-01 03:53

    I am by no ways an expert in Tensorflow, but if I had to take a guess as to why this is happening, I would say that:

    • tf.train.Saver(), saves a complete meta-graph. Therefore, all the information needed to perform any operations contained in your graph is already there. All tensorflow needs to do to load the model, is insert the meta-graph into the default/current graph and you're good to go.
    • The SavedModelBuilder() on the other hand, behind the scene creates a language agnostic representation of your operations and variables. Which means that the loading method has to extract all the information, then recreate all the operation and variables from your previous graph, and insert them into the default/current graph.

    Depending on the size of your graph, recreating everything that it contained might take some time.

    Concerning the second question, as @J H said, if there are no reasons for you to use one strategy over the other, and time is of the essence, then just go with the fastest one.

提交回复
热议问题