Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between a regular model checkpoint and a saved model in tensorflow?

Tags:

tensorflow

There's a fairly clear difference between a model and a frozen model. As described in model_files, relevant part: Freezing ...so there's the freeze_graph.py script that takes a graph definition and a set of checkpoints and freezes them together into a single file.

  • Is a "saved_model" most similar to a "frozen_model" (and not a saved "model_checkpoint")?
  • Is this defined somewhere in docs I'm missing?
  • In prior versions of tensorflow we would save and restore model weights, but this seems to be in context of a "model_checkpoint" not a "saved_model", is that still correct?

I'm asking more for the design overview here, not implementation specifics.

like image 381
oooiiiii Avatar asked Mar 09 '19 19:03

oooiiiii


People also ask

What is saved model in TensorFlow?

A SavedModel contains a complete TensorFlow program, including trained parameters (i.e, tf. Variable s) and computation. It does not require the original model building code to run, which makes it useful for sharing or deploying with TFLite, TensorFlow. js, TensorFlow Serving, or TensorFlow Hub.

What is a checkpoint in TensorFlow?

Checkpoints capture the exact value of all parameters ( tf. Variable objects) used by a model. Checkpoints do not contain any description of the computation defined by the model and thus are typically only useful when source code that will use the saved parameter values is available.

What does model checkpoint do?

ModelCheckpoint callback is used in conjunction with training using model. fit() to save a model or weights (in a checkpoint file) at some interval, so the model or weights can be loaded later to continue the training from the state saved.


1 Answers

Checkpoint file only contains variables for specific model and should be loaded with either exactly same, predefined graph or with specific assignment_map to load only chosen variables. See https://www.tensorflow.org/api_docs/python/tf/train/init_from_checkpoint

Saved model is more broad cause it contains graph that can be loaded within a session and training could be continued. Frozen graph, however, is serialized and could not be used to continue training.
You can find all the info here https://www.tensorflow.org/guide/saved_model

like image 174
Sharky Avatar answered Nov 15 '22 06:11

Sharky