Tensorflow 中模块问题

Tensorflow 中模块问题,第1张

学习深度学习时,使用 tensorflow 是必不可少的,但是在导入tensorflow中的模块时遇到很多问题,下面对几种常见的问题提供解决方法:

tensorflow == 2.8.0

1.导入 mnist 数据集

使用 from tensorflow.examples.tutorials.mnist import input_data,提示没有tensorflow.examples.tutorials模块

解决方法:

在你的Python环境中.\PycharmProjects\pythonProject\venv\Lib\site-packages\tensorflow中创建一个新的examples,然后加入tutorials。


 tutorials的链接:https://gitee.com/qinlewei/machine_learning.git

2.tensorflow显示没有placeholder、random_normal等模块

此问题说明你的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()

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/langs/568344.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存