decision-forests icon indicating copy to clipboard operation
decision-forests copied to clipboard

WARNING:tensorflow:5 out of the last 5 calls to <InferenceCoreModel.make_predict_function. predict_function_trained > tf.function retracing

Open AnushangaWimalasena opened this issue 2 years ago • 1 comments

I'm using tensorflow_decision_forests-1.0.1 in tensorflow==2.10.0. First I got the following warning when using the model.evaluate(test_ds, return_dict=True).

WARNING: AutoGraph could not transform <function simple_ml_inference_op_with_handle at 0x7f4e341ba440> and will run it as-is. Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause: could not get source code To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert

Then I use tf.autograph.set_verbosity(1).

Ather that following warning shows.

WARNING:tensorflow:5 out of the last 5 calls to <function InferenceCoreModel.make_predict_function..predict_function_trained at 0x7f7c544fa3b0> 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 reduce_retracing=True option 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.

Can anyone say what are those warnings and how can I fix them? Any help would be appreciated.

AnushangaWimalasena avatar Sep 16 '22 11:09 AnushangaWimalasena

@AnushangaWimalasena what happens if you run your code with an older tensorflow_decision_forests version?

geraldstanje avatar Sep 20 '22 12:09 geraldstanje

This has been fixed with 2fc493c5e186d1a62d773c97385e09d6002b66a2

rstz avatar Sep 11 '23 15:09 rstz