Pre-trained checkpoints .chkpt Vs GraphDef .pb
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
In TensorFlow, a checkpoint and a GraphDef .pb file solve different problems even though both are associated with saved models. A checkpoint is primarily about restoring variables so you can resume or reuse model state, while a GraphDef .pb file is a serialized computation graph, often used for inference-oriented export in older TensorFlow workflows.
What a Checkpoint Contains
A TensorFlow checkpoint stores variable values and the information needed to restore those variables into a compatible object graph. In practical terms, checkpoints are for state restoration.
Typical uses include:
- continuing interrupted training
- loading pre-trained weights into the same model architecture
- restoring optimizer state when the checkpoint tracks it
A minimal TensorFlow 2 example looks like this.
After restoration, weight returns to the saved value.
The important point is that a checkpoint does not stand alone as a full deployable inference artifact. It assumes you know what variables should exist and where they belong.
What a GraphDef .pb File Contains
A GraphDef .pb file is a serialized protobuf representation of a TensorFlow graph. In older TensorFlow 1.x workflows, it was common to freeze a graph so that variable values became constants embedded into the graph, producing a single inference-oriented .pb file.
A small TensorFlow 2 example can still produce a frozen GraphDef.
That .pb file describes computation. In a frozen graph scenario, it may also contain the constant values needed for inference.
The Practical Difference
The simplest mental model is:
- checkpoint equals restorable state
- GraphDef
.pbequals serialized graph structure
That difference drives how each format is used.
If you want to fine-tune a model, continue training, or swap weights into the same architecture, use a checkpoint.
If you want an older-style inference graph that can be loaded and executed as a frozen computation, a .pb graph is the relevant artifact.
Why Confusion Happens
Many pre-trained TensorFlow models used to ship as a mix of graph files, checkpoint files, label maps, and config files. People would see both a checkpoint and a .pb file in the same project and assume they were interchangeable.
They are not.
A checkpoint generally needs compatible code or an equivalent object structure to restore into. A frozen .pb graph is closer to a portable inference representation, but it is less convenient for further training because the variables may no longer exist as variables.
Legacy TensorFlow vs Current Practice
The checkpoint-versus-GraphDef distinction comes mostly from TensorFlow 1.x mental models. In current TensorFlow workflows, you will more often see:
- checkpoints for training state
- '
SavedModelfor export and serving' - '
.kerasfor Keras-native saving workflows'
That means raw .pb questions are often legacy deployment questions rather than the default modern recommendation.
Still, understanding the distinction matters when you inherit older pre-trained model packages or need to convert legacy assets.
Common Pitfalls
The most common mistake is trying to resume training from a .pb graph as if it were a normal checkpoint.
Another mistake is assuming a checkpoint is self-sufficient for inference deployment. It is not, because the runtime still needs the compatible model structure.
A third issue is mixing TensorFlow 1.x terminology with TensorFlow 2 saving APIs without noticing that the preferred export formats changed.
Finally, do not assume that a file extension tells the whole story. The actual contents and the surrounding loading code matter.
Summary
- A checkpoint stores variable state for restoration and continued model use.
- A GraphDef
.pbfile stores a serialized computation graph, often for legacy inference export. - Checkpoints are the right tool for resuming training or loading weights into a compatible model.
- Frozen
.pbgraphs are more aligned with inference than with ongoing training. - In modern TensorFlow,
SavedModeland.kerasare often more relevant than raw GraphDef files. - When working with pre-trained assets, identify whether you need state restoration or graph export before choosing the format.
Related reading
- Predict single Image after training model in tensorflow
- Predicting a probability of a sentence using tensorflow
- Predicting a single image with Keras' ImageDataGenerator
- Predicting next word using the language model tensorflow example
- Problem with Dataloader object not subscriptable
- Problem with missing and unexpected keys while loading my model in Pytorch
- Precision/recall for multiclass-multilabel classification
- Precomputed Kernels with LibSVM in Python
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.