解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is ....问题

解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecate问题

我使用的是tensorflow1.x版本,做了一些简单的深度学习测试,但是在我使用pycharm运行代码的时候,总是会报出如下图的代码警告:

解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is ....问题

我尝试过使用如下命令, 或者修改numpy的版本(尝试和多种numpy版本,均不行):

import os

os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

但是依然没有办法解决,所以真正的解决办法如下:

解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is ....问题

在pycharm中,点击警告提示,进入dtypes.py文件,对如下图的这段代码进行修改:

修改前:

解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is ....问题

修改后: 只需将每行的最后一个1修改为:(1,)即可,如下如

解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is ....问题

修改完成后,再测试一段简单的代码

解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is ....问题

问题解决!!!

上一篇:pycharm bash: 第 0 行:cd: D:/xxxxxxx: 没有那个文件或目录


下一篇:Python IDE PyCharm的快捷键大全(三)