Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF 1.x: remove the "deprecated" warning messages #27023

Closed
erikchwang opened this issue Mar 22, 2019 · 31 comments
Closed

TF 1.x: remove the "deprecated" warning messages #27023

erikchwang opened this issue Mar 22, 2019 · 31 comments

Comments

@erikchwang
Copy link

I know the functional APIs, such as tf.layers.dense, will disappear in TF 2.0. However, their alternatives, tf.keras.layers, are not compatible with other components of TF 1.x, for example, they even do not support variable scope (#27016). So I will stick on the deprecated APIs in TF 1.x.
Would you please remove the disgusting "deprecated" warning messages like this: xxx (from tensorflow.python.layers.core) is deprecated and will be removed in a future version. Use keras.layers.xxx instead.

@shashvatshahi1998
Copy link
Contributor

You can use this:-
import os
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

In detail:-
0 = all messages are logged (default behavior)
1 = INFO messages are not printed
2 = INFO and WARNING messages are not printed
3 = INFO, WARNING, and ERROR messages are not printed

@erikchwang
Copy link
Author

this is what i have been using for years
it cannot stop the deprecation warning

@erikchwang
Copy link
Author

By the way, before deprecating old components, would you please complete the current functionality? See #27042. It seems that TF is very good at deprecating widely used functions, but poor at improving its weak points

@mihaimaruseac
Copy link
Collaborator

mihaimaruseac commented Mar 22, 2019

Deprecation messages are needed to inform people who want to use an actual version of TensorFlow what is going to happen in the future, and give them time to adapt.

As such, we won't be able to remove these messages. You can disable them for yourself using this private API

import tensorflow.python.util.deprecation as deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False

@erikchwang
Copy link
Author

Thanks
See #27045, any suggestions?

@skylogic004
Copy link

skylogic004 commented Jun 12, 2019

This code gave me an error:

import tensorflow.python.util.deprecation as deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False
AttributeError: module 'tensorflow' has no attribute 'python'

But changing the import line made it work (and suppresses the deprecation warnings as desired):

from tensorflow.python.util import deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False

Thanks

@mihaimaruseac
Copy link
Collaborator

@skylogic004 is this from a recent nightly/build from source from recent master?

@skylogic004
Copy link

@mihaimaruseac Oh, I'm using tf 1.13 from anaconda (I'm not familiar with what branch & build it would have come from originally, sorry, but maybe this is enough info for you?).

$ python
Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v.1900 64 bit (AMD64)] on win32  
Type "help", "copyright", "credits" or "license" for more information.                                          
>>> import tensorflow as tf                                                                                     
>>> tf.__version__                                                                                              
'1.13.1'                                                                                                        

$ conda list | grep tensor
tensorboard               1.13.1           py36h33f27b4_0
tensorflow                1.13.1          gpu_py36h1635174_0
tensorflow-base           1.13.1          gpu_py36h0fff12a_0
tensorflow-estimator      1.13.0                     py_0
tensorflow-gpu            1.13.1               h0d30ee6_0

Link to anaconda package: https://anaconda.org/anaconda/tensorflow-gpu

@mihaimaruseac
Copy link
Collaborator

Then it's not something I should worry about (full context: over the past week there have been some failures on imports due to some changes I made; but those are only on master code, which doesn't seem to be the case)

@de-code
Copy link

de-code commented Aug 8, 2019

Deprecation warnings are important for developers. They may not be all that useful to users. Therefore there are situations where it is desirable to switch them off.

Python has sys.warnoptions which could be for example set via PYTHONWARNINGS, e.g.:
PYTHONWARNINGS=ignore.

TensorFlow has it's own TF_CPP_MIN_LOG_LEVEL option as pointed out earlier.

And there is also the TensorFlow Python logging API (which I believed worked before):

import tensorflow as tf

tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

That none of the options above are preventing the warning messages from being printed seem to be a bug.

The _PRINT_DEPRECATION_WARNINGS flag seems to be internal and may be removed any time.

EDIT: Apologies, I was confusing the numpy FuturreWarnings for tensorflow warnings. The last option to set the logging level should generally still work.

@mrgloom
Copy link

mrgloom commented Aug 22, 2019

On 1.14.0 only this works:

import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

@figroc
Copy link

figroc commented Sep 12, 2019

For r1.14 and onward, try this:

try:
    from tensorflow.python.util import module_wrapper as deprecation
except ImportError:
    from tensorflow.python.util import deprecation_wrapper as deprecation
deprecation._PER_MODULE_WARNING_LIMIT = 0

