keras icon indicating copy to clipboard operation
keras copied to clipboard

Unexpected depreciation warning in tensorflow 2.16.1

Open whichedge opened this issue 1 year ago • 3 comments

Python 3.12 tensorflow 2.16.1 keras 3.3.3 Windows 11

I have just updated to tensorflow 2.16.1 and am going through my code checking of compatablity. When I import my tensorflow code I get the warning:

**WARNING:tensorflow:From \venv\Lib\site-packages\keras\src\backend\common\global_state.py:82: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

The warning points to line 82 in global_state.py in the keras backend, which uses the correct statement (tf.compat.v1.reset_default_graph). I have pin pointed this warning coming from my use of keras.backend.clear_session().

Is this warning valid? Because from what I can see the depreciated tf.reset_default_graph is not used

EDIT: I have got my tensorflow code running and so far it seems to be work without giving any errors....it has called the keras.backend.clear_session() several times and no errors.

whichedge avatar Jun 06 '24 07:06 whichedge

I'm not able to notice the warning in the latest TensorFlow version when the keras.backend.clear_session() is used, Keras uses tf.compat.v1.reset_default_graph in the code as mentioned below

https://github.com/keras-team/keras/blob/f6c4ac55692c132cd16211f4877fac6dbeead749/keras/src/backend/common/global_state.py#L82

sachinprasadhs avatar Jun 13 '24 16:06 sachinprasadhs

As I couldn't find a reason for the warning either, that's why I raised the issue, it's probably my installation, in the next couple of weeks I'll be transfering the code to a Linux machine, I'll see what happens and report back. In the mean time how do I supress this warning? It's filling my console with red text!

whichedge avatar Jun 18 '24 18:06 whichedge

You can follow this https://www.tensorflow.org/api_docs/python/tf/keras/config/disable_interactive_logging and this here https://stackoverflow.com/questions/14463277/how-to-disable-python-warnings

sachinprasadhs avatar Jun 21 '24 18:06 sachinprasadhs

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Jul 06 '24 01:07 github-actions[bot]

It must be something to do with my installation on my Windows machine, because I don't get the error on my Linux machine. Thanks for your help.

whichedge avatar Jul 16 '24 18:07 whichedge

@whichedge , Could you please close the issue of you don't have anymore questions. Thanks

sachinprasadhs avatar Jul 16 '24 21:07 sachinprasadhs

Thanks for your help... closing

whichedge avatar Jul 21 '24 19:07 whichedge

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Jul 21 '24 19:07 google-ml-butler[bot]