FastAI2019 Notebook

第0课:https://github.com/fastai/course-v3/blob/master/nbs/dl1/00_notebook_tutorial.ipynb

Jupyter Notebook的两种模式:Edit(绿色)和Command(蓝色)
按Esc键,切换到Command模式,按Enter键,进入所选Cell的Edit模式
在Cell外单击,切换到Command模式,在Cell内点击(Code Cell需要单击,Markdown Cell需要双击),切换到Edit模式

Jupyter Notebook每120秒自动保存,在Command模式下按s键手动保存,个人更习惯直接Ctrl+s进行保存

右上角查看Kernel的运行状态:Kernel Busy(实心圆●)或Kernel Idle(空心圆○)
在这里插入图片描述

Command模式下的快捷键
0+0:Restart Kernel
m:Convert cell to Markdown
y:Convert cell to Code
o:Toggle between hide or show output
Shift+Up/Down:选中多个cell(然后可以运行、复制、粘贴、合并这些cell)
Shift+M:合并选中的cell

Jupyter Notebook可以创建Terminal
在这里插入图片描述

Code Cell中的特殊用法
使用?function-name??function-namedoc(function-name),可以查看文档
使用!可以使用linux命令,并且使用{var_name}可以直接引用python定义的变量,例如

folder = 'imagenet'
!ls -l {folder}

Line Magics

%matplotlib inline
%reload_ext autoreload
%autoreload 2

%matplotlib inline:This command ensures that all matplotlib plots will be plotted in the output cell within the notebook and will be kept in the notebook when saved.
%reload_ext autoreload, %autoreload 2:Reload all modules before executing a new line. If a module is edited, it is not necessary to rerun the import commands, the modules will be reloaded automatically.

%timeit:Runs a line a ten thousand times and displays the average time it took to run it.(似乎不太常用)

第1课:https://github.com/fastai/course-v3/blob/master/nbs/dl1/lesson1-pets.ipynb

untar_data函数原型

Signature: untar_data(url:str, fname:Union[pathlib.Path, str]=None, dest:Union[pathlib.Path, str]=None, data=True, force_download=False) -> pathlib.Path

使用了参数:类型=默认值的格式,Union[XXX, XXX]表示或

path.ls()返回一个list,包含了该目录下的所有文件的完整路径

查看learn.fit_one_cycle的文档可知,默认的学习率为0.003

max_lr:Union[float, Collection[float], slice]=slice(None, 0.003, None)
learn.unfreeze()
learn.fit_one_cycle(3, max_lr=slice(1e-6,1e-4))

unfreeze后运行lr_find,选择的学习率为1e-6,然后取unfreeze前使用的学习率(默认为3e-3)的约1/10,此处为1e-4,然后令max_lr=slice(1e-6,1e-4)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值