Anyway, it is internal and subjects to change.

@mihaimaruseac
Copy link
Collaborator

Or switch to TF2.0 where deprecation warnings are removed (as not needed).

@jubjamie
Copy link
Contributor

Unless you use a good selection of IDE's :p
Only thing that made me roll back was the autocomplete issue so these suppression requests are valid imo.

@mihaimaruseac
Copy link
Collaborator

Autocompletion has been mostly solved

@pyotr777
Copy link

pyotr777 commented Oct 24, 2019

Tried all of what have been suggested:

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
from tensorflow.python.util import deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False
try:
    from tensorflow.python.util import module_wrapper as deprecation
except ImportError:
    from tensorflow.python.util import deprecation_wrapper as deprecation
deprecation._PER_MODULE_WARNING_LIMIT = 0

Still, have a pile of warnings.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
TF version 1.14.0

Ubuntu 16.04
Python 3.6.8

@figroc
Copy link

figroc commented Oct 24, 2019 via email

@mihaimaruseac
Copy link
Collaborator

@pyotr777 those come from numpy. You are using a numpy version that is slightly incompatible with the TF version you're using.

At the risk of getting more downvotes, please switch to 2.0

@bhushanbrb
Copy link

FutureWarning

import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=FutureWarning)

did not supress

/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])

@bhushanbrb
Copy link

bhushanbrb commented Jan 9, 2020

For me this worked for t2.0 warning

import tensorflow as tf
tf.get_logger().warning('test')
# WARNING:tensorflow:test
tf.get_logger().setLevel('ERROR')
tf.get_logger().warning('test')

FYI Logging in TensorFlow changed as TF_CPP_MIN_LOG_LEVEL is not working Anymore

@TiwaPhil
Copy link

TiwaPhil commented Jan 14, 2020

Still, have a pile of warnings.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])

Please tried one at a time to change the 1 to 0 eg: _np_qint8 = np.dtype([("qint8", np.int8, 1)]) to _np_qint8 = np.dtype([("qint8", np.int8, 0)]) that works for me

@mihaimaruseac
Copy link
Collaborator

@TiwaPhil #27023 (comment)

@TiwaPhil
Copy link

solve warnings

@pyotr777
Copy link

pyotr777 commented Jan 15, 2020

You are using a numpy version that is slightly incompatible with the TF version you're using.

For me worked putting

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)

before

import tensorflow as tf

and all other imports.

I have TF 1.14.0 and numpy 1.18.1.

@szuer2018
Copy link

szuer2018 commented Feb 16, 2020

before import tensorflow, you should implement:
import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
warnings.filterwarnings('ignore', category=DeprecationWarning)
it works for tensorflow==1.12.0, numpy==1.18.1, python 3.6

@mikeyEcology
Copy link

mikeyEcology commented Feb 20, 2020

I tried this:

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
warnings.filterwarnings('ignore', category=DeprecationWarning)

And it did not work for me when I ran python non-interactively tensorflow==1.14.0, numpy==1.18.1, python==3.6.10, but it did work in an interactive session.

@mikeyEcology
Copy link

mikeyEcology commented Feb 21, 2020

I found that the following worked when I run python both interactively and non-interactively. When using tensorflow 2.X, you can use:

import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)

And when using tensorflow 1.X (worked on 1.14 for me):

import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

jjfiv added a commit to toybox-rs/Toybox that referenced this issue Apr 11, 2020
etosch added a commit to toybox-rs/Toybox that referenced this issue Apr 11, 2020
@zchrissirhcz

This comment has been minimized.

@destinyzs
Copy link

destinyzs commented Sep 25, 2020

I tried all methods, but none of them worked in jupyter notebook...

warnings.filterwarnings('ignore',category=FutureWarning)
This can ignore warnings when importing tensorflow, but there still exists many many many WARN if i load model...

@alcasla
Copy link

alcasla commented Jan 15, 2021

This work for me on python 3.6 and TensorFlow 2.2. Inspired from @bhushanbrb, thanks.

import tensorflow as tf
tf.get_logger().setLevel('ERROR')

@BishwaBS
Copy link

BishwaBS commented Jun 8, 2021

You are using a numpy version that is slightly incompatible with the TF version you're using.

For me worked putting

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)

before

import tensorflow as tf

and all other imports.

I have TF 1.14.0 and numpy 1.18.1.

This indeed works. I tried every other suggestions provided above but none of them worked for me. But, this worked like a charm

@tensorflow tensorflow locked and limited conversation to collaborators Jun 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests