旧版吴恩达深度学习环境搭建(anaconda+tensorflow+jupyter notebook)(呕心沥血诚意之作) |
您所在的位置:网站首页 › mc指令下载旧版 › 旧版吴恩达深度学习环境搭建(anaconda+tensorflow+jupyter notebook)(呕心沥血诚意之作) |
本人在参考多位博主的文章后,多次尝试才成功配置了tensorflow1.2.1的环境(课程建议Python3.6+tensorflow1.2.1+Keras2.0.7)。在此之前,曾经尝试用tensorflow2.x降级的方法(import tensorflow.compat.v1 as tf),运行课后作业,但是存在诸多问题,不得不弃用2.x版本,进而构建tensorflow1.2.1的环境。如果要使用tensorflow2.x的环境,可以配套使用新版的吴恩达教授深度学习课程。(本人用的旧版课程)。 目录 1.anaconda下载 2.tensorflow环境配置 2.1 创建虚拟环境 2.2 安装tensorflow 2.3 安装keras 3.安装和配置jupyter 3.1 使用命令行安装 4.安装需要使用的库 5. 附录:记录一些可能用到的指令 主要参考文章: 1.吴恩达课程编程环境配置windows 2. 吴恩达2022版深度学习第二部分Annaconda+Tensorflow环境搭建 3. 在anaconda环境下安装旧版本TensorFlow1.8 1.anaconda下载本人使用anaconda的版本Anaconda3-2023.03-1-Windows-x86_64(当时官网下载的最新版本),在anaconda.org可以免费下载(free download)。安装过程和一些环境变量的配置大同小异,可以参考其他博客,这里就不进行赘述。 2.tensorflow环境配置参考文章:吴恩达课程编程环境配置windows 作业中使用到了TensorFlow与Keras,相应的版本为 python:3.6.0 tensorflow:1.2.1 keras:2.0.7 2.1 创建虚拟环境在搜索栏中搜索“Anaconda Prompt”并运行 打开 Anaconda Prompt 之后,输入命令: 创建虚拟环境,命名为dltf,编译器为python3.6 conda create --name dltf python=3.6.0激活环境(从base环境切换到dltf环境) activate dltf 参考文章:吴恩达2022版深度学习第二部分Annaconda+Tensorflow环境搭建 安装tensorflow1.2.1,输入pip install tensorflow==1.2.1(-i后面是镜像源的名字,这里用到是清华的) pip install tensorflow==1.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple安装好之后,查看python和tensorflow的版本 python >>>import tensorflow as tf >>>tf.__version__ (dltf) C:\Windows\System32>python Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py:458: 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'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py:459: 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'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py:460: 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'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py:461: 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'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py:462: 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'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py:465: 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'. np_resource = np.dtype([("resource", np.ubyte, 1)]) >>> tf.__version__ '1.2.1' >>>这里查出了tensorflow的版本,但是有警告。我们需要复制dtypes.py的路径,打开dtypes.py,然后进行修改(是你自己的路径,跟我的不同,图中看出路径为E:\develop+\anaconda3\envs\dltf\lib\site-packages\tensorflow\python\framework\dtypes.py) 文件打开是这样的 这里的前缀是你的anaconda安装地址,运行结果里也会显示。出错的行数也可能不同,具体看你的运行过程了。我测试后发现需要将报错的几个都修改一下,就不会再出现了。对报警的行进行修改。修改时要把命令行先关了。 将我的458行的_np_quint8 = np.dtype([(“quint8”, np.uint8, 1)])改为 _np_quint8 = np.dtype([("quint8", np.uint8, (1,))])这里参考了:在anaconda环境下安装旧版本TensorFlow1.8 原版: _np_qint8 = np.dtype([("qint8", np.int8, 1)]) _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) _np_qint16 = np.dtype([("qint16", np.int16, 1)]) _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) _np_qint32 = np.dtype([("qint32", np.int32, 1)])修改后: _np_qint8 = np.dtype([("qint8", np.int8, (1,))]) _np_quint8 = np.dtype([("quint8", np.uint8, (1,))]) _np_qint16 = np.dtype([("qint16", np.int16, (1,))]) _np_quint16 = np.dtype([("quint16", np.uint16, (1,))]) _np_qint32 = np.dtype([("qint32", np.int32, (1,))])后面还有一句(第465行的警告) #np_resource = np.dtype([("resource", np.ubyte, 1)]) np_resource = np.dtype([("resource", np.ubyte, (1,))]) 2.3 安装keras安装keras pip install keras==2.0.7 -i https://pypi.tuna.tsinghua.edu.cn/simple 3.安装和配置jupyter 3.1 (方法一)使用命令行安装 pip install --user jupyter -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com这里的--trusted-host pypi.douban.com,是将豆瓣源设为可信任 。 出现错误 ERROR: Command errored out with exit status 1 参考了:pip install 时报错:ERROR: Command errored out with exit status 1: python setup.py egg_inf 需要更新一下pip #更新pip pip install --upgrade setuptools && python -m pip install --upgrade pip #然后重新安装jupyter pip install --user jupyter -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com此时仍然出现很多warning,我们等会解决 运行jupyter notebook jupyter notebook#有可能出现的问题:打开的notebook网页在运行时出现kernel error: 参考了:kernel error 解决办法 python -m ipykernel install --user #然后再重新启动jupyter notebook以上问题都解决后,就继续安装需要使用的库了。 3.2 (方法二)使用anaconda navigator安装直接在导航中安装,如果安装卡了很久的话,有可能是pip没更新 #更新pip pip install --upgrade setuptools && python -m pip install --upgrade pip我是在命令行安装后,才从navigator中再安装的。如果直接安装的话,可能会遇到一些问题,可以尝试先用命令行装。其他问题可以参考:吴恩达2022版深度学习第二部分Annaconda+Tensorflow环境搭建 4.安装需要使用的库安装matplotlib pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple安装pillow pip install pillow==8.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple安装spicy pip install spicy -i https://pypi.tuna.tsinghua.edu.cn/simple然后作业中缺什么包,用同样的方法安装就行了。 到此为止,就可顺利运行作业了。 5. 附录:记录一些可能用到的指令(参考用,使用时可适当修改,随手记录一下) conda clean --packages --tarballs 清除conda缓存 conda remove -n tensorflow1.2.1(环境的名字) --all #删除环境 conda create -n tensorflow1.2.1 python=3.6 #安装python3.6 pip install tensorflow==1.2.1 -i https://mirrors.aliyun.com/pypi/simple/ python -m pip install --upgrade pip #先更新pip conda install ipython -i https://mirrors.aliyun.com/pypi/simple/ pip install --user tensorflow==1.2.1 --upgrade https://blog.csdn.net/Erick2020/article/details/119706076 pip install --user jupyter -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com #jupyter的安装(在管理员模式下--user可以去掉) pip install jupyter -i http://pypi.douban.com/simple/ 使用anaconda的版本Anaconda3-2023.03-1-Windows-x86_64 conda env list #查看环境列表 pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |