如何抑制结果中显示的 Tensorflow 警告 [英] How to Suppress Tensorflow warning displayed in result
问题描述
我有一个与 Tensorflow 相关的 Python 代码.它应该返回单个结果集.但是我收到了下面提到的警告和结果.
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.
警告:张量流:来自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
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
我将在这里放一小段 TensorFlow 代码.请让我知道如何抑制此警告.
I will just put a small snippet of TensorFlow code here. Please let me know how to suppress this warning.
注意:我从 C# 调用这个 Python 文件.所以我不想显示结果以外的任何东西.
Note: I'm calling this Python file from C#. So i dont want to display anything other than result.
代码片段:
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 本身找到了答案,其中为不同的问题提供了答案.该解决方案也适用于此.
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.
这是 TF 1.x 的解决方案:
Here is the solution for TF 1.x:
tf.logging.set_verbosity(tf.logging.ERROR)
对于 TF 2.x:
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
这篇关于如何抑制结果中显示的 Tensorflow 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!