我有一個 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 回圈中嘗試了許多不同的方法來阻止它彈出但沒有成功。有沒有一種方法可以禁用所有警告?
uj5u.com熱心網友回復:
用這個:
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
uj5u.com熱心網友回復:
你可以試試這個:
將張量流匯入為 tf
匯入作業系統
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/388180.html
上一篇:嘗試向Python字典添加新鍵時出現keyerrorpython
下一篇:如何使用熊貓資料列印圖形?
