其他分享
首页 > 其他分享> > [警告] FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a

[警告] FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a

作者:互联网

警告信息

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)])
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)])
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)])
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)])
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)])
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)])
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)])
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)])
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)])
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)])
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)])
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)])

系统环境

原因分析

TensorFlow 2.0.b1的版本下,如果Numpy的版本超过了1.17,那么就会出现这个警告。
这个问题已经在 GitHub 的 PR #30559 [2] 中得到了解决,不出意外的话,在TensorFlow的下个版本中,应该就不会再出现这个警告了。

解决方案

有如下三种临时解决方案:

1. 回退版本

既然高版本(Numpy 1.17.0rc1)会报错,那么稍微降低版本不就可以了!?!

pip install "numpy<1.17"

2. 暂时忽略报错

根据网友 njanirudhGra-tak解决方案 [1],暂时忽略报错是一个不错的选择,毕竟这个报错目前还没有负面影响。在导入tensorflow之前,导入warnings包:

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

import tensorflow as tf

当然,这会暂时忽略所有的FutureWarning报错。

3. 物我两忘

它报任它报,物我而兼忘。

Reference

  1. njanirudh, Gra-tak. (September 22, 2019). FutureWarning: Deprecated numpy API calls in tf.python.framework.dtypes. Retrieved from https://github.com/tensorflow/tensorflow/issues/30427
  2. yongtang. (September 22, 2019). Fix numpy warning with numpy 1.17.0+. Retrieved from https://github.com/tensorflow/tensorflow/pull/30559

标签:synonym,numpy,future,deprecated,np,Passing,type,FutureWarning
来源: https://blog.csdn.net/xovee/article/details/101170113