Convolution neural network learning the classical model of depth

LeNet-5 model

Application of CNN, LeNet-5 model character recognition system used is very classic model. LeNet-5 model in 1998, Professor Yann LeCun proposed, it was the first successful large-scale application in the convolution neural network handwritten numeral recognition of this problem, MNIST dataset correct rate can be as high as 99.2%.

The following details about the principle LeNet-5 model work.

LeNet-5 model, a total of seven layers, each comprising a number of parameters, i.e. the convolutional neural network parameters. Although the number of layers of only seven layers, which in today's vast neural network but that is very small, but contains a convolution layer, pooling layer, fully connected layer, can be described as a small but perfectly formed. For convenience, we called the convolution layer C layer, the lower layer is called sampling down-sampling layer.

First, the input layer of the original image, the original image is processed into a 32 × 32 pixel point values. Then, hidden behind the meter alternate between convolution and subsampling. Layer is a layer C1 convolution, characterized in comprising six FIG. Each map is 28x28 neurons. 5x5 convolution kernel may be cross-shaped, which is 28 × 28 neurons sharing convolution kernel weighting parameter, by the convolution operation, the original signal enhancement feature, but also reduces the noise, is not the same when the convolution kernel, extracted different features in the image; C2 layer is a layer of a pool, the pool of the functional layer above has been introduced, the local pixel value will be achieved averaging subsampling.

Pooling layer contains six characteristic map, each 14x14 pixel mapping values, such pooling layer is very important to guarantee the characteristics of the network can be extracted to some extent, but also greatly reduces the amount of computation, reduces network structure the risk of over-fitting. Since convolution is a layer with a pool of alternating layers, the hidden layers of the third layer is a convolution layer, the second layer is composed of convolution 16 wherein the mapping structure, each feature map for calculating the weighted sum convolution kernel is a 10x10. The fourth hidden layer, i.e. the second cell layer 16 comprises the same feature map, the convolution kernel in each feature map used is a 5x5. The fifth layer is a hidden calculates a 5x5 convolution kernel, comprising neurons 120, this network is the last layer of the convolution operation.

Sixth layer after layer is fully connected, comprising the features of FIG. 84. After the addition of the biasing layer is fully connected to the input dot product, then through a transmission to the activation function of the neurons in the output layer. The last layer, which is the seventh layer, in order to obtain an output vector, setting ten neurons be classified, an output corresponding to a one-dimensional array comprising ten elements, i.e., the vector of 0 to 9 ten elements.

AlexNet model

AlexNet Profile

2012 Imagenet image recognition contest, alexnet network model Alext proposed blockbuster, set off a wave of applications of neural networks and image recognition to win the 2012 session of the championship contest, which also makes convolution neural network to become the true sense of the image processing core algorithm. LeNet-5 described above appear in the last century, although it is a classic, but forced all sorts of complex real scene restriction can be applied only in some areas. However, with the rapid development of the manual design features such as SVM, LeNet-5 does not form a large application status. With ReLU and dropout raised, and GPU bring explosive force to break through and count the Internet era of big data, convolution neural network to bring the history of the breakthrough, AlexNet proposed to allow the depth of learning took to the forefront of artificial intelligence.

Image preprocessing
AlexNet training data using a subset of the data set ILSVRC2010 ImageNet, including the class of 1000, a total of 1.2 million training image, 50000 validation set, the test set 150,000. Before making network training we want to set the picture data preprocessing. First, we want different resolution images into images of all sizes 256x256, image conversion method is the short side of the pixel value scaled to 256, and then taken a long side of the intermediate position 256 pixel values, obtained 256x256 size image. In addition to pretreatment of the image size, but also to reduce the mean image, the image is generally composed of RGB primary colors are, respectively, the mean calculated by the three-component RGB, whereby images can more prominent features and more convenient calculation later.

In addition, to ensure the effectiveness of training, we still need to carry out more stringent training data processing. In the image of size 256x256, 227x227 size image is taken, after which the picture image taken, so that the increase in the raw data (256-224) x (256-224) x2 = 2048 times. Finally, the RGB space to do PCA, and then do the main component (0, 0.1) Gaussian disturbance, resulting in the error rate decreased by 1%. Test data, the size of the image in order to extract the four corners of the image 224224, 224224 size of the center of the image as well as their mirror image flip, so that we can get 10 images, we can take advantage of softmax predict, for all take the average forecast as the result of classification.

ReLU activation function
we mentioned before nonlinear activation function used is the sigmoid, it is possible to continuously determine the real value of the input is all between 0 and 1. But this presents a problem, as when the absolute value of a negative number is large, then the output is 0; if the absolute value is very large positive number, the output is 1. This phenomenon will be saturated, saturation gradients in neurons become very small, so the network will inevitably make learning more difficult. Further, the output value of the sigmoid not mean 0, since this would result in non-zero mean signal level on the output will be input directly to the rear layer of neurons. Therefore, the proposed model AlexNet ReLU function formula: f (x) = max ( 0, x) f (x) = max (0, x).

With ReLU instead of Sigmoid, ReLU been found that the use of SGD convergence rate much faster than the sigmoid, which became one of the advantages AlexNet model.

Dropout

AlexNet模型提出了一个有效的模型组合方式,相比于单模型,只需要多花费一倍的时间,这种方式就做Dropout。在整个神经网络中,随机选取一半的神经元将它们的输出变成0。这种方式使得网络关闭了部分神经元,减少了过拟合现象。同时训练的迭代次数也得以增加。当时一个GTX580 GPU只有3GB内存,这使得大规模的运算成为不可能。但是,随着硬件水平的发展,当时的GPU已经可以实现并行计算了,并行计算之后两块GPU可以互相通信传输数据,这样的方式充分利用了GPU资源,所以模型设计利用两个GPU并行运算,大大提高了运算效率。

模型分析

AlexNet模型共有8层结构,其中前5层为卷积层,其中前两个卷积层和第五个卷积层有池化层,其他卷积层没有。后面3层为全连接层,神经元约有六十五万个,所需要训练的参数约六千万个。

图片预处理过后,进过第一个卷积层C1之后,原始的图像也就变成了55x55的像素大小,此时一共有96个通道。模型分为上下两块是为了方便GPU运算,48作为通道数目更加适合GPU的并行运算。上图的模型里把48层直接变成了一个面,这使得模型看上去更像一个立方体,大小为55x55x48。在后面的第二个卷积层C2中,卷积核的尺寸为5x5x48,由此再次进行卷积运算。在C1,C2卷积层的卷积运算之后,都会有一个池化层,使得提取特征之后的特征图像素值大大减小,方便了运算,也使得特征更加明显。而第三层的卷积层C3又是更加特殊了。第三层卷积层做了通道的合并,将之前两个通道的数据再次合并起来,这是一种串接操作。第三层后,由于串接,通道数变成256。全卷积的卷积核尺寸也就变成了13×13×25613×13×256。一个有4096个这样尺寸的卷积核分别对输入图像做4096次的全卷积操作,最后的结果就是一个列向量,一共有4096个数。这也就是最后的输出,但是AlexNet最终是要分1000个类,所以通过第八层,也就是全连接的第三层,由此得到1000个类输出。

Alexnet网络中各个层发挥了不同的作用,ReLU,多个CPU是为了提高训练速度,重叠pool池化是为了提高精度,且不容易产生过拟合,局部归一化响应是为了提高精度,而数据增益与dropout是为了减少过拟合。

VGG net

在ILSVRC-2014中,牛津大学的视觉几何组提出的VGGNet模型在定位任务第一名和分类任务第一名[[i]]。如今在计算机视觉领域,卷积神经网络的良好效果深得广大开发者的喜欢,并且上文提到的AlexNet模型拥有更好的效果,所以广大从业者学习者试图将其改进以获得更好地效果。而后来很多人经过验证认为,AlexNet模型中所谓的局部归一化响应浪费了计算资源,但是对性能却没有很大的提升。VGG的实质是AlexNet结构的增强版,它侧重强调卷积神经网络设计中的深度。将卷积层的深度提升到了19层,并且在当年的ImageNet大赛中的定位问题中获得了第一名的好成绩。整个网络向人们证明了我们是可以用很小的卷积核取得很好地效果,前提是我们要把网络的层数加深,这也论证了我们要想提高整个神经网络的模型效果,一个较为有效的方法便是将它的深度加深,虽然计算量会大大提高,但是整个复杂度也上升了,更能解决复杂的问题。虽然VGG网络已经诞生好几年了,但是很多其他网络上效果并不是很好地情况下,VGG有时候还能够发挥它的优势,让人有意想不到的收获。

与AlexNet网络非常类似,VGG共有五个卷积层,并且每个卷积层之后都有一个池化层。当时在ImageNet大赛中,作者分别尝试了六种网络结构。这六种结构大致相同,只是层数不同,少则11层,多达19层。网络结构的输入是大小为224*224的RGB图像,最终将分类结果输出。当然,在输入网络时,图片要进行预处理。

VGG网络相比AlexNet网络,在网络的深度以及宽度上做了一定的拓展,具体的卷积运算还是与AlexNet网络类似。我们主要说明一下VGG网络所做的改进。第一点,由于很多研究者发现归一化层的效果并不是很好,而且占用了大量的计算资源,所以在VGG网络中作者取消了归一化层;第二点,VGG网络用了更小的3x3的卷积核,而两个连续的3x3的卷积核相当于5x5的感受野,由此类推,三个3x3的连续的卷积核也就相当于7x7的感受野。这样的变化使得参数量更小,节省了计算资源,将资源留给后面的更深层次的网络。第三点是VGG网络中的池化层特征池化核改为了2x2,而在AlexNet网络中池化核为3x3。这三点改进无疑是使得整个参数运算量下降,这样我们在有限的计算平台上能够获得更多的资源留给更深层的网络。由于层数较多,卷积核比较小,这样使得整个网络的特征提取效果很好。其实由于VGG的层数较多,所以计算量还是相当大的,卷积层比较多成了它最显著的特点。另外,VGG网络的拓展性能比较突出,结构比较简洁,所以它的迁移性能比较好,迁移到其他数据集的时候泛化性能好。到现在为止,VGG网络还经常被用来提出特征。所以当现在很多较新的模型效果不好时,使用VGG可能会解决这些问题。

GoogleNet

谷歌于2014年Imagenet挑战赛(ILSVRC14)凭借GoogleNet再次斩获第一名。这个通过增加了神经网络的深度和宽度获得了更好地效果,在此过程中保证了计算资源的不变。这个网络论证了加大深度,宽度以及训练数据的增加是现有深度学习获得更好效果的主要方式。但是增加尺寸可能会带来过拟合的问题,因为深度与宽度的加深必然会带来过量的参数。此外,增加网络尺寸也带来了对计算资源侵占过多的缺点。为了保证计算资源充分利用的前提下去提高整个模型的性能,作者使用了Inception模型,这个模型在下图中有展示,可以看出这个有点像金字塔的模型在宽度上使用并联的不同大小的卷积核,增加了卷积核的输出宽度。因为使用了较大尺度的卷积核增加了参数。使用了1*1的卷积核就是为了使得参数的数量最少。

Inception模块
上图表格为网络分析图,第一行为卷积层,输入为224×224×3 ,卷积核为7x7,步长为2,padding为3,输出的维度为112×112×64,这里面的7x7卷积使用了 7×1 然后 1×7 的方式,这样便有(7+7)×64×3=2,688个参数。第二行为池化层,卷积核为3×33×3,滑动步长为2,padding为 1 ,输出维度:56×56×64,计算方式:1/2×(112+2×1−3+1)=56。第三行,第四行与第一行,第二行类似。第 5 行 Inception module中分为4条支线,输入均为上层产生的 28×28×192 结果:第 1 部分,1×1 卷积层,输出大小为28×28×64;第 2 部分,先1×1卷积层,输出大小为28×28×96,作为输入进行3×3卷积层,输出大小为28×28×128;第 3部分,先1×1卷积层,输出大小为28×28×32,作为输入进行3×3卷积层,输出大小为28×28×32;而第3 部分3×3的池化层,输出大小为输出大小为28×28×32。第5行的Inception module会对上面是个结果的输出结果并联,由此增加网络宽度。

ResNet

2015年ImageNet大赛中,MSRA何凯明团队的ResidualNetworks力压群雄,在ImageNet的诸多领域的比赛中上均获得了第一名的好成绩,而且这篇关于ResNet的论文Deep Residual Learning for Image Recognition也获得了CVPR2016的最佳论文,实至而名归。

上文介绍了的VGG以及GoogleNet都是增加了卷积神经网络的深度来获得更好效果,也让人们明白了网络的深度与广度决定了训练的效果。但是,与此同时,宽度与深度加深的同时,效果实际会慢慢变差。也就是说模型的层次加深,错误率提高了。模型的深度加深,以一定的错误率来换取学习能力的增强。但是深层的神经网络模型牺牲了大量的计算资源,学习能力提高的同时不应当产生比浅层神经网络更高的错误率。这个现象的产生主要是因为随着神经网络的层数增加,梯度消失的现象就越来越明显。所以为了解决这个问题,作者提出了一个深度残差网络的结构Residual:

上图就是残差网络的基本结构,可以看出其实是增加了一个恒等映射,将原本的变换函数H(x)转换成了F(x)+x。示意图中可以很明显看出来整个网络的变化,这样网络不再是简单的堆叠结构,这样的话便很好地解决了由于网络层数增加而带来的梯度原来越不明显的问题。所以这时候网络可以做得很深,到目前为止,网络的层数都可以上千层,而能够保证很好地效果。并且,这样的简单叠加并没有给网络增加额外的参数跟计算量,同时也提高了网络训练的效果与效率。

在比赛中,为了证明自己观点是正确的,作者控制变量地设计几个实验。首先作者构建了两个plain网络,这两个网络分别为18层跟34层,随后作者又设计了两个残差网络,层数也是分别为18层和34层。然后对这四个模型进行控制变量的实验观察数据量的变化。下图便是实验结果。实验中,在plain网络上观测到明显的退化现象。实验结果也表明,在残差网络上,34层的效果明显要好于18层的效果,足以证明残差网络随着层数增加性能也是增加的。不仅如此,残差网络的在更深层的结构上收敛性能也有明显的提升,整个实验大为成功。

除此之外,作者还做了关于shortcut方式的实验,如果残差网络模块的输入输出维度不一致,我们如果要使维度统一,必须要对维数较少的进行増维。而增维的最好效果是用0来填充。不过实验数据显示三者差距很小,所以线性投影并不是特别需要。使用0来填充维度同时也保证了模型的复杂度控制在比较低的情况下。

随着实验的深入,作者又提出了更深的残差模块。这种模型减少了各个层的参数量,将资源留给更深层数的模型,在保证复杂度很低的情况下,模型也没有出现梯度消失很明显的情况,因此目前模型最高可达1202层,错误率仍然控制得很低。但是层数如此之多也带来了过拟合的现象,不过诸多研究者仍在改进之中,毕竟此时的ResNet已经相对于其他模型在性能上遥遥领先了。

残差网络的精髓便是shortcut。从一个角度来看,也可以解读为多种路径组合的一个网络。如下图:

ResNet可以做到很深,但是从上图中可以体会到,当网络很深,也就是层数很多时,数据传输的路径其实相对比较固定。我们似乎也可以将其理解为一个多人投票系统,大多数梯度都分布在论文中所谓的effective path上。

DenseNet

在Resnet模型之后,有人试图对ResNet模型进行改进,由此便诞生了ResNeXt模型。

这是对上面介绍的ResNet模型结合了GoogleNet中的inception模块思想,相比于Resnet来说更加有效。随后,诞生了DenseNet模型,它直接将所有的模块连接起来,整个模型更加简单粗暴。稠密相连成了它的主要特点。

我们将DenseNet与ResNet相比较:

从上图中可以看出,相比于ResNet,DenseNet参数量明显减少很多,效果也更加优越,只是DenseNet需要消耗更多的内存。

总结
上面介绍了卷积神经网络发展史上比较著名的一些模型,这些模型非常经典,也各有优势。在算力不断增强的现在,各种新的网络训练的效率以及效果也在逐渐提高。从收敛速度上看,VGG>Inception>DenseNet>ResNet,从泛化能力来看,Inception>DenseNet=ResNet>VGG,从运算量看来,Inception<DenseNet< ResNet<VGG,从内存开销来看,Inception<ResNet< DenseNet<VGG。在本次研究中,我们对各个模型均进行了分析,但从效果来看,ResNet效果是最好的,优于Inception,优于VGG,所以我们第四章实验中主要采用谷歌的Inception模型,也就是GoogleNet。

Guess you like

Origin blog.csdn.net/yoggieCDA/article/details/92623545