Tensorflow+Tutoria 关于吴恩达深度学习课后作业无法运行的解决方案

Tensorflow+Tutoria 关于吴恩达深度学习课后作业无法运行的解决方案

Welcome to this week’s programming assignment. Until now, you’ve always used numpy to build neural networks. Now we will step you through a deep learning framework that will allow you to build neural networks more easily. Machine learning frameworks like TensorFlow, PaddlePaddle, Torch, Caffe, Keras, and many others can speed up your machine learning development significantly. All of these frameworks also have a lot of documentation, which you should feel free to read. In this assignment, you will learn to do the following in TensorFlow:

参考文章

https://blog.csdn.net/goryeon/article/details/102985990 安装低版本的tensorflow
https://pypi.tuna.tsinghua.edu.cn/simple/tensorflow/ TensorFlow下载地址1
https://pypi.org/project/tensorflow/#files TensorFlow下载地址2
https://blog.csdn.net/weixin_45033674/article/details/103562690 作业中的tensorflow版本的问题

正文 遇到的问题(报错)

No module named 'tensorflow'
ModuleNotFoundError: No module named ‘tensorflow’
NameError: name ‘tf’ is not defined

问题所在

conda 中未安装TensorFlow,目前直接安装将会下载2.0版本之后的,而高版本对于本次作业不兼容,有些代码无法使用

注:无法使用的代码:

init = tf.global_variables_initializer()      # When init is run later (session.run(init)),
                                                 # the loss variable will be initialized and ready to be computed
with tf.Session() as session:                    # Create a session and print the output
    session.run(init)                            # Initializes the variables
    print(session.run(loss))                     # Prints the loss

解决方式:

如果已经安装了tensorflow:

查看目前版本pip show tensorflow
卸载目前版本:pip uninstall tensorflow
查看自己的python版本号为3.8,然后进行降级到3.6
(这里没注意是python版本限制下不了还是源的问题)

更换镜像源:将清华滤镜网站置顶

(输入两次add channels…一长串的… 置顶清华滤镜网站)

(base) C:\Users\lenovo>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 
(base) C:\Users\lenovo>conda config --set show_channel_urls yes
 
(base) C:\Users\lenovo>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 
Warning: 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/' already in 'channels' list, moving to the top
安装低版本python (另外安装,在conda的base中,不影响之前的版本)

若你还没有按装anaconda,赶紧下载安装吧!若已安装好,进入win菜单打开Anaconda prompt,
然后安装低版本TensorFlow
在这里插入图片描述

使用py36版本jp notebook 启动

在这里插入图片描述

在这里插入图片描述
就OK了!继续完成此作业了。。。。

+++++++++++++++++++++++
更新 安装keras (要低版本对应)在这里插入图片描述
pip install keras==2.0.0

少啥装啥
pip install pydot
在这里插入图片描述
报错信息:

OSError: Unable to open file (Unable to open file: name = 'datasets/train_happy.h5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)

报错信息:
原文件名称错误:
在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45673197/article/details/121066297