【问题标题】:How to Suppress Tensorflow warning displayed in result [duplicate]如何抑制结果中显示的Tensorflow警告[重复]
【发布时间】:2018-07-14 11:52:45
【问题描述】:

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

警告:张量流:来自 C:\Users\vsureshx079451\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\objectives.py:66: 调用reduce_sum(来自tensorflow.python.ops.math_ops) keep_dims 已弃用,将在未来版本中删除。 更新说明:keep_dims 已弃用,请使用 keepdims 相反 2018-02-04 19:12:04.860370: 我 C:\tf_jenkins\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] 您的 CPU 支持此 TensorFlow 二进制文件不支持的指令 编译使用:AVX AVX2

结果在这里!

我将在这里放一小段 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'

【问题讨论】:

    标签: python tensorflow tflearn


    【解决方案1】:

    一起搜索几个小时后,我从 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?

    【讨论】:

    • 但是如果我使用的是 keras 而不是直接使用 tensorflow 该怎么办
    • 对我有用,适用于 keras 和 tf.keras 模型
    • 不推荐使用名称 tf.logging.set_verbosity。请改用tf.compat.v1.logging.set_verbosity。名称 tf.logging.ERROR 已弃用。请改用tf.compat.v1.logging.ERROR
    • 结合这两种方法我得到了最好的结果。
    猜你喜欢
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 2011-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    相关资源
    最近更新 更多