ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

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

2019-09-22 21:08:30  阅读:499  来源: 互联网

标签:synonym numpy future deprecated np Passing type FutureWarning


警告信息

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

系统环境

  • Ubuntu 18.4 LTS
  • Python 3.6
  • TensorFlow 2.0.0-beta1
  • NumPy 1.17.2

原因分析

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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有