內容簡介
本書首先介紹了深度學習相關的理論和主流的深度學習框架,然後從Caffe 深度學習框架為切入點,介紹了Caffe 的安裝、配置、編譯和接口等運行環境,剖析Caffe 網路模型的構成要素和常用的層類型和Solver 方法。通過LeNet 網路模型的Mnist 手寫實例介紹其樣本訓練和識別過程,進一步詳細解讀了AlexNet、VGGNet、GoogLeNet、Siamese 和SqueezeNet 網路模型,並給出了這些模型基於Caffe 的訓練實戰方法。然後,本書解讀了利用深度學習進行目標定位的經典網路模型:FCN、R-CNN、Fast-RCNN、Faster-RCNN 和SSD,並進行目標定位Caffe 實戰。本書的最後,從著名的Kaggle 網站引入了兩個經典的實戰項目,並進行了有針對性的原始數據分析、網路模型設計和Caffe 訓練策略實踐,以求帶給讀者從問題提出到利用Caffe 求解的完整工程經歷,從而使讀者能儘快掌握Caffe 框架的使用技巧和實戰經驗。針對Caffe 和深度學習領域的初學者,本書是一本不可多得的參考資料。本書的內容既有易懂的理論背景,又有豐富的套用實踐,是深度學習初學者的指導手冊,也可作為深度學習相關領域工程師和愛好者的參考用書。
目錄信息
第1 章 緒論................................................................................................................................1
1.1 引言...............................................................................................................................1
1.2 人工智慧的發展歷程....................................................................................................2
1.3 機器學習及相關技術....................................................................................................4
1.3.1 學習形式分類.....................................................................................................4
1.3.2 學習方法分類.....................................................................................................5
1.3.3 機器學習的相關技術.........................................................................................7
1.4 國內外研究現狀............................................................................................................8
1.4.1 國外研究現狀.....................................................................................................8
1.4.2 國內研究現狀.....................................................................................................9
第2 章 深度學習.......................................................................................................................11
2.1 神經網路模型..............................................................................................................11
2.1.1 人腦視覺機理...................................................................................................11
2.1.2 生物神經元.......................................................................................................13
2.1.3 人工神經網路...................................................................................................15
2.2 BP 神經網路................................................................................................................18
2.2.1 BP 神經元.........................................................................................................18
2.2.2 BP 神經網路構成.............................................................................................19
2.2.3 正向傳播...........................................................................................................21
2.2.4 反向傳播...........................................................................................................21
2.3 卷積神經網路..............................................................................................................24
2.3.1 卷積神經網路的歷史.......................................................................................25
2.3.2 卷積神經網路的網路結構...............................................................................26
2.3.3 局部感知...........................................................................................................27
2.3.4 參數共享...........................................................................................................28
2.3.5 多卷積核...........................................................................................................28
2.3.6 池化(Pooling)...............................................................................................29
2.4 深度學習框架..............................................................................................................30
2.4.1 Caffe ..................................................................................................................30
2.4.2 Torch ..................................................................................................................31
2.4.3 Keras..................................................................................................................32
2.4.4 MXNet ...............................................................................................................32
2.4.5 TensorFlow ........................................................................................................33
2.4.6 CNTK ................................................................................................................33
2.4.7 Theano ...............................................................................................................34
第3 章 Caffe 簡介及其安裝配置.............................................................................................36
3.1 Caffe 是什麼................................................................................................................36
3.1.1 Caffe 的特點......................................................................................................38
3.1.2 Caffe 的架構......................................................................................................38
3.2 Caffe 的安裝環境........................................................................................................39
3.2.1 Caffe 的硬體環境..............................................................................................39
3.2.2 Caffe 的軟體環境..............................................................................................43
3.2.3 Caffe 的依賴庫..................................................................................................44
3.2.4 Caffe 開發環境的安裝......................................................................................46
3.3 Caffe 接口....................................................................................................................52
3.3.1 Caffe Python 接口.............................................................................................52
3.3.2 Caffe MATLAB 接口........................................................................................55
3.3.3 Caffe 命令行接口..............................................................................................56
第4 章 Caffe 網路定義.............................................................................................................58
4.1 Caffe 模型要素............................................................................................................58
4.1.1 網路模型...........................................................................................................58
4.1.2 參數配置...........................................................................................................62
4.2 Google Protobuf 結構化數據.......................................................................................63
4.3 Caffe 資料庫................................................................................................................65
4.3.1 LevelDB.............................................................................................................65
4.3.2 LMDB................................................................................................................66
4.3.3 HDF5 .................................................................................................................66
4.4 Caffe Net.......................................................................................................................66
4.5 Caffe Blob.....................................................................................................................68
4.6 Caffe Layer ...................................................................................................................70
4.6.1 Data Layers........................................................................................................71
4.6.2 Convolution Layers............................................................................................75
4.6.3 Pooling Layers ...................................................................................................76
4.6.4 InnerProduct Layers...........................................................................................77
4.6.5 ReLU Layers......................................................................................................78
4.6.6 Sigmoid Layers..................................................................................................79
4.6.7 LRN Layers .......................................................................................................79
4.6.8 Dropout Layers ..................................................................................................80
4.6.9 SoftmaxWithLoss Layers...................................................................................80
4.6.10 Softmax Layers................................................................................................81
4.6.11 Accuracy Layers ..............................................................................................81
4.7 Caffe Solver ..................................................................................................................82
Solver 方法....................................................................................................................83
第5 章 LeNet 模型....................................................................................................................88
5.1 LeNet 模型簡介...........................................................................................................88
5.2 LeNet 模型解讀...........................................................................................................89
5.3 Caffe 環境LeNet 模型.................................................................................................91
5.3.1 mnist 實例詳解.................................................................................................91
5.3.2 mnist 手寫測試...............................................................................................103
5.3.3 mnist 樣本字型檔的圖片轉換............................................................................106
第6 章 AlexNet 模型..............................................................................................................107
6.1 AlexNet 模型介紹......................................................................................................107
6.2 AlexNet 模型解讀......................................................................................................108
6.3 AlexNet 模型特點......................................................................................................111
6.4 Caffe 環境AlexNet 模型訓練...................................................................................112
6.4.1 數據準備.........................................................................................................112
6.4.2 其他支持檔案.................................................................................................113
6.4.3 圖片預處理.....................................................................................................113
6.4.4 ImageNet 數據集介紹.....................................................................................113
6.4.5 ImageNet 圖片介紹.........................................................................................115
6.4.6 ImageNet 模型訓練.........................................................................................115
6.4.7 Caffe 的AlexNet 模型與論文的不同............................................................124
6.4.8 ImageNet 模型測試.........................................................................................124
第7 章 GoogLeNet 模型........................................................................................................126
7.1 GoogLeNet 模型簡介................................................................................................126
7.1.1 背景和動機.....................................................................................................127
7.1.2 Inception 結構.................................................................................................127
7.2 GoogLeNet 模型解讀................................................................................................129
7.2.1 GoogLeNet 模型結構......................................................................................129
7.2.2 GoogLeNet 模型特點......................................................................................134
7.3 GoogLeNet 模型的Caffe 實現..................................................................................135
第8 章 VGGNet 模型.............................................................................................................146
8.1 VGGNet 網路模型.....................................................................................................146
8.1.1 VGGNet 模型介紹..........................................................................................146
8.1.2 VGGNet 模型特點..........................................................................................147
8.1.3 VGGNet 模型解讀..........................................................................................147
8.2 VGGNet 網路訓練.....................................................................................................149
8.2.1 VGGNet 訓練參數設定..................................................................................149
8.2.2 Multi-Scale 訓練.............................................................................................149
8.2.3 測試.................................................................................................................150
8.2.4 部署.................................................................................................................150
8.3 VGGNet 模型分類實驗.............................................................................................150
8.3.1 Single-scale 對比.............................................................................................150
8.3.2 Multi-scale 對比..............................................................................................151
8.3.3 模型融合.........................................................................................................152
8.4 VGGNet 網路結構.....................................................................................................153
第9 章 Siamese 模型.............................................................................................................158
9.1 Siamese 網路模型......................................................................................................159
9.1.1 Siamese 模型原理...........................................................................................159
9.1.2 Siamese 模型實現...........................................................................................160
9.2 Siamese 網路訓練......................................................................................................165
9.2.1 數據準備.........................................................................................................165
9.2.2 生成side..........................................................................................................165
9.2.3 對比損失函式.................................................................................................166
9.2.4 定義solver.......................................................................................................166
9.2.5 網路訓練.........................................................................................................166
第10 章 SqueezeNet 模型....................................................................................................168
10.1 SqueezeNet 網路模型..............................................................................................168
10.1.1 SqueezeNet 模型原理...................................................................................168
10.1.2 Fire Module ...................................................................................................169
10.1.3 SqueezeNet 模型結構...................................................................................170
10.1.4 SqueezeNet 模型特點...................................................................................171
10.2 SqueezeNet 網路實現..............................................................................................172
第11 章 FCN 模型..................................................................................................................177
11.1 FCN 模型簡介..........................................................................................................177
11.2 FCN 的特點和使用場景..........................................................................................178
11.3 Caffe FCN 解讀........................................................................................................179
11.3.1 FCN 模型訓練準備.......................................................................................180
11.3.1 FCN 模型訓練...............................................................................................183
第12 章 R-CNN 模型.............................................................................................................196
12.1 R-CNN 模型簡介.....................................................................................................196
12.2 R-CNN 的特點和使用場景.....................................................................................197
12.3 Caffe R-CNN 解讀...................................................................................................198
12.3.1 R-CNN 模型訓練準備..................................................................................198
12.3.2 R-CNN 模型訓練..........................................................................................201
第13 章 Fast-RCNN 模型.....................................................................................................217
13.1 Fast-RCNN 模型簡介..............................................................................................217
13.2 Fast-RCNN 的特點和使用場景..............................................................................218
13.3 Caffe Fast-RCNN 解讀............................................................................................220
13.3.1 Fast-RCNN 模型訓練準備...........................................................................220
13.3.2 Fast-RCNN 模型訓練...................................................................................222
第14 章 Faster-RCNN 模型..................................................................................................239
14.1 Faster-RCNN 模型簡介...........................................................................................239
14.2 Faster-RCNN 的特點和使用場景...........................................................................241
14.3 Caffe Faster-RCNN 解讀.........................................................................................242
14.3.1 Faster-RCNN 模型訓練準備........................................................................242
14.3.2 Faster-RCNN 模型訓練................................................................................244
第15 章 SSD 模型..................................................................................................................264
15.1 SSD 模型簡介..........................................................................................................264
15.2 SSD 的特點和使用場景..........................................................................................266
15.3 Caffe SSD 解讀........................................................................................................267
15.3.1 SSD 模型訓練準備.......................................................................................267
15.3.2 SSD 模型訓練...............................................................................................268
第16 章 Kaggle 項目實踐:人臉特徵檢測..........................................................................290
16.1 項目簡介..................................................................................................................290
16.2 賽題和數據..............................................................................................................291
16.3 Caffe 訓練和測試資料庫.........................................................................................293
16.3.1 資料庫生成...................................................................................................293
16.3.2 網路對比.......................................................................................................295
16.3.3 網路一...........................................................................................................296
16.3.4 網路二...........................................................................................................300
16.3.5 Python 人臉特徵預測程式...........................................................................306
第17 章 Kaggle 項目實踐:貓狗分類檢測..........................................................................311
17.1 項目簡介..................................................................................................................311
17.2 賽題和數據..............................................................................................................312
17.3 Caffe 訓練和測試資料庫.........................................................................................312
17.3.1 資料庫生成...................................................................................................312
17.3.2 Caffe 實現......................................................................................................316
17.3.3 CatdogNet 訓練.............................................................................................328
17.3.4 CatdogNet 模型驗證.....................................................................................332