如何解决如何禁用FutureWarning:不建议将type,1或'1type'作为type的同义词传递?
由于tensorflow和numpy版本不匹配,似乎在tensorflow导入时发生此警告(如import tensorflow as tf
)。
python3 -c "import numpy as np;print(np.__version__)"
1.19.2
python3 -c "import tensorflow as tf;print(tf.__version__)"
1.14.0
如何禁用此警告?
/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)])
/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type,)type'.
_np_quint8 = np.dtype([("quint8",np.uint8,1)])
/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type,)type'.
_np_qint16 = np.dtype([("qint16",np.int16,1)])
/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type,)type'.
_np_quint16 = np.dtype([("quint16",np.uint16,1)])
/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type,)type'.
_np_qint32 = np.dtype([("qint32",np.int32,1)])
/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type,)type'.
np_resource = np.dtype([("resource",np.ubyte,1)])
/usr/local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type,1)])
/usr/local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type,1)])
/usr/local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type,1)])
/usr/local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type,1)])
/usr/local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type,1)])
/usr/local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type,1)])
解决方法
import warnings
warnings.filterwarnings('ignore')
在.py文件顶部添加此代码似乎有所帮助。
https://github.com/tensorflow/tensorflow/issues/30427#issuecomment-522920338
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。