学习深度学习时,使用 tensorflow 是必不可少的,但是在导入tensorflow中的模块时遇到很多问题,下面对几种常见的问题提供解决方法:
1.导入 mnist 数据集tensorflow == 2.8.0
使用 from tensorflow.examples.tutorials.mnist import input_data,提示没有tensorflow.examples.tutorials模块
解决方法:
2.tensorflow显示没有placeholder、random_normal等模块在你的Python环境中.\PycharmProjects\pythonProject\venv\Lib\site-packages\tensorflow中创建一个新的examples,然后加入tutorials。
tutorials的链接:https://gitee.com/qinlewei/machine_learning.git
此问题说明你的tensorflow版本太高
import tensorflow as tf
print(tf.__version__) # 查看 tensorflow 版本
解决方法:
将 import tensorflow as tf 换成
import tensorflow._api.v2.compat.v1 as tf
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)