How to merge not all summaries 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
When working with TensorBoard summaries, you do not have to merge every summary operation in the graph. In TensorFlow, the right approach is to either merge a selected list of summaries directly or organize summaries into separate collections so you can write only the subset you care about.
Select Specific Summaries in TensorFlow 1.x
In TensorFlow 1.x style code, tf.summary.merge_all() collects everything from the default summary collection. If you want only some summaries, build them separately and pass only those operations to tf.summary.merge.
Now you control exactly which merged op is run in each phase.
Use Collections to Organize Summaries
Another clean TensorFlow 1.x pattern is to put summaries into named collections and merge by collection later.
This scales better when a graph has many summaries and you want a structured way to separate train, eval, debug, or profiling views.
TensorFlow 2.x Usually Does Not Need Merge Ops
In TensorFlow 2.x, summary writing is usually imperative rather than graph-merged. You simply write the summaries you want inside the current writer context.
In this model, "merge not all summaries" usually just means "write only the summaries relevant for this step or phase."
That is one reason many old TensorFlow 1.x summary questions feel different from TensorFlow 2.x code. In 1.x you grouped ops in the graph, while in 2.x you more often decide at runtime which writes to emit.
Why Selective Merging Helps
Writing every summary at every step can slow training, clutter TensorBoard, and make it harder to focus on the metrics that matter. Selective merging or selective writing is useful when:
- training metrics should be recorded more often than evaluation metrics,
- expensive histograms should be logged rarely,
- debug summaries should be isolated from normal experiment output.
This is less about syntax and more about keeping logging intentional.
If you only care about training loss every step but want histograms every hundred steps, selective writing is the difference between a usable TensorBoard run and a noisy, slow one.
Common Pitfalls
- Using
merge_all()and then wondering why every summary shows up everywhere. - Forgetting that TensorFlow 1.x graph collections are different from TensorFlow 2.x eager summary writing.
- Logging too many heavy summaries, such as histograms or images, at every step.
- Mixing train and eval summaries into one stream without a clear naming or collection strategy.
- Assuming summary merging changes the metric values themselves rather than just grouping write operations.
Summary
- In TensorFlow 1.x, use
tf.summary.merge([...])to merge only the summaries you choose. - Collections are a good way to organize train, eval, and debug summaries separately.
- In TensorFlow 2.x, selective summary writing usually replaces explicit merge logic.
- Log only the summaries that help you debug or monitor the current phase.
- Keeping summary output intentional makes TensorBoard easier to use and cheaper to write.
Related reading
- How to Merge Numerical and Embedding Sequential Models to treat categories in \`RNN\`
- How to Merge Numerical and Embedding Sequential Models to treat categories in `RNN`
- How to merge two saved keras model?
- How to monitor a filtered version of a metric in EarlyStopping callback in tensorflow?
- How to monitor gradient vanish and explosion in keras with tensorboard?
- how to normalize input data for models in tensorflow
- How to monitor dead relus
- How to monitor the status of model training running on the server via fast-api
.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.