caffe源码解析caffeproto文档格式.docx
《caffe源码解析caffeproto文档格式.docx》由会员分享,可在线阅读,更多相关《caffe源码解析caffeproto文档格式.docx(19页珍藏版)》请在冰豆网上搜索。
caffe.proto中的几个重要数据类型
caffe.pb.cc里面的东西都是从caffe.proto编译而来的,无非就是一些关于这些数据结构(类)的标准化操作,比如
voidCopyFrom();
voidMergeFrom();
voidClear();
boolIsInitialized()const;
intByteSize()const;
boolMergePartialFromCodedStream();
voidSerializeWithCachedSizes()const;
SerializeWithCachedSizesToArray()const;
intGetCachedSize()
voidSharedCtor();
voidSharedDtor();
voidSetCachedSize()const;
<
0>
BlobProto
messageBlobProto{//blob的属性以及blob中的数据(data\diff)
optionalint32num=1[default=0];
optionalint32channels=2[default=0];
optionalint32height=3[default=0];
optionalint32width=4[default=0];
repeatedfloatdata=5[packed=true];
repeatedfloatdiff=6[packed=true];
}
1>
Datum
messageDatum{
optionalint32channels=1;
optionalint32height=2;
optionalint32width=3;
optionalbytesdata=4;
//真实的图像数据,以字节存储(bytes)
optionalint32label=5;
repeatedfloatfloat_data=6;
//datum也能存float类型的数据(float)
2>
LayerParameter
messageLayerParameter{
repeatedstringbottom=2;
//输入的blob的名字(string)
repeatedstringtop=3;
//输出的blob的名字(string)
optionalstringname=4;
//层的名字
enumLayerType{//层的枚举(enum,和c++中的enum一样)
NONE=0;
ACCURACY=1;
BNLL=2;
CONCAT=3;
CONVOLUTION=4;
DATA=5;
DROPOUT=6;
EUCLIDEAN_LOSS=7;
ELTWISE_PRODUCT=25;
FLATTEN=8;
HDF5_DATA=9;
HDF5_OUTPUT=10;
HINGE_LOSS=28;
IM2COL=11;
IMAGE_DATA=12;
INFOGAIN_LOSS=13;
INNER_PRODUCT=14;
LRN=15;
MEMORY_DATA=29;
MULTINOMIAL_LOGISTIC_LOSS=16;
POOLING=17;
POWER=26;
RELU=18;
SIGMOID=19;
SIGMOID_CROSS_ENTROPY_LOSS=27;
SOFTMAX=20;
SOFTMAX_LOSS=21;
SPLIT=22;
TANH=23;
WINDOW_DATA=24;
}
optionalLayerTypetype=5;
//层的类型
repeatedBlobProtoblobs=6;
//blobs的数值参数
repeatedfloatblobs_lr=7;
//学习速率(repeated),如果你想设置一个blob的学习速率,你需要设置所有blob的学习速率。
repeatedfloatweight_decay=8;
//权值衰减(repeated)
//相对于某一特定层的参数(optional)
optionalConcatParameterconcat_param=9;
optionalConvolutionParameterconvolution_param=10;
optionalDataParameterdata_param=11;
optionalDropoutParameterdropout_param=12;
optionalHDF5DataParameterhdf5_data_param=13;
optionalHDF5OutputParameterhdf5_output_param=14;
optionalImageDataParameterimage_data_param=15;
optionalInfogainLossParameterinfogain_loss_param=16;
optionalInnerProductParameterinner_product_param=17;
optionalLRNParameterlrn_param=18;
optionalMemoryDataParametermemory_data_param=22;
optionalPoolingParameterpooling_param=19;
optionalPowerParameterpower_param=21;
optionalWindowDataParameterwindow_data_param=20;
optionalV0LayerParameterlayer=1;
3>
NetParameter
messageNetParameter{
optionalstringname=1;
//网络的名字
repeatedLayerParameterlayers=2;
//repeated类似于数组
repeatedstringinput=3;
//输入层blob的名字
repeatedint32input_dim=4;
//输入层blob的维度,应该等于(4*#input)
optionalboolforce_backward=5[default=false];
//网络是否进行反向传播。
如果设置为否,则由网络的结构和学习速率来决定是否进行反向传播。
4>
SolverParameter
messageSolverParameter{
optionalstringtrain_net=1;
//训练网络的protofile
optionalstringtest_net=2;
//测试网络的protofile
optionalint32test_iter=3[default=0];
//每次测试时的迭代次数
optionalint32test_interval=4[default=0];
//两次测试的间隔迭代次数
optionalbooltest_compute_loss=19[default=false];
optionalfloatbase_lr=5;
//基本学习率
optionalint32display=6;
//两次显示的间隔迭代次数
optionalint32max_iter=7;
//最大迭代次数
optionalstringlr_policy=8;
//学习速率衰减方式
optionalfloatgamma=9;
//关于梯度下降的一个参数
optionalfloatpower=10;
//计算学习率的一个参数
optionalfloatmomentum=11;
//动量
optionalfloatweight_decay=12;
//权值衰减
optionalint32stepsize=13;
//学习速率的衰减步长
optionalint32snapshot=14[default=0];
//snapshot的间隔
optionalstringsnapshot_prefix=15;
//snapshot的前缀
optionalboolsnapshot_diff=16[default=false];
//是否对于diff进行snapshot
enumSolverMode{
CPU=0;
GPU=1;
optionalSolverModesolver_mode=17[default=GPU];
//solver的模式,默认为GPU
optionalint32device_id=18[default=0];
//GPU的ID
optionalint64random_seed=20[default=-1];
//随机数种子
caffe.proto源码
//Copyright2014BVLCandcontributors.
packagecaffe;
messageBlobProto{
//TheBlobProtoVectorissimplyawaytopassmultipleblobprotoinstances
//around.
messageBlobProtoVector{
repeatedBlobProtoblobs=1;
messageDatum{
//theactualimagedata,inbytes
//Optionally,thedatumcouldalsoholdfloatdata.
messageFillerParameter{
//Thefillertype.
optionalstringtype=1[default='
constant'
];
optionalfloatvalue=2[default=0];
//thevalueinconstantfiller
optionalfloatmin=3[default=0];
//theminvalueinuniformfiller
optionalfloatmax=4[default=1];
//themaxvalueinuniformfiller
optionalfloatmean=5[default=0];
//themeanvalueinGaussianfiller
optionalfloatstd=6[default=1];
//thestdvalueinGaussianfiller
//Theexpectednumberofnon-zeroinputweightsforagivenoutputin
//Gaussianfiller--thedefault-1meansdon'
tperformsparsification.
optionalint32sparse=7[default=-1];
//considergivingthenetworkaname
//abunchoflayers.
//Theinputblobstothenetwork.
//Thedimoftheinputblobs.Foreachinputblobthereshouldbefour
//valuesspecifyingthenum,channels,heightandwidthoftheinputblob.
//Thus,thereshouldbeatotalof(4*#input)numbers.
//Whetherthenetworkwillforceeverylayertocarryoutbackwardoperation.
//IfsetFalse,thenwhethertocarryoutbackwardisdetermined
//automaticallyaccordingtothenetstructureandlearningrates.
//Theprotofileforthetrainingnet.
//Theprotofileforthetestingnet.
//Thenumberofiterationsforeachtestingphase.
//Thenumberofiterationsbetweentwotestingphases.
//Thebaselearningrate
//thenumberofiterationsbetweendisplayinginfo.Ifdisplay=0,noinfo
//willbedisplayed.
//themaximumnumberofiterations
//Thelearningratedecaypolicy.
//Theparametertocomputethelearningrate.
//Themomentumvalue.
//Theweightdecay.
//thestepsizeforlearningratepolicy"
step"
//Thesnapshotinterval
//Theprefixforthesnapshot.
//whethertosnapshotdiffintheresultsornot.Snapshottingdiffwillhelp
//debuggingbutthefinalprotocolbuffersizewillbemuchlarger.
//themodesolverwilluse:
0forCPUand1forGPU.UseGPUindefault.
//thedevice_idwillthatbeusedinGPUmode.Usedevice_id=0indefault.
//Ifnon-negative,theseedwithwhichtheSolverwillinitializetheCaffe
//randomnumbergenerator--usefulforreproducibleresults.Otherwise,
//(andbydefault)initializeusingaseedderivedfromthesystemclock.
//Amessagethatstoresthesolversnapshots
messageSolverState{
optionalint32iter=1;
//Thecurrentiteration
optionalstringlearned_net=2;
//Thefilethatstoresthelearnednet.
repeatedBlobProtohistory=3;
//Thehistoryforsgdsolvers
//UpdatethenextavailableIDwhenyouaddanewLayerParameterfield.
//
//LayerParameternextavailableID:
23(lastadded:
memory_data_param)
//thenameofthebottomblobs
//thenameofthetopblobs
//thelayername
//AddnewLayerTypestotheenumbelowinlexicographicalorder(otherthan
//startingwithNONE),startingwiththenextavailableIDinthecomment
//lineabovetheenum.UpdatethenextavailableIDwhenyouaddanew
//LayerType.
//
//LayerTypenextavailableID:
30(lastadded:
MEMORY_DATA)