tensorflow 报告 warning FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/net_wolf/article/details/99733243

最近每次启动tensorflow总是报告一堆warning,没有什么影响,但是看着烦人。

它的问题根本是numpy的版本和tensorflow不匹配导致的。

C:\Users\Joy9\MyPythonWork>python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.
C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:523: 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)])
C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:524: 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)])
C:\Program Files\Python36\lib\site-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_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:526: 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)])
C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:527: 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)])
C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:532: 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和numpy 版本 :

C:\Users\Joy9\MyPythonWork>pip list |findstr tensorflow
tensorflow               1.10.0
tensorflow-gpu           1.10.0

C:\Users\Joy9\MyPythonWork>pip list |findstr numpy
numpy                    1.17.0
numpydoc                 0.8.0

尝试重新安装numpy,会报告不兼容:

C:\Users\Joy9\MyPythonWork>pip install numpy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/c1/a58630a439aa10a285169b4a122bc9f7a9a4392e4ec39602f0a60b2693db/numpy-1.17.0-cp36-cp36m-win_amd64.whl
ERROR: -ensorflow-gpu 1.10.0 has requirement numpy<=1.14.5,>=1.13.3, but you'll have numpy 1.17.0 which is incompatible.
ERROR: tensorflow 1.10.0 has requirement numpy<=1.14.5,>=1.13.3, but you'll have numpy 1.17.0 which is incompatible.
ERROR: tensorflow-gpu 1.10.0 has requirement numpy<=1.14.5,>=1.13.3, but you'll have numpy 1.17.0 which is incompatible.
Installing collected packages: numpy
Successfully installed numpy-1.17.0

安装指定的numpy 版本,会报告imgaug模块不兼容

C:\Users\Joy9\MyPythonWork>pip install numpy==1.14.5
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy==1.14.5
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0d/b7/0c804e0bcba6505f8392d042d5e333a5e06f308e019517111fbc7767a0bc/numpy-1.14.5-cp36-none-win_amd64.whl
ERROR: imgaug 0.2.9 has requirement numpy>=1.15.0, but you'll have numpy 1.14.5 which is incompatible.
Installing collected packages: numpy
Successfully installed numpy-1.14.5

最后发现把imgaug设定为版本0.2.7不会有兼容问题:

C:\Users\Joy9\MyPythonWork>pip install imgaug==0.2.7
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting imgaug==0.2.7
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/af/fc/c56a7da8c23122b7c5325b941850013880a7a93c21dc95e2b1ecd4750108/imgaug-0.2.7-py3-none-any.whl (644kB)
     |████████████████████████████████| 645kB 298kB/s
Requirement already satisfied: Shapely in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (1.6.4.post2)
Requirement already satisfied: imageio in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (2.5.0)
Requirement already satisfied: scikit-image>=0.11.0 in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (0.15.0)
Requirement already satisfied: Pillow in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (5.4.1)
Requirement already satisfied: numpy>=1.7.0 in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (1.14.5)
Requirement already satisfied: six in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (1.12.0)
Requirement already satisfied: matplotlib in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (3.0.3)
Requirement already satisfied: scipy in c:\program files\python36\lib\site-packages (from imgaug==0.2.7) (1.2.0)
Requirement already satisfied: PyWavelets>=0.4.0 in c:\program files\python36\lib\site-packages (from scikit-image>=0.11.0->imgaug==0.2.7) (1.0.3)
Requirement already satisfied: networkx>=2.0 in c:\program files\python36\lib\site-packages (from scikit-image>=0.11.0->imgaug==0.2.7) (2.3)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\program files\python36\lib\site-packages (from matplotlib->imgaug==0.2.7) (2.3.1)
Requirement already satisfied: cycler>=0.10 in c:\program files\python36\lib\site-packages (from matplotlib->imgaug==0.2.7) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in c:\program files\python36\lib\site-packages (from matplotlib->imgaug==0.2.7) (2.8.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\program files\python36\lib\site-packages (from matplotlib->imgaug==0.2.7) (1.0.1)
Requirement already satisfied: decorator>=4.3.0 in c:\program files\python36\lib\site-packages (from networkx>=2.0->scikit-image>=0.11.0->imgaug==0.2.7) (4.3.2)
Requirement already satisfied: setuptools in c:\program files\python36\lib\site-packages (from kiwisolver>=1.0.1->matplotlib->imgaug==0.2.7) (39.1.0)
Installing collected packages: imgaug
Successfully installed imgaug-0.2.7

重新看看环境是否有还有warning:

C:\Users\Joy9\MyPythonWork>python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.
>>> exit()

问题解决。

猜你喜欢

转载自blog.csdn.net/net_wolf/article/details/99733243
今日推荐