WARNING:tensorflow:5 out of the last 177 calls to <function Model.make_predict_function.<locals>.predict_function at 0x0000021A23B39A60> 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.
时间: 2023-06-14 14:08:20 浏览: 241
VC.Web.service.instance.calls.rar_The Test_VC Web service_vc ser
这是一个TensorFlow的警告信息,它提示在模型预测时出现了大量的tf.function retracing,这可能是由于在循环中重复创建@tf.function,传递不同形状的张量或传递Python对象而不是张量等原因导致的。针对这些问题,可以将@tf.function定义在循环外部,使用experimental_relax_shapes=True选项放宽参数形状,或者参考文档进行更改,以减少不必要的重新跟踪。
阅读全文