美文网首页
lesson one

lesson one

作者: 与尔岩说 | 来源:发表于2017-09-04 18:02 被阅读0次

引言

为了所有想要应用深度学习技巧和计算机专业的人士设计的课程


image.png

深度学习的发展

image.png

准备

GPU 的准备
下载相应的数据
Then download dogscats.zip into that directory and unzip.
looking at the Dogs vs. Cats Kaggle competition

数据结构概览

1.切分验证集,训练集以及测试集
2.分别看这几个文件夹下面的文件结构是什么样的

image.png

使用CNN

本周的任务

建一个模型可以识别狗和猫,达到80%以上的准确率

基本配置

Use $ jupyter notebook to open a connection to the notebook GUI at port 8888. Recall the ip address for your instance we recorded earlier. In your browser, go to instanceIP:8888 to access the GUI, and login with password dl_course. Click on lesson1.ipynb.

from __future__ import division,print_function
import os, json
from glob import glob
import numpy as np
np.set_printoptions(precision=4, linewidth=100)
from matplotlib import pyplot as plt
import utils; reload(utils)
from utils import plots

定义文件夹路径

#path = "data/dogscats/"
path = "data/dogscats/sample/"

注意这里的utils是一个我们下载好的库,里面有一些常用的函数,我们可以用. reload(utils) 来更新我们的notebook如果我们对这个库有什么更新的话。

用训练好的VGG模型

使用别人训练好的模型,VGG16
理解vgg的建造方法很重要,他的数据大部分是单个物体的,也就是说vgg比较适合于单个物体的识别,比如猫呀狗呀,看看数据你就知道你用的别人的模型有什么好的和坏的地方。

punchline: state of the art custom model in 7 lines of code

现在我们可以开始:

# As large as you can, but no larger than 64 is recommended. 
# If you have an older or cheaper GPU, you'll run out of memory, so will have to decrease this.
batch_size=64
# Import our class, and instantiate
from vgg16 import Vgg16# Import our class, and instantiate
from vgg16 import Vgg16
vgg = Vgg16()
# Grab a few images at a time for training and validation.
# NB: They must be in subdirectories named based on their category
batches = vgg.get_batches(path+'train', batch_size=batch_size)
val_batches = vgg.get_batches(path+'valid', batch_size=batch_size*2)
vgg.finetune(batches)
vgg.fit(batches, val_batches, nb_epoch=1)

我们可以用vgg来识别主要的imagenet 的类别(就是原来那个比赛的数据集里面有的类别)但是我们不能直接识别猫和狗因为原来那个比赛没有这个类别,然而我们可以看看他是怎么识别这些图像的。首先我们构造了一个vgg的对象;由于vgg是基于keras的,所以他可以直接识别图片和他的标签,用一个文件夹目录的结构,不同的类别必须被放在单独的文件夹中。
BTW,当Keras引用“类”时,并不意味着Python类,而是指标签的类别,例如“pug”或“tabby”。)批次只是一个常规的python迭代器。 每次迭代都会返回图像本身以及标签。
为了理解什么是batch,我们可以先看看一个batch长什么样子

image.png

http://wiki.fast.ai/index.php/Lesson_1_Notes

相关文章

  • # Lesson One

    [TOC] What is vector? 有方向有大小的东西。 So it may not that corre...

  • lesson one

    2008年的时候我在上海,跟在大人屁股后头看世博会。早上六点半起来,在廉价早餐店吃馒头喝淡得像水一样的稀饭,大头菜...

  • lesson one

    引言 为了所有想要应用深度学习技巧和计算机专业的人士设计的课程 深度学习的发展 准备 GPU 的准备下载相应的数据...

  • Lesson One

    作者:苗术 1. 武老大粗壮的手指上,一排戒指金光灿灿。 “这三个金箍子,两个是真的,一个是假的。”他将手背面向我...

  • [3]- Lesson 2:Thirteen equals on

    Lesson 2:Thirteen equals one 播放音频:Lesson 1:A Puma at larg...

  • 六级听力-高频单词[1]-连载

    Lesson One Part One 1.In America,white-tailed deer are mo...

  • 11讲

    # Lesson 21 倒装 ``` 1. That one is my bag. Which one is yo...

  • Lesson One — JavaScript

    一、什么是JavaScript JavaScript 是一种具有面向对象能力的、解释型的程序设计语言。更具体一点,...

  • English one lesson

    任何一句话都有时态 时态特点:现在、过去、将来、过去将来 时态形式:现在、完成、进行、完成进行 共有16种时态:一...

  • 每日英汉对照(207-9-9)

    One day a teacher was giving a lesson to a class of boys....

网友评论

      本文标题:lesson one

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