What does that code snippet signify tf.logging.set_verbositytf.logging.INFO in tensorflow code?
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
tf.logging.set_verbosity(tf.logging.INFO) is a TensorFlow 1.x style logging call. It tells TensorFlow to emit messages at the INFO level and above, which usually means you will see informational, warning, error, and fatal messages, but not debug-level noise.
What It Means in TensorFlow 1.x
TensorFlow 1.x exposed a logging API through tf.logging. The set_verbosity function sets the minimum severity level that the TensorFlow logger should print. When the level is INFO, ordinary status messages become visible.
That matters for old training scripts because many helper APIs log useful progress only at INFO. If the verbosity is higher, such as WARN, those messages are suppressed and the script can look silent even though it is working.
Here is a minimal example using the compatibility namespace that still exists in current TensorFlow:
With the level set to INFO, the debug message is hidden, while the info and warn messages are shown.
The Logging Levels
The levels are ordered from least severe to most severe:
- '
DEBUG' - '
INFO' - '
WARN' - '
ERROR' - '
FATAL'
Think of set_verbosity as a threshold. Messages below the threshold are dropped. Messages at or above it are emitted.
This is why INFO is a common default in examples. It gives you progress updates without the volume of DEBUG.
The Modern TensorFlow 2 Equivalent
In TensorFlow 2, the old tf.logging namespace is legacy code. Newer code usually goes through tf.get_logger() or plain Python logging. If you are reading a current codebase, that is the style you are more likely to see.
This modern form expresses the same basic intent: show INFO and more severe messages.
There is one more layer to be aware of. Some TensorFlow runtime messages come from native code rather than the Python logger. Those are often controlled with the TF_CPP_MIN_LOG_LEVEL environment variable.
That example suppresses lower-severity C++ runtime messages. It is useful when startup logs are too noisy, but it is separate from tf.compat.v1.logging.set_verbosity(...).
When You Still See This Snippet
You will still encounter this line in older tutorials, TensorFlow 1.x notebooks, and migration code that lives under tf.compat.v1. It usually exists for one of two reasons:
- the author wanted readable training progress in the console
- the script relied on hooks or utilities that emit
INFOmessages
So if you see the snippet in old code, do not over-interpret it. It does not change model math, performance, or randomness. It only changes what gets printed.
Common Pitfalls
A common mistake is assuming this call affects every log source in the process. It does not. Python's standard logging module, TensorFlow compatibility logging, and TensorFlow C++ runtime logs can each have their own controls.
Another mistake is copying tf.logging into modern TensorFlow 2 code without the compatibility namespace. In current TensorFlow, the safe migration path is tf.compat.v1.logging for old code and tf.get_logger() for new code.
Developers also sometimes expect this setting to change Keras progress bars or notebook cell output. Those are separate display mechanisms and may not respond to logger verbosity in the way you expect.
Summary
- '
tf.logging.set_verbosity(tf.logging.INFO)is a TensorFlow 1.x logging threshold setting.' - It enables
INFO,WARN,ERROR, andFATALmessages while hidingDEBUGmessages. - In modern TensorFlow, prefer
tf.get_logger().setLevel(logging.INFO). - This setting changes console logging, not model behavior.
- Native TensorFlow runtime logs may require
TF_CPP_MIN_LOG_LEVELinstead.
Related reading
- What does the function control_dependencies do?
- What does the print of DMA and tensorflow mean? And is it possible to set them?
- What does the property losses of the Bayesian layers of TensorFlow Probability represent?
- what does the question mark in tensorflow shape mean?
- What events should go through the RAFT log
- What happens when I reboot an EC2 instance?
- What does the value of 'leaf' in the following xgboost model tree diagram means?
- What does visibility Timeout mean for AWS SQS

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
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.