背景簡介
在 LeNet 問世后的第4年集侯,2012年, AlexNet 在 ImageNet LSVRC-2010 數(shù)據(jù)集上對(duì)1000個(gè)類別的圖像進(jìn)行分類取得了當(dāng)時(shí)最好的效果曾撤;同時(shí)在 ILSVRC-2012 數(shù)據(jù)集上取得了當(dāng)時(shí)第一的成績。在AlexNet之后晕粪,圖像分類模型越來越復(fù)雜挤悉,網(wǎng)絡(luò)也越來越 deep。現(xiàn)在 AlexNet 仍然可以應(yīng)用到小數(shù)據(jù)集上巫湘,做一些驗(yàn)證性的實(shí)驗(yàn)装悲。
原論文
https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf
文章發(fā)在 NIPS 上。截止目前引用次數(shù)為36782尚氛!
個(gè)人 Github 實(shí)現(xiàn)
https://github.com/uestcsongtaoli/AlexNet
模型介紹
AlexNet Architecture
上圖是 Alex Krizhevsky 原論文中 AlexNet 結(jié)構(gòu)圖诀诊,做了簡單的標(biāo)注。
該模型由5個(gè)卷積層和3個(gè)全連接層構(gòu)成阅嘶,其中還有3個(gè) Pooling 層属瓣。
先定義 conv block 包括卷積、BatchNormalization 和 Activation:
def Conv_block(layer, filters, kernerl_size=(3, 3), strides=(1, 1), padding="valid", name=None):
x = Conv2D(filters=filters, kernel_size=kernel_size, strides=strides, padding=padding, name=name)(layer)
x = BatchNormalization()(x)
x = Activation("relu")(x)
return x
- 卷積層 Conv_1
x = Conv_block(x, filters=96, kernel_size=(11, 11), strides=(4, 4), padding="valid", name="Conv_1_96_11x11_4")
- 池化層 Pool_1
x = MaxPool2D(pool_size=(3, 3), strides=(2, 2), padding="valid", name="maxpool_1_3x3_2")(x)
- 卷積層 Conv_2
x = Conv_block(x, filters=256, kernel_size=(5, 5), strides=(1, 1), padding="same", name="Conv_2_256_5x5_1")
- 池化層 Pool_2
x = MaxPool2D(pool_size=(3, 3), strides=(2, 2), padding="valid", name="maxpool_2_3x3_2")(x)
- 卷積層 Conv_3
x = Conv_block(x, filters=384, kernel_size=(3, 3), strides=(1, 1), padding="same", name="Conv_3_384_3x3_1")
- 卷積層 Conv_4
x = Conv_block(x, filters=384, kernel_size=(3, 3), strides=(1, 1), padding="same", name="Conv_4_384_3x3_1")
- 卷積層 Conv_5
x = Conv_block(x, filters=256, kernel_size=(3, 3), strides=(1, 1), padding="same", name="Conv_5_256_3x3_1")
- 池化層 Pool_2
x = MaxPool2D(pool_size=(3, 3), strides=(2, 2), padding="valid", name="maxpool_3_3x3_2")(x)
- 全連接層 FC_1
x = Flatten()(x)
x = dense(units=4096)(x)
x = BatchNormalization()(x)
x = Activation("relu")(x)
- 全連接層 FC_2
x = dense(units=4096)(x)
x = BatchNormalization()(x)
x = Activation("relu")(x)
- 全連接層 FC_3
x = dense(units=num_classes)(x)
x = BatchNormalization()(x)
x = Activation("softmax")(x)
個(gè)人理解
- 這里實(shí)現(xiàn)的時(shí)候有個(gè)trick, 輸入圖片大小應(yīng)該是227讯柔,這樣通過計(jì)算卷積之后才是55x55的大小抡蛙,所以我在實(shí)現(xiàn)的時(shí)候先加了 zero_padding 具體參見我Github 的代碼。
- AlexNet 網(wǎng)絡(luò)參數(shù)的大約是6千萬個(gè)左右魂迄。
- AlexNet 之后網(wǎng)絡(luò)的激活函數(shù)基本都使用 relu, 因?yàn)?relu 收斂更快粗截,沒有梯度消失問題。
- 池化也大多使用最大值池化 max pooling.
- 增加了 Batchnormalization 技術(shù)捣炬,更快收斂熊昌、類似正則化的作用怠晴,減小過擬合。
- 原文中還有 Dropout 技術(shù)浴捆,來防止過擬合蒜田,多用于全連接層
- 優(yōu)化器是 SGD.
- 當(dāng)時(shí)設(shè)置的 batch_size 為 128
- 采用了 group convolution 技術(shù),也就是分塊卷積选泻,是一種模型并行的技術(shù)冲粤。受限于當(dāng)時(shí)的技術(shù)資源,作者將卷積部分均分成兩部分页眯。優(yōu)點(diǎn)是:1. 收斂快梯捕,每次可以接收更多圖片,2. 參數(shù)少窝撵,3. 每一個(gè) filter group 可以學(xué)習(xí)到數(shù)據(jù)不同的特征傀顾。
模型講解
- ImageNet Classification with Deep Convolutional Neural Networks
http://vision.stanford.edu/teaching/cs231b_spring1415/slides/alexnet_tugce_kyunghee.pdf - Understanding AlexNet
https://www.learnopencv.com/understanding-alexnet/ - A Walk-through of AlexNet
https://medium.com/@smallfishbigsea/a-walk-through-of-alexnet-6cbd137a5637 - AlexNet
為什么使用ReLu
http://cvml.ist.ac.at/courses/DLWT_W17/material/AlexNet.pdf - AlexNet Implementation Using Keras
https://engmrk.com/alexnet-implementation-using-keras/ - AlexNet Keras Implementation
Github
https://github.com/eweill/keras-deepcv/blob/master/models/classification/alexnet.py - Plant Diseases Classification Using AlexNet
Kaggle 應(yīng)用
https://www.kaggle.com/vipoooool/plant-diseases-classification-using-alexnet - Finetuning AlexNet with TensorFlow
遷移學(xué)習(xí),fine-tune
https://kratzert.github.io/2017/02/24/finetuning-alexnet-with-tensorflow.html - AlexNet implementation + weights in TensorFlow
模型的權(quán)重碌奉,用于遷移學(xué)習(xí)
http://www.cs.toronto.edu/~guerzhoy/tf_alexnet/