Re-train a frozen .pb model in TensorFlow
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
A frozen .pb model is meant for inference, not normal continued training. Freezing replaces trainable variables with constants, which means the original weights are no longer represented as mutable training state. So the honest answer is: you generally do not re-train a frozen graph directly. Instead, you either go back to the unfrozen checkpoint or use the frozen graph as a fixed feature extractor and train new layers on top.
Why Frozen Graphs Are Hard to Retrain
In TensorFlow 1.x style workflows, freezing converts variables into constant nodes inside the graph. Constants do not receive optimizer updates.
That means the normal training ingredients are missing:
- mutable variables
- optimizer state
- a straightforward save-and-restore training path
So if the original checkpoint still exists, that is the best place to resume training.
Best Option: Go Back to the Original Checkpoint
If you have access to the original training graph and checkpoint files, use those instead of the frozen .pb.
This is the real retraining workflow. The frozen graph should be treated as a deployment artifact, not as the canonical training artifact.
Practical Alternative: Use the Frozen Graph as a Fixed Base
If the checkpoint is gone, the next realistic option is transfer learning: import the frozen graph, identify a useful output tensor, and attach new trainable layers on top.
In legacy TensorFlow 1.x style code, the import step looked like this:
At that point, the imported graph can serve as a fixed feature producer, but not as a fully retrainable network in the original sense.
What Fine-Tuning Looks Like in Practice
The common legacy strategy is:
- load the frozen graph
- locate the input tensor and a useful intermediate or output tensor
- feed data through the frozen base
- train a new classifier or regression head on top of those features
Conceptually, that is closer to transfer learning than full retraining.
If you control a newer TensorFlow or Keras pipeline, the better long-term move is to rebuild the model architecture in a trainable form, load whatever weights you can recover, and continue from there.
Reconstructing the Model Is Sometimes Possible
If you know the original architecture and can extract the constants, you may be able to rebuild a trainable model manually. But that is a reconstruction project, not a normal retraining workflow. It is error-prone, time-consuming, and usually only justified when the original training artifacts are lost and the model is too valuable to discard.
That is why the general engineering advice is simple: keep checkpoints or SavedModels, not just frozen .pb files.
Legacy TensorFlow Context Matters
Questions about frozen .pb files usually come from TensorFlow 1.x workflows. In modern TensorFlow, SavedModel and Keras model saving are better choices because they preserve more of the structure needed for reuse and fine-tuning.
So if you are designing a pipeline today, avoid depending on frozen graphs as the only long-term artifact.
Common Pitfalls
- Assuming a frozen
.pbfile is just a normal training checkpoint in another format. - Trying to run optimizer updates against constants that were created during graph freezing.
- Throwing away the original checkpoint and then expecting full fine-tuning to remain easy later.
- Confusing transfer learning on top of frozen features with true retraining of the original model weights.
- Keeping only deployment artifacts instead of storing trainable model artifacts such as checkpoints or SavedModels.
Summary
- A frozen
.pbmodel is primarily an inference artifact, not a normal retraining artifact. - The best retraining path is to return to the original checkpoint or unfrozen model.
- If that is impossible, treat the frozen graph as a fixed feature extractor and train a new head on top.
- Full reconstruction is possible only in special cases and is usually expensive.
- Preserve trainable artifacts if you expect the model to be updated later.
Related reading
- Read big train/validation/test datasets in tensorflow
- Read in Large CSV File and feed into TensorFlow
- Read mixed data types from CSV row via tf.TextLineReader and tf.decode_csv
- Read mnist images into Tensorflow
- Re-train model with new classes
- Read csv files in a MLFlow pipeline
- Read only mode in keras
- Reading data from bucket in Google ml-engine tensorflow
.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.