吴恩达深度学习编程作业报错解决方法汇总

概述及资源分享

大二结束后的暑假,学习吴恩达深度学习([双语字幕]吴恩达深度学习deeplearning.ai_哔哩哔哩_bilibili)的课程,在做编程作业的时候总是遇到一些报错,尤其是导入所需要的库的时候会报一些No model。。。的问题,作为深度学习的小白一枚,上网搜索方法来解决错误,有时候方法不一定都顶用,所以想把管用的方法记录一下。有时候,这些报错还和你电脑里中pip list(在命令提示符里面输入pip list  )中的文件版本有关,比如tensorflow的版本过高了(2.0的版本好像废除了一些东西啥的)。

嘿嘿,学到吴恩达深度学习的第四门的第四周课的时候,才想到在csdn中记录,(如果有时间的话,我会把前面课程的编程资料也补上的),方便自己下次在jupyter notebook 中成功运行代码(不知道对其他同学有没有用,如果有用的话,我还是很开心能帮助到,要是误导了,我也说声对不起)

我代码看的是吴恩达《深度学习》L4W4作业1 - Heywhale.com这里面的,因为里面全是中文,比较方便,我分享的链接里面的代码说明没有这个好。

另外,我将附上我搜集到的吴恩达深度学习的课程资料(包括深度学习笔记、测试题(中英文对照的哦)、编程作业(里面有编程作业代码,还有需要的一些.h5文件等有用的东西))、还有我同学给我发的一本电子书(关于深度学习的)

链接:https://pan.baidu.com/s/1rOWP2u4tvHHKGzQvvLlMeQ 
提取码:03tm

--------------------------------

L4W4作业1

我的环境:

1.在jupyter notebook 中运行,没有装anaconda

2.python 版本信息

 3.pip list
C:\Users\29856>pip list
Package                 Version
----------------------- -----------
absl-py                 0.13.0
argon2-cffi             20.1.0
astor                   0.8.1
astunparse              1.6.3
async-generator         1.10
attrs                   21.2.0
backcall                0.2.0
bleach                  4.0.0
cached-property         1.5.2
cachetools              4.2.2
certifi                 2021.5.30
cffi                    1.14.6
charset-normalizer      2.0.4
clang                   5.0
colorama                0.4.4
cycler                  0.10.0
debugpy                 1.3.0
decorator               5.0.9
defusedxml              0.7.1
ecdsa                   0.17.0
entrypoints             0.3
flatbuffers             1.12
gast                    0.3.3
google-auth             1.35.0
google-auth-oauthlib    0.4.5
google-pasta            0.2.0
graphviz                0.17
grpcio                  1.38.1
h5py                    2.10.0
idna                    3.2
imageio                 2.9.0
importlib-metadata      3.10.1
ipykernel               6.0.1
ipython                 7.26.0
ipython-genutils        0.2.0
ipywidgets              7.6.3
jedi                    0.18.0
Jinja2                  3.0.1
joblib                  1.0.1
jsonschema              3.2.0
jupyter                 1.0.0
jupyter-client          6.1.12
jupyter-console         6.4.0
jupyter-core            4.7.1
jupyterlab-pygments     0.1.2
jupyterlab-widgets      1.0.0
Keras                   2.3.1
Keras-Applications      1.0.8
Keras-Preprocessing     1.1.2
kiwisolver              1.3.1
Markdown                3.3.4
MarkupSafe              2.0.1
matplotlib              3.4.2
matplotlib-inline       0.1.2
mistune                 0.8.4
mock                    4.0.3
nbclient                0.5.3
nbconvert               6.1.0
nbformat                5.1.3
nest-asyncio            1.5.1
notebook                6.4.2
numpy                   1.19.5
oauthlib                3.1.1
opt-einsum              3.3.0
packaging               21.0
pandas                  1.3.0
pandocfilters           1.4.3
parso                   0.8.2
pickleshare             0.7.5
Pillow                  8.3.1
pip                     21.2.4
prometheus-client       0.11.0
prompt-toolkit          3.0.19
protobuf                3.17.3
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycparser               2.20
pycryptodome            3.10.1
pydot                   1.4.2
pydot-ng                2.0.0
Pygments                2.9.0
pyparsing               2.4.7
pyrsistent              0.18.0
python-dateutil         2.8.1
pytz                    2021.1
pywin32                 301
pywinpty                1.1.3
PyYAML                  5.4.1
pyzmq                   22.2.1
qtconsole               5.1.1
QtPy                    1.9.0
requests                2.26.0
requests-oauthlib       1.3.0
rsa                     4.7.2
scikit-learn            0.24.2
scipy                   1.2.1
SCons                   4.1.0.post1
Send2Trash              1.7.1
setuptools              57.1.0
six                     1.15.0
sklearn                 0.0
tensorboard             1.14.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
tensorflow              1.14.0
tensorflow-estimator    1.14.0
termcolor               1.1.0
terminado               0.10.1
testpath                0.5.0
threadpoolctl           2.2.0
tornado                 6.1
traitlets               5.0.5
typing-extensions       3.7.4.3
urllib3                 1.26.6
wcwidth                 0.2.5
webencodings            0.5.1
Werkzeug                2.0.1
wheel                   0.37.0
widgetsnbextension      3.5.1
wrapt                   1.12.1
zipp                    3.5.0

 遇到的bug

一。运行的代码块

from keras.models import Sequential
from keras.layers import Conv2D, ZeroPadding2D, Activation, Input, concatenate
from keras.models import Model
from keras.layers.normalization import BatchNormalization
from keras.layers.pooling import MaxPooling2D, AveragePooling2D
from keras.layers.merge import Concatenate
from keras.layers.core import Lambda, Flatten, Dense
from keras.initializers import glorot_uniform
from keras.engine.topology import Layer
from keras import backend as K
K.set_image_data_format('channels_first')
import cv2
import os
import numpy as np
from numpy import genfromtxt
import pandas as pd
import tensorflow as tf
from fr_utils import *
from inception_blocks_v2 import *

%matplotlib inline
%load_ext autoreload
%autoreload 2

np.set_printoptions(threshold=np.nan)

二。bug

1.ModuleNotFoundError: No module named 'cv2'。

解决方法:在cmd中运行命令pip install opencv-python,问题解决

参考链接:jupyter notebook 使用CV2库出现找不到模块问题 - 简书 (jianshu.com)

2.ValueError: threshold must be non-NAN, try sys.maxsize for untruncated representation

解决方法:见参考链接

参考链接:(19条消息) ValueError: threshold must be numeric and non-NAN, try sys.maxsize for untruncated representation_zou_albert的博客-CSDN博客

3.解决完以上两步后,又因为引入的 sys出现了问题

bug及解决方法如下:

Python 程序报:NameError: name 'sys' is not defined_百度知道 (baidu.com)

4.

bug:

吴恩达深度学习编程作业报错解决方法汇总_第1张图片

问题:代码文件的同级文件夹images中kevin.jpg文件名有误,把“(1)”去掉,改回来就好了

吴恩达深度学习编程作业报错解决方法汇总_第2张图片

总结:

我今天第一次发现,其实在导入库的时候,报错的问题没有解决,后面还是有可能可以进行下去的,能输出数据的地方还是会照常输出该有的数据。

你可能感兴趣的:(人工智能,深度学习)