栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

机器学习-JupyterNotebook使用中的错误集锦

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

机器学习-JupyterNotebook使用中的错误集锦

目录

系统Windows10,Python3.9

1.改变jupyter的文件存储路径

2.调用module中的错误

(1)module 'numpy' has no attribute '_version_'

(2)TensorFlow

1)module 'numpy' has no attribute '_version_'

2)The Session graph is empty. Add operations to the graph before calling run().


 

系统Windows10,Python3.9

1.改变jupyter的文件存储路径

(1)通过Windows进入

WIN+R打开运行,输入cmd-输入jupyter notebook --generate-config显示新生成的jupyter_notebook_config.py文件的用户目录,用Notepad++或者记事本打开该文件,通过Ctrl+F调出查找窗口,输入The directory to use for notebooks,点击查找下一个,c.NotebookApp.notebook_dir = 'E:jupyter'(改为新的存储路径,我的是E:jupyter),

注意:一定要把前面的#去掉

(2)通过快捷方式进入

在开始界面找到jupyter notebook的快捷方式,右键-更多-打开文件所在位置-找到jupyter notebook,右键-属性-目标中.py之后的后缀去掉,换成"E:jupyter"(新的存储路径),如下图所示:

2.调用module中的错误

(1)module 'numpy' has no attribute '_version_'

import numpy 

numpy.__version__(version前后是_ _,两个连着的下划线,不是一个,亲测有用!!!)

我出这个错误看了好多相关回帖,解决方案包括:numpy的卸载重新安装;安装TensorFlow,如果和我一样是小白刚刚下载,拜托先看看前后的下划线长不长吧呜呜~

(2)TensorFlow

tensorflow2.0后的版本一些语句命令有变化

1)module 'numpy' has no attribute '_version_'

输入tf.Session报错module 'numpy' has no attribute '_version_',是版本原因,将语句改为tf.compat.v1.Session()

2)The Session graph is empty. Add operations to the graph before calling run().

解决方案:加入tf.compat.v1.disable_eager_execution()该语句

 如下示例:

import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello=tf.constant('Hello,tensorflow')
sess=tf.compat.v1.Session()
print(sess.run(hello))

(作为一个学习笔记,帮助自己后面学习和巩固,也希望大家不要和我一样因为一个小问题纠结好几天了) 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/864241.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号