How to use freeze_graph.py tool in TensorFlow v1
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 v1, freeze_graph.py is used to combine a graph definition with checkpoint weights and produce a frozen graph file, usually a .pb file. Freezing replaces variable nodes with constants so the graph can be deployed without a separate checkpoint.
This is a TensorFlow v1 workflow, so the main challenge is not the command itself. It is knowing which graph file, checkpoint prefix, and output node names to pass into the tool.
What You Need Before Freezing
You typically need:
- a graph definition file such as
.pbtxt - a checkpoint prefix such as
model.ckpt-1000 - the names of the output nodes
If any of those are wrong, the freeze step will fail or produce a graph that loads but is unusable.
The checkpoint argument is usually the prefix, not the individual .index or .data file.
Typical freeze_graph.py Command
That command tells TensorFlow:
- where the graph structure lives
- which checkpoint contains the trained variable values
- which nodes must remain reachable in the frozen output
Everything not needed to reach the output nodes can be pruned away.
Why Output Node Names Matter
The output nodes define the part of the graph you want to keep. If you freeze with the wrong output node names, TensorFlow may discard the layers you actually need.
A practical way to inspect node names inside a v1 graph is:
Once you identify the final inference nodes, pass those names to freeze_graph.py.
This is usually the step that takes the most care, because a syntactically successful freeze can still be useless if the wrong outputs were preserved.
A Minimal Training-and-Freeze Example
After running that script, the freeze step can use:
When Freezing Is Useful
Freezing is useful when you want:
- one portable inference graph
- no separate checkpoint files
- simpler deployment to older TF1-style inference pipelines
It is less about training and more about packaging the trained model for inference.
In other words, freeze_graph.py belongs near the end of a TensorFlow v1 workflow, after training and before deployment or offline inference export.
Common Pitfalls
- Passing the wrong output node names and pruning away needed computation.
- Pointing to
.indexor.datafiles instead of the checkpoint prefix. - Trying to use TensorFlow v2 habits directly with a v1 freeze workflow.
- Freezing a training graph instead of the inference graph.
- Forgetting that
freeze_graph.pybelongs to older TensorFlow tooling and expects a TF1-style graph/checkpoint setup.
Summary
- '
freeze_graph.pyin TensorFlow v1 converts a graph plus checkpoint into a frozen.pbgraph.' - You need the graph file, checkpoint prefix, and correct output node names.
- Output node names determine what part of the graph is preserved.
- Freezing is mainly for inference packaging, not for training.
- Most failures come from wrong node names or wrong checkpoint arguments, not from the freeze tool itself.
Related reading
- How to use graph convolutional neural network GCNN to predict the appropriate patterns to solve an scheduling problem
- How to use Huggingface Trainer with multiple GPUs?
- How to use hyperopt for hyperparameter optimization of Keras deep learning network?
- How to use image_summary to view images from different batches in Tensorflow?
- how to use GridSearchCV with custom estimator in sklearn?
- How to use Hugging Face Transformers library in Tensorflow for text classification on custom data?
- How to use Isolation Forest
- How to use k-fold cross validation in a neural network

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the 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.