运行tensorflow代码出现dtypes.py:516: FutureWarning: Passing (type, 1) or '1type的解决方法

使用tensorflow写的深度学习模型,在服务器上跑模型时老是弹出/anaconda3/envs/tf/lib/python3.5/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'.

运行tensorflow代码出现dtypes.py:516: FutureWarning: Passing (type, 1) or '1type的解决方法

弹出这个的原因是tensorflow版本与numpy版本不匹配。

解决方法:

第一种方法:

降低numpy版本。我的是tensorflow-gpu 1.14.0与numpy 1.17.2,不匹配,换成numpy 1.16.0就可以了

先卸载当前版本的numpy :

pip uninstall numpy

再安装低版本的numpy:

pip install numpy==1.16.0

如果安装下载速度太慢,可以转换为清华源(速度很快):

pip install numpy==1.16.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

如果1.16.0版本还不行,就再降低几个版本看看,都不行的话可以使用第二种方法试试

第二种方法:

解决方法来源于该博客