C1_W1_Lab04_Cost_function_Soln中遇到的一些问题
1、
import numpy as np %matplotlib notebook import matplotlib.pyplot as plt from lab_utils_uni import plt_intuition, plt_stationary, plt_update_onclick, soup_bowl plt.style.use('./deeplearning.mplstyle')
这部分代码报错:
the 'package' argument is required to perform a relative import for './deeplearning'
解决办法:
将这三个文件中的所有“plt.style.use('./deeplearning.mplstyle')”改为“plt.style.use('deeplearning.mplstyle')”即去掉“./”
如图所示:
修改完成后不报“the 'package' argument is required to perform a relative import for './deeplearning'”这个问题了
接着可能会报错No module named ‘ipympl‘
解决办法:
在cmd中运行
pip install ipympl -i https://pypi.tuna.tsinghua.edu.cn/simple
有可能会下载失败,这和visual stdio c++有关,需要自己去下载相关内容,这里推荐看这个:
http://t.csdn.cn/hfgJ1文章就能解决
下载完成后不报错了但是plt_intuition(x_train,y_train)只有按钮没有图像
解决办法:
将代码一开始中的
%matplotlib widget 改为%matplotlib notebook
改为
这样就可以运行了,可能会有些卡要稍等一会
划了太多下,就不会显示了原因是20张图片以上就需要清除内存数据,需要运行plt.close('all')
总结:
这一切一切的原因可能都是因为我们使用的是jupyter notebook,而教程里使用的是jupyter lab,在我更换了jupyter lab运行这些代码之后,就没有这么些麻烦事了可以直接运行
如果对您有帮助的化可以点赞支持
如图:jupyter lab