我有一个for循环,其中包含几个不同的深度学习模型,这些模型产生了以下警告:
WARNING:tensorflow:5 out of the last 5 calls to <function Model.make_predict_function.<locals>.predict_function at 0x000001B0A8CC90D0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for more details.
WARNING:tensorflow:6 out of the last 6 calls to <function Model.make_predict_function.<locals>.predict_function at 0x000001B0A6C01940> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for more details.我在for循环中尝试了许多不同的东西来阻止它弹出,但没有成功。是否有一种简单的方法来禁用所有警告?
发布于 2021-12-21 03:07:58
用这个:
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)发布于 2021-12-21 07:52:38
您可以使用它来避免警告:
import os
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'发布于 2021-12-21 14:36:57
只需将tensorflow记录器设置为错误:
import tensorflow as tf
tf.get_logger().setLevel('ERROR')https://stackoverflow.com/questions/70429982
复制相似问题