您的位置:首页 > 编程语言 > Python开发

Coursera | Andrew Ng (01-week-2-2.17)—Jupyter _ ipython 笔记本的快速指南

2018-01-02 16:29 696 查看
该系列仅在原课程基础上部分知识点添加个人学习笔记,或相关推导补充等。如有错误,还请批评指教。在学习了 Andrew Ng 课程的基础上,为了更方便的查阅复习,将其整理成文字。因本人一直在学习英语,所以该系列以英文为主,同时也建议读者以英文为主,中文辅助,以便后期进阶时,为学习相关领域的学术论文做铺垫。- ZJ

Coursera 课程 |deeplearning.ai |网易云课堂

转载请注明作者和出处:ZJ 微信公众号-「SelfImprovementLab」

知乎https://zhuanlan.zhihu.com/c_147249273

CSDNhttp://blog.csdn.net/JUNJUN_ZHAO/article/details/78952886

2.17 Quick tour of Jupyter/ipython notebooks (Jupyter _ ipython 笔记本的快速指南)

(字幕来源:网易云课堂)



With everything you’ve learned,you’re just about ready to tackle your first programming assignment.Before you do that, let me just give you ,a quick tour of ipython notebooks in Coursera. Here you see, Jupyter iphython notebooks ,that you can get to in Coursera.Let me just quickly show you a few features of this.The instructions are written into text in the ipython notebook,like gray blocks are blocks of code.So occasionally, you see in these blocks ,sometimes looks like this ,this is their start code here and end code here.To do their primary exercise,please make sure to write your code ,between the start code here and end code here.So for example, print Hello World.Right. And, then to execute a code block,,you can hit shift enter and then they execute this code block,which I guess we just wrote print Hello World.

你们已经学会很多了,现在你已经准备好了,解决你的第一个编程任务,在你这样做之前 让我来给你,介绍一下 Coursera 中的 ipython 笔记本,你可以看到 这是 Jupyter iphython 笔记本,你可以在 Coursera 中访问,让我快速向你展示一下它的功能,这指南是用 ipython笔记本文本写的,灰色块是代码段,所以你偶尔会看到这些代码段,有时看起来是这样的,这是写 代码开始 代码结束,要做第一个大作业,请确保你写的代码,在代码开始和代码结束之间,比如 print Hello World,对吧 然后要执行代码段,你可以输入 Shift+Enter 然后执行代码段,我们刚写了print Hello World。



So that printed Hello World.To run a cell, you can also,to run one of these code blocks in cell,you can also click cell and then run cell.So to execute this is possible that on your computer the keyboard shortcut for cell runs cell might be different than shift enter but on both my Mac as well as on my PC,a shift enter so might be the same for you as well.Now, when you’re reading the instructions if you know,accidentally double click on it,you might end up with this markdown language.If you end up with this funny looking text,to convert it back to the nice looking text just run the cell.So click on the cell runs cell or I’m going to hit shift enter and that basically executes the markdown and turns it back into this nice looking code.

所以 Hello World 就输出来了,要运行一个单元格 你也可以,在其中一个单元格里跑代码,你可以点单元格菜单 然后运行单元格,你是可以用 键盘快捷方式执行的,要执行单元格程序 可能用的不是 Shift+Enter,但在我的 mac 和 PC 中都行,所以你用 Shift+Enter 可能也行,所以当你阅读说明你就知道,意外双击后,你可能会得到这样的标记语言,如果你得到这种怪怪的文本,要把它们变回格式整齐的文本 只需要执行这个单元格就行了,所以点击单元格 然后运行 我这里要用 shift+enter,这基本上就执行了标记语言,并将它重新转换成漂亮的代码段。



Just a couple of more tips,when you execute code like this,it actually runs on a kernel,on a piece of code that runs on the server.If you’re running an excessively large job or if you’re,you leave a computer for a very long time or something goes wrong,your internet connection is off,there is a small chance of the kernel on the back end might die,which is just click kernel.And then restart kernel and hopefully that will reboot the kernel and make it work again.So that shouldn’t happen if you’re just running relatively small jobs and you’re just starting up your ipython notebook.But if you see an error message that the kernel has died or something,you can try kernel restart.Finally, and ipython notebook like this there may be multiple blocks of code.So, even if an earlier block of code doesn’t have any grading code,be sure to execute this block of code because in this example,it imposed numpy as np and so on.

这里还有一些提示,当你执行这样的代码时,它应该是在内核上运行的,那是服务器上的一段代码,如果你跑一段计算量很大的代码,或者你离开电脑很久 出了什么问题,比如你的网断了,那么后端的内核可能会宕机,那么你只需点击内核,然后重启内核 希望,重启内核可以让它重新工作,不过如果你运行的代码,计算量不多 应该不会出这种问题,如果你开始使用 ipython 笔记本,然后你看到错误信息,内核卡死了之类的,你可以尝试重启内核,最后 这样的 iPython 笔记本,可能有很多代码段,所以即使前面一些代码段,没有任何用于作业评分的代码,一定要确保执行这段代码 因为这个例子中,它执行了
import numpy as py
等等



And said so some of the variables that you might need in order to execute the lowdown on blocks of code,so be sure to execute the ones on top even if you aren’t asked to write any code in them.And finally, when you’re done implementing your solutions as this blue submit assignment button here on the right and we click that it will submit your solutions for grading.I found out the interactive command shell nature of ipython notebooks to be very useful for letting you quickly implement a few lines of code,see an outcome, learn it very quickly.And so I hope that the approach exercises and Coursera in Jupyter ipython notebooks will help you quickly learn and experiment and see how to implement these learning algorithms.There’s one more video after this. This is an optional video that talks about the cost function for logistic reggression.You can watch that or not,either way is perfectly fine.But either way, best of luck with the week two probing assignments.And I also look forward to seeing you at the start of the next week’s materials.

这样就初始化一些变量,才能执行下面这些代码,所以一定要执行最上面的代码,或者即使没要求你在上面写代码,最后 当你完成代码实现之后,按这个蓝色提交作业按钮,在右边 我们点击一下,就会提交你的答案 然后评分,我发现这些交互命令很像 shell,这样的 ipython笔记本是非常有用的,可以让你快速实现几行代码,马上看到结果 迅速学习,我希望这个练习方法,还有和 Coursera Jupyter ipython 可以帮你迅速,学习和实验 看结果,学会如何实现这些学习算法,之后还有一个视频,那是一个可选的视频,会讨论成本函数的logistic回归,你们可以看 也可以不看,都行,总之 祝你们在,完成第二周作业中有好运气,我希望在下周材料,开始时再见到你。

重点总结:

Windows jupyter install (Python) 本地搭建

pip3 install  jupyter


启动 jupyter notebook 命令 cmd

jupyter notebook


mac

jupyter-notebook


PS: 欢迎扫码关注公众号:「SelfImprovementLab」!专注「深度学习」,「机器学习」,「人工智能」。以及 「早起」,「阅读」,「运动」,「英语 」「其他」不定期建群 打卡互助活动。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息