标签:
因工作交接须要。 要将caffe用法及总体结构描写叙述清楚。
鉴于也有同学问过我相关内容, 决定在本文中写个简单的tutorial, 方便大家參考。
本文简单的讲几个事情:
Caffe能做什么?
为什么选择caffe?
环境:
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 12.04.4 LTS
Release: 12.04
Codename: precise
$ cat /proc/version
Linux version 3.2.0-29-generic (buildd@allspice) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012
Vim + Taglist + Cscope
总体结构:
定义CAFFE为caffe跟文件夹,caffe的核心代码都在$CAFFE/src/caffe 下,主要有下面部分:net, blob, layer, solver.
net.cpp:
net定义网络。 整个网络中含有非常多layers, net.cpp负责计算整个网络在训练中的forward, backward过程, 即计算forward/backward 时各layer的gradient。
layers:
在$CAFFE/src/caffe/layers中的层。在protobuffer (.proto文件里定义message类型。.prototxt或.binaryproto文件里定义message的值) 中调用时包括属性name, type(data/conv/pool…)。 connection structure (input blobs and output blobs),layer-specific parameters(如conv层的kernel大小)。定义一个layer须要定义其setup, forward 和backward过程。
blob.cpp:
net中的数据和求导结果通过4维的blob传递。一个layer有非常多blobs, e.g,
slover.cpp:
结合loss。用gradient更新weights。
主要函数:
Init(),
Solve(),
ComputeUpdateValue(),
Snapshot(), Restore(),//快照(拷贝)与恢复 网络state
Test()。
在solver.cpp中有3中solver。即3个类:AdaGradSolver, SGDSolver和NesterovSolver可供选择。
关于loss。能够同一时候有多个loss。能够加regularization(L1/L2);
Protocol buffer:
上面已经将过。 protocol buffer在 .proto文件里定义message类型,.prototxt或.binaryproto文件里定义message的值;
Caffe
Caffe的全部message定义在$CAFFE/src/caffe/proto/caffe.proto中。
Experiment
在实验中,主要用到两个protocol buffer: solver的和model的,分别定义solver參数(学习率啥的)和model结构(网络结构)。
技巧:
训练基本流程:
在python中训练:
Document & Examples: https://github.com/BVLC/caffe/pull/1733
核心code:
Debug:
经典文献:
[ DeCAF ] J. Donahue, Y. Jia, O. Vinyals, J. Hoffman, N. Zhang, E. Tzeng, and T. Darrell. Decaf: A deep convolutional activation feature for generic visual recognition. ICML, 2014.
[ R-CNN ] R. Girshick, J. Donahue, T. Darrell, and J. Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. CVPR, 2014.
[ Zeiler-Fergus Visualizing] M. Zeiler and R. Fergus. visualizing and understanding convolutional networks. ECCV, 2014.
[ LeNet ] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. IEEE, 1998.
[ AlexNet ] A. Krizhevsky, I. Sutskever, and G. Hinton. Imagenet classification with deep convolutional neural networks. NIPS, 2012.
[ OverFeat ] P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus, and Y. LeCun. Overfeat: Integrated recognition, localization and detection using convolutional networks. ICLR, 2014.
[ Image-Style (Transfer learning) ] S. Karayev, M. Trentacoste, H. Han, A. Agarwala, T. Darrell, A. Hertzmann, H. Winnemoeller. Recognizing Image Style. BMVC, 2014.
[ Karpathy14 ] A. Karpathy, G. Toderici, S. Shetty, T. Leung, R. Sukthankar, and L. Fei-Fei. Large-scale video classification with convolutional neural networks. CVPR, 2014.
[ Sutskever13 ] I. Sutskever. Training Recurrent Neural Networks. PhD thesis, University of Toronto, 2013.
[ Chopra05 ] S. Chopra, R. Hadsell, and Y. LeCun. Learning a similarity metric discriminatively, with application to face verification. CVPR, 2005.
Caffe —— Deep learning in Practice
标签:
原文地址:http://www.cnblogs.com/bhlsheji/p/5203386.html