Skip to content Skip to sidebar Skip to footer

Disabling Keras Or Tensorflow Outputs

I know that there are already some similar questions here on stackoverflow but none of them solved my problem. In a python script, I have to train a keras model multiple times and

Solution 1:

I use this simple approach, works for me.

# tacke future warning, deprecated warning, bla bla import warnings

# ------------ tackle some noisy warningdefwarn(*args, **kwargs):
    pass
warnings.warn = warn
warnings.simplefilter(action="ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category = DeprecationWarning)

'''
TF_CPP_MIN_LOG_LEVEL = 0 to all logs .
TF_CPP_MIN_LOG_LEVEL = 1 to filter out INFO logs 
TF_CPP_MIN_LOG_LEVEL = 2 to additionall filter out WARNING 
TF_CPP_MIN_LOG_LEVEL = 3 to additionally filter out ERROR.
'''
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'# now import tf import tensorflow as tf

Solution 2:

This tutorial in the Tensorflow Documenation discusses using metadata DB(MLMD) APIs to prevent the printing of outputs. This might apply to your application.

Post a Comment for "Disabling Keras Or Tensorflow Outputs"