python - 如何抑制结果中显示的 Tensorflow 警告

标签 python tensorflow tflearn

<分区>

我有一个与 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'

最佳答案

一起搜索几个小时后,我从 Stackoverflow 本身找到了答案,其中针对不同的问题提供了答案。该解决方案也适用于此。

这是 TF 1.x 的解决方案:

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

对于 TF 2.x:

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

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

关于python - 如何抑制结果中显示的 Tensorflow 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48608776/

相关文章:

python - 如何在 python 中使用 numba.jit 将计算值传递给列表排序?

tensorflow - 使用三元组损失和预训练的 resnet 时形状不兼容

python - 在 Keras 中,为什么必须根据神经网络的输出来计算损失函数?

python - Tensorflow:如何设计自定义成本函数?

python - 在 tflearn 中可视化 CNN 层或池化层

python - pysvn.Client.callback_ssl_server_trust_prompt 错误

python - Cassandra 十进制精度问题

python - Django 测试用例,可以在类/模块级别加载夹具吗?

TFlearIndexError 越界

machine-learning - 如何使用tflearn深度学习进行文档分类