Search code examples
pythonpython-3.xtensorflowkeras

How to suppress all autograph warnings from Tensorflow?


I'm getting a warning which I cannot find a solution to. Apparently this:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # or any {'0', '1', '2'}
import tensorflow as tf
os.environ['AUTOGRAPH_VERBOSITY'] = '1'

is not enough to stop this annoying message:

WARNING:tensorflow:AutoGraph could not transform <function Model.make_train_function.<locals>.train_function at 0x00000281A55264C8> 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: Bad argument number for Name: 4, expecting 3
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert

which pops up after every single epoch.

And yes, I've decorated every function I have with @tf.autograph.experimental.do_not_convert and the message still pops up. I am currently using Tensorflow 2.2.0

If you know the reason why this is happening, that would be great. I have no clue what "Name" is, as nothing is called that anywhere in any of my files.


Solution

  • Try this:

    tf.autograph.set_verbosity(0)
    

    If that doesn't work, perhaps the logging module could be of help here:

    import logging
    logging.getLogger("tensorflow").setLevel(logging.ERROR) # this goes *before* tf import
    import tensorflow as tf
    

    Thanks @Shahrokh Bah for adding that comment.