如何抑制resu中显示的Tensorflow警告

2024-05-15 08:54:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个与Tensorflow连接的python代码。它应该返回单个结果集。但我得到下面提到的警告和结果。

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!

我将在这里放一小段TensorFlow代码。请告诉我如何取消此警告。

注意:我从C#调用这个Python文件。所以我不想显示结果以外的任何东西。

代码段:

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')

编辑: 我也试过了,没用。

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

Tags: 代码selfjson警告datanettensorflowwith
1条回答
网友
1楼 · 发布于 2024-05-15 08:54:07

在一起搜索了几个小时后,我从Stackoverflow本身找到了答案,在那里,答案是针对不同的问题提供的。这个解决方案在这里也有效。

以下是解决方案:

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

资料来源: Is there a way to suppress the messages TensorFlow prints?

相关问题 更多 >