How to Suppress Tensorflow warning displayed in result

vinothvs picture vinothvs · Feb 4, 2018 · Viewed 31.5k times · Source

I have a python code connected with Tensorflow. It is supposed to return single result set. But i'm getting below mentioned warning along with result.

WARNING:tensorflow:From C:\Users\vsureshx079451\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\objectives.py:66: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead 2018-02-04 19:12:04.860370: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

Result Here!

I will just put a small snippet of TensorFlow code here. Please let me know how to suppress this warning.

Note: I'm calling this Python file from C#. So i dont want to display anything other than result.

Code Snippet:

self.words = data['words']
        self.classes = data['classes']
        train_x = data['train_x']
        train_y = data['train_y']
        with open('intents.json') as json_data:
            self.intents = json.load(json_data)
        #input("Press Enter to continue...")
        tf.reset_default_graph()
        net = tflearn.input_data(shape=[None, len(train_x[0])])
        net = tflearn.fully_connected(net, 8)
        net = tflearn.fully_connected(net, 8)
        net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax')
        net = tflearn.regression(net)
        # Define model and setup tensorboard
        self.model = tflearn.DNN(net, tensorboard_dir='tflearn_logs')

Edit: I tried this as well, it didn't work.

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

Answer

vinothvs picture vinothvs · Feb 4, 2018

After searching hours together i found answer from Stackoverflow itself, where the answer is provided for different issue. And that solution worked here as well.

Here is the solution for TF 1.x:

tf.logging.set_verbosity(tf.logging.ERROR)

For TF 2.x:

tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

Source: Is there a way to suppress the messages TensorFlow prints?