NG Andrew deep learning三

2实例探究

2.0 Network in networks,1x1 convolution and Inception Net

2.0.1 Network in networks: 1x1 convolution
2.0.2 Inception module(GoogLeNet/Inception v1:致敬LeNet)

(Original paper: 《going deeper with convolutions》)
在这里插入图片描述

  1. Motivation:
    在这里插入图片描述

  2. computational cost:
    28x28x192-----5x5, same, 32 Conv----->28x28x32
    number of multiply = 28x28x32(number of output) x 5x5x192(number of multiply for one single output) = 120M (1.2亿).
    (need to reduce it by a factor of 10)

  3. Use 1x1 convolution to reduce computional cost(bottleneck layer):
    在这里插入图片描述

number of multiply =28x28x16 x 1x1x192 + 28x28x32 x 5x5x16 = 2.4M+10M=12.4M (1/10of 120M)

  1. Inception module: bootleneck(reduce cost) + Motivation
    在这里插入图片描述

  2. Inception network
    比较特别的是,它有3个softmax,把他们加起来才是最终结果。
    这样有点像本文后面提到的集成学习,这样相当于3个深浅递增的网络同时参与,这样增加了可信度。
    在这里插入图片描述

2.1 迁移学习

自己的数据集数据量太少就只修改softmax层,

比较多就softmax和softmax前一两层,

很多就softmax和softmax前几层。

指导原则:数据量越少,冻结的层可以越多,新训练的层可以越少;数据量越多,冻结的层可以越少,新训练的层可以越多。

(但也不一定,可以多尝试下)

PS:为了加快训练,可以预先把所有数据在最后一个冻结层的激活输出保存起来;以它作为输入,只训练后半截新网络,大大节省时间。训练好了再拼接起来。

2.2 Data Augmentation

PCA color Augmentation (AlexNet)

2.3 Tip for doing well on benchmark/wining competitions

因为比赛只在乎benchmark,所以时间慢啥的可以接受。论文也行。(工业上不ok)

  1. 集成学习(Ensembling):同时得到三五个网络,平局输出(不是平均权重信息);通常能够提高1到2个点。
  2. Multi-crop at test time:对测试图片crop10次,得到10个结果再平均/取次数最多一项。

3 Object Detection

3.1 localization VS detection

single object picture: bounding box + classification = localization problem
multiple object: bounding boxes + classification = detection problem.

3.2 landmarks detection (for lacalization or pose detection or …)

landmarks---- ( b x , b y , b h , b w ) (b_x, b_y, b_h, b_w) (bx,by,bh,bw): ( b x , b y ) (b_x, b_y) (bx,by) is the center point; b h a n d b w b_h and b_w bhandbw is the height and width, respectively.

An supervised algorithms shoud predict these four values and the class label. (对bounding box的预测问题,实际上是回归问题)

Localization problem:
Input: pictures + features(landmarks for localization; landmarks for poses detection)
o u t p u t = [ P c , b x , b y , b h , b w , c 1 , c 2 , c 3 ] output = [P_c, b_x, b_y, b_h, b_w, c_1, c_2, c_3] output=[Pc,bx,by,bh,bw,c1,c2,c3](假设分类三类);
P c = 1 P_c=1 Pc=1,表示有object, l o s s = ( P c ^ − P c ) 2 + ∑ ( b i ^ − b i ) 2 + ∑ ( c 1 ^ − c 1 ) 2 loss=(\hat{P_c}-P_c)^2+ \sum(\hat{b_i} - b_i)^2+\sum{(\hat{c_1}-c_1)}^2 loss=(Pc^Pc)2+(bi^bi)2+(c1^c1)2;否则表示无object,纯背景,其他几个values we don’t care, l o s s = ( P c ^ − P c ) 2 loss=(\hat{P_c}-P_c)^2 loss=(Pc^Pc)2

3.3 objection detection——sliding windows detection

  1. fine granularity细粒度) or small stride: greate computational cost

  2. 训练/检测
    训练过程:若识别车,训练集就只是车(无背景);
    在detection/location过程:以相同框截取滑动窗口,传入网络中分别预测

在这里插入图片描述
3. 问题:计算量巨大。
4. solution: 见3.4

3.4 FC与滑动窗口的卷积实现

  1. Turning FC layer into convolutional layers
    5x5x16——FC——> 400———FC———>400——FC——> 4
    ===>
    5x5x16–5x5x16x400–>400–1x1x400x400–>400–1x1x400x4–>4
    在这里插入图片描述

  2. convolution implementation of sliding windows——《overfeat2014, Sermanet》
    在这里插入图片描述
    如图,第一行是按3.3.2训练好的窗口截取结果判断网络;第二/三行是待检测图片。
    先看第二行的图片:本应该按14x14滑动窗口截取,得到4张14x14图片(左上红/右上绿/左下黄/右下紫),分别输入网络;但实际上,这里面有许多重复计算部分。于是,就将整个16x16输入该网络,最终会得到22的图(4个元素)——对应位置的结果就是预测结果。比如右上的绿色14x14,第一张12x12feature map的右上角10x10就是原网络(第一行)应该输出的10x10结果。这样总体来看,就相当于对16x16图片以stride=2进行滑动窗口截取并推测(因为max pool stride=2)
    再看第3行28x28图片:与第二行类似,相当于对它进行stride=2, size=10滑动截取预测(因为max pool stride=2),得到8
    8((28-10)/2+1=8)张滑动截取图的判断结果。
    但是这样的boding box不精确(没有正中间框住/框应该是长方形等等),解决方案如下:

3.5 精确Bounding Box预测——YOLO2015Redmon——卷积实现滑动

(YOLO论文难理解,即便是资深研究员)
这篇写的很好

  1. List item
    思想:切割图像(下图例子中是3x3个grid cells);用3.4.2中的做法以卷积代替滑动窗口(下图最下方),得到3x3x8输出(假设3类);某物体a的中心点不在grid cell b中,则认为格子b没有物体a——以中心点判断。
    以上需要每个大格需要只有一个物体,怎么避免两个?——切割的更细一点。
    在这里插入图片描述

  2. bounding boxes编码问题
    左上角(0,0),右下角(1,1);w/h像素比例(可能大于1,如果无力占据多于一个大格)
    在这里插入图片描述

3.6评价指标——交并比(Intersection over union, IoU)

I o U = S i z e 预 测 S i z e   G r o u n d _ T r u e IoU=\frac{Size预测}{Size\ Ground\_True} IoU=Size Ground_TrueSize
Correct if IoU>=Thresdhold(0.5/more stringent)

3.7非极大值抑制(non max suppression)

作用:确保一个对象只被检测一次
做法:输出maximal predition probabilities(PC) classifications, suppress its closeby ones that are non maximal
下图中只假设一种分类,即是车,所以为c1 c2 c3元素。
对于n种目标的检测,则前后独立进行n次non-max suppression.
在这里插入图片描述

问:为什么要去掉和higest pc目标IoU大的bounding boxes而不是直接看分数说话?
答:如图,同时有两个目标。pick了pc最大的box,基本上就确定了它是本目标(下图右车)的bounding boxes,而与其IoU大的一般是对本目标(下图右车)的重复detection, 小的是其他目标的boxes(如下图左车目标的两个框)。在这里插入图片描述

3.8 Anchor Boxes(锚框)

解决一个grid cell只能检测一个对象的问题——预先设置一些(假设n个)形状的anchor boxes,和训练集一一配对喂给算法;output长度=原始编码*n(一种形状box对应一个原始编码)
不做笔记了,完了看原始视频blog

3.9 YOLO算法——组装前面提到的组件

1、training
在这里插入图片描述
2 predictions
在这里插入图片描述
3 outputting the non-max supressed outputs
在这里插入图片描述

3.10 候选区域(region proposals)——R-CNN2013(Regions with convolutional networks,带区域的卷积网络)

Two stages(非end-to-end): 基于Segmentation algorithm(图像分割)切分区域(色块);在每个色块上放置box检测——避免在纯粹背景块上浪费太多资源。

原版太慢,更快速的改进版(还是比YOLO慢很多):
在这里插入图片描述

Ps:一般数据量多,可以直接用end-to-end算法,自动学习,效果好;数据量太少, hand-engineering可能会引入更多信息从而效果更好。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值