Col*_*ole 5 python keras tensorflow
我有一个 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.
Run Code Online (Sandbox Code Playgroud)
我在 for 循环中尝试了许多不同的方法来阻止它弹出,但没有成功。有没有一种简单的方法可以禁用所有警告?
小智 8
您可以使用它来避免警告:
import os
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
Run Code Online (Sandbox Code Playgroud)
小智 6
用这个:
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10563 次 |
| 最近记录: |