美文网首页
fastai学习思考(1)

fastai学习思考(1)

作者: 深度学习模型优化 | 来源:发表于2019-05-16 19:29 被阅读0次

1 fastai简易练习

from fastai.vision import *

path = untar_data(URLs.MNIST_SAMPLE)
data = ImageDataBunch.from_folder(path)

这是用来加载数据的,但是我在使用的过程中出现了无法下载的情况,于是我用浏览器直接下载,然后解压之后,在使用ImageDataBunch来加载数据。fastai的一个方便的地方是可以很容易的实现加载数据和做数据增强。

  • Learner.lr_find 进行学习率范围搜搜,可以帮助我们选择比较好的学习率。
  • Learner.fit_one_cycle 使用1轮策略来提高我们模型的训练速度。
  • Learner.to_fp16 这个会将我们的模型转化为16位定点类型,来实现在混合精度下的训练。

class Learner[source][test]

Learner(data:DataBunch, model:Module, opt_func:Callable='Adam', loss_func:Callable=None, metrics:Collection[Callable]=None, true_wd:bool=True, bn_wd:bool=True, wd:Floats=0.01, train_bn:bool=True, path:str=None, model_dir:PathOrStr='models', callback_fns:Collection[Callable]=None, callbacks:Collection[Callback]=<factory>, layer_groups:ModuleList=None, add_time:bool=True, silent:bool=None)

在基础训练中重要的类是Learner

通过 pip 安装
通过下列三步可以用 pip 安装 fastai,要严格安装顺序执行。

  1. 安装每日编译 nightly 的 PyTorch,注意 cuda 的版本要和你自己的系统保持一致,比如在 CUDA 9.2 上安装:

pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html

pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html

  1. 安装定制的 torchvision,这个版本是在 nightly-pytorch 上编译的:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ torchvision==0.2.1.post2

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ torchvision==0.2.1.post2

  1. 安装 fastai:
    pip install fastai
    有些时候,上面的命令会试图安装 torch-0.4.1,这时候可以使用下面的命令:

pip uninstall torchvision fastai
pip install --no-deps torchvision
pip install fastai

pip uninstall torchvision fastai
pip install --no-deps torchvision
pip install fastai
安装完毕,大家愉快的体验 fastai 的新特性吧!

相关文章

  • fastai学习思考(1)

    1 fastai简易练习 这是用来加载数据的,但是我在使用的过程中出现了无法下载的情况,于是我用浏览器直接下载,然...

  • fastAI学习

    背景 2018版的课程有两部分 Part 1. Practical Deep Learning For Coder...

  • FastAI00-FastAI入门

    从现在开始,学习fastAI,将重点知识记载本笔记上,防止遗忘。 1. Jupyter Notebook技巧 1....

  • fastai教程

    学习fastai是因为上次在一个博客上看见一个兄弟用fastai非常容易的拿到了kaggle一个比赛的冠军,而且在...

  • kaggle竞赛:MNIST入门

    本文的代码见这里。 这里使用fastai v1来处理MNIST数据集,主要是希望fastai能和数据挖掘中的skl...

  • 开箱即用的深度学习框架fastai

    Fastai,Make deep learning uncool ! fastai将训练一个准确的神经网络变得...

  • lesson 3

    1、深度学习中最复杂的步骤往往是将数据转换成能够输入模型的形式 2、fastai中,要了解的pytorch类 在p...

  • fastai

    data_input train predict

  • 产品经理也能动手实践的AI(二)- 做个识别宠物的AI

    上一篇《产品经理也能动手实践的AI(一)- FastAI介绍》,介绍了为什么选择FastAI,为什么适合产品经理,...

  • Image classification with FastAI

    之前一篇文章介绍了FastAI v0.7中处理dogscats数据集的过程。这一篇则介绍一下FastAI v1.0...

网友评论

      本文标题:fastai学习思考(1)

      本文链接:https://www.haomeiwen.com/subject/bbepoqtx.html