【一】以 lenet_train_test.prototxt 为例
name: "LeNet"
layer {name: "mnist"type: "Data"top: "data"top: "label"include {phase: TRAIN}transform_param {scale: 0.00390625}data_param {source: "examples/mnist/mnist_train_lmdb"batch_size: 64backend: LMDB}
}
layer {name: "mnist"type: "Data"top: "data"top: "label"include {phase: TEST}transform_param {scale: 0.00390625}data_param {source: "examples/mnist/mnist_test_lmdb"batch_size: 100backend: LMDB}
}
layer {name: "conv1"type: "Convolution"bottom: "data"top: "conv1"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 20kernel_size: 5stride: 1weight_filler {type: "xavier"}bias_filler {type: "constant"}}
}
layer {name: "pool1"type: "Pooling"bottom: "conv1"top: "pool1"pooling_param {pool: MAXkernel_size: 2stride: 2}
}
layer {name: "conv2"type: "Convolution"bottom: "pool1"top: "conv2"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 50kernel_size: 5stride: 1weight_filler {type: "xavier"}bias_filler {type: "constant"}}
}
layer {name: "pool2"type: "Pooling"bottom: "conv2"top: "pool2"pooling_param {pool: MAXkernel_size: 2stride: 2}
}
layer {name: "ip1"type: "InnerProduct"bottom: "pool2"top: "ip1"param {lr_mult: 1}param {lr_mult: 2}inner_product_param {num_output: 500weight_filler {type: "xavier"}bias_filler {type: "constant"}}
}
layer {name: "relu1"type: "ReLU"bottom: "ip1"top: "ip1"
}
layer {name: "ip2"type: "InnerProduct"bottom: "ip1"top: "ip2"param {lr_mult: 1}param {lr_mult: 2}inner_product_param {num_output: 10weight_filler {type: "xavier"}bias_filler {type: "constant"}}
}
layer {name: "accuracy"type: "Accuracy"bottom: "ip2"bottom: "label"top: "accuracy"include {phase: TEST}
}
layer {name: "loss"type: "SoftmaxWithLoss"bottom: "ip2"bottom: "label"top: "loss"
}
}
【二】参数详解

包级参数

name :定义网络名称

可以随便起,例子中为"LeNet"

layer {定义层结构

name :层的名称

例如,输入层名称为“mnist”

type :层的类型

例如,输入层的类型为“Data”、卷积层“Convolution”、池化层“Pooling”、全连接层“InnerProduct”、激活层“ReLU”、计算精度“Accuracy”、Softmax损失层“SoftmaxWithLoss”

top :用来标记输出数据(blob)。例如,在训练中,输入层有两个top分别为“data”和“label”,分别存放了数据和标签。

bottom :用来标记输入数据(blob)

它的上层的top相同,输入层是顶层,因此没有bottom blob。如果该层的bottom和top相同,则该层的输入和输出占用了一个blob。

include {当前层所属的阶段

一般训练的时候和测试的时候,模型的层是不一样的。该层(layer)是属于训练阶段的层,还是属于测试阶段的层,需要用include来指定。 如果没有include参数,则表示该层既在训练模型中,又在测试模型中。

 phase:当前层的阶段;TRAIN:训练;TEST:测试;
}

data_param {定义数据参数、数据来源等等

source       : 包含数据库的目录名称,如examples/mnist/mnist_train_lmdb
batch_size  : 每次处理的数据个数,如64
rand_skip       : 在开始的时候,路过某个数据的输入。通常对异步的SGD很有用。
backend     : 选择是采用LevelDB还是LMDB, 默认是LevelDB.
}
transform_param {数据的预处理,可以将数据变换到定义的范围内。
scale :0.00390625,实际上就是1/255, 即将输入数据由0-255归一化到0-1之间
mean_file_size: "examples/cifar10/mean.binaryproto" ,用一个配置文件来进行均值操作
mirror: 1  ,1表示开启镜像,0表示关闭,也可用ture和false来表示
crop_size: 227   ,剪裁一个 227*227的图块,在训练阶段随机剪裁,在测试阶段从中间裁剪
}

param {定义weight或bias的学习速率和衰减因子参数。

  lr_mult        : weight或bias的学习速率decay_mult     :weight或bias的衰减因子}
convolution_param {定义卷积层的参数。
  num_output     :输出的个数;即卷积核的个数;pad             :填充边缘的大小。可使用pad_h和pad_w来分别设定kernel_size  :卷积核的大小,如果卷积核的长和宽不等,需要用kernel_h和kernel_w分别设定group      :分组,默认为1组。卷积分组可以减少网络的参数。 weight_filler :权值初始化,若设置为constant, 则默认为0。也可使用"xavier"或者”gaussian"进行初始化bias_filler  :偏置项的初始化,参考weight_filler
}
lrn_param {定义归一化层的参数
  local_size     :对于cross channel LRN为需要求和的邻近channel的数量;对于within channel LRN为需要求和的空间区域的边长alpha         :缩放参数;默认为1;beta            :β系数;默认为5norm_region  : [default ACROSS_CHANNELS]: 选择哪种LRN的方法ACROSS_CHANNELS 或者WITHIN_CHANNEL
}
pooling_param {定义池化层的参数
  kernel_size    :必选;(or kernel_h and kernel_w):过滤器的大小pool          :可选;池化的方法,最大值池化MAX、平均值池化AVE 和 随机池化STOCHASTIC;默认MAXstride        :可选(or stride_h and stride_w) [default1]:指定过滤器的步长
}

inner_product_param {定义全连接层的参数

inner_product_param级别参数num_output    :过滤器个数。必选;weight_filler   :[default type: 'constant' value: 0]:参数的初始化方法bias_filler  :偏置的初始化方法 {weight_filler 和 bias_filler级别参数type   :初始化类型;有 常量“constant” 高斯分布“gaussian” “uniform” “Xavier”等等。常用的是“constant”和“gaussian”std    :标准差;如果是 gaussian,则可选的设置它;默认值为1;mean     :均值;如果是 gaussian,则可选的设置它;默认值为0;value     :定值;如果是“constant”,则设置它;默认值为0;}
}

dropout_param :定义Dropout层的参数

accuracy_param :定义Accuracy层的参数

}
}

【三】官方说明

参见:caffe/src/caffe/proto/caffe.proto中message ParamSpec

// Specifies training parameters (multipliers on global learning constants, and the name and other settings used for weight sharing).
// 指定训练参数(全局学习常数的乘数,以及用于权重共享的名称和其他设置)。
message ParamSpec {// The names of the parameter blobs -- useful for sharing parameters among layers, but never required otherwise.  To share a parameter between two layers, give it a (non-empty) name.// 参数块的名称——用于在层之间共享参数,但在其他情况下不需要。要在两个层之间共享一个参数,请给它一个(非空)名称。optional string name = 1;// Whether to require shared weights to have the same shape, or just the same count -- defaults to STRICT if unspecified.// 是否要求共享的权重具有相同的形状,或者只是相同的计数——如果未指定,默认为STRICT。optional DimCheckMode share_mode = 2;enum DimCheckMode {// STRICT (default) requires that num, channels, height, width each match. STRICT(默认值)要求num、通道、高度和宽度都匹配STRICT = 0;// PERMISSIVE requires only the count (num*channels*height*width) to match. PERMISSIVE只要求count(num*channels*height*width)匹配PERMISSIVE = 1;}// The multiplier on the global learning rate for this parameter.全局学习率的乘数。optional float lr_mult = 3 [default = 1.0];// The multiplier on the global weight decay for this parameter.全局权值的乘数衰减。optional float decay_mult = 4 [default = 1.0];
}// NOTE
// Update the next available ID when you add a new LayerParameter field. 在添加新LayerParameter字段时更新下一个可用ID。
//
// LayerParameter next available layer-specific ID: 149 (last added: clip_param)
message LayerParameter {optional string name = 1; // the layer nameoptional string type = 2; // the layer typerepeated string bottom = 3; // the name of each bottom blobrepeated string top = 4; // the name of each top blob// The train / test phase for computation.optional Phase phase = 10;// The amount of weight to assign each top blob in the objective.// Each layer assigns a default value, usually of either 0 or 1, to each top blob.// 在目标中分配每个顶部blob的权重。每个层为每个顶部blob分配一个默认值,通常为0或1。repeated float loss_weight = 5;// Specifies training parameters (multipliers on global learning constants, and the name and other settings used for weight sharing).// 指定训练参数(全局学习常数的乘数,以及用于权重共享的名称和其他设置)。repeated ParamSpec param = 6;// The blobs containing the numeric parameters of the layer. 包含该层的数值参数的块。repeated BlobProto blobs = 7;// Specifies whether to backpropagate to each bottom. If unspecified, Caffe will automatically infer whether each input needs backpropagation to compute parameter gradients. // If set to true for some inputs, backpropagation to those inputs is forced; if set false for some inputs, backpropagation to those inputs is skipped.// The size must be either 0 or equal to the number of bottoms.// 指定是否反向传播到每个底部。如果未指定,Caffe将自动推断每个输入是否需要反向传播来计算参数梯度。// 如果对某些输入设置为true,则强制反向传播到这些输入;如果某些输入设置为false,则跳过对这些输入的反向传播。大小必须是0或等于底部的数量。repeated bool propagate_down = 11;// Rules controlling whether and when a layer is included in the network,based on the current NetState.  // You may specify a non-zero number of rules to include OR exclude, but not both.  If no include or exclude rules are specified, the layer is always included.  // If the current NetState meets ANY (i.e., one or more) of the specified rules, the layer is included/excluded.// 根据当前网络状态控制网络中是否包含层以及何时包含层的规则。// 你可以指定一个非零数的规则来包含或排除,但不能同时包含或排除。如果没有指定包含或排除规则,则始终包含该层。// 如果当前网络状态满足任何,一个或多个)指定的规则,该层被包括/排除。repeated NetStateRule include = 8;repeated NetStateRule exclude = 9;// Parameters for data pre-processing. 用于数据预处理的参数。optional TransformationParameter transform_param = 100;// Parameters shared by loss layers. 损耗层共享的参数。optional LossParameter loss_param = 101;// Layer type-specific parameters. Layer特定类型参数。//// Note: certain layers may have more than one computational engine for their implementation. // These layers include an Engine type and engine parameter for selecting the implementation.// The default for the engine is set by the ENGINE switch at compile-time.// 注意:某些层的实现可能有多个计算引擎。 这些层包括用于选择实现的引擎类型和引擎参数。 引擎的默认值由引擎开关在编译时设置。optional AccuracyParameter accuracy_param = 102;optional ArgMaxParameter argmax_param = 103;optional BatchNormParameter batch_norm_param = 139;optional BiasParameter bias_param = 141;optional ClipParameter clip_param = 148;optional ConcatParameter concat_param = 104;optional ContrastiveLossParameter contrastive_loss_param = 105;optional ConvolutionParameter convolution_param = 106;optional CropParameter crop_param = 144;optional DataParameter data_param = 107;optional DropoutParameter dropout_param = 108;optional DummyDataParameter dummy_data_param = 109;optional EltwiseParameter eltwise_param = 110;optional ELUParameter elu_param = 140;optional EmbedParameter embed_param = 137;optional ExpParameter exp_param = 111;optional FlattenParameter flatten_param = 135;optional HDF5DataParameter hdf5_data_param = 112;optional HDF5OutputParameter hdf5_output_param = 113;optional HingeLossParameter hinge_loss_param = 114;optional ImageDataParameter image_data_param = 115;optional InfogainLossParameter infogain_loss_param = 116;optional InnerProductParameter inner_product_param = 117;optional InputParameter input_param = 143;optional LogParameter log_param = 134;optional LRNParameter lrn_param = 118;optional MemoryDataParameter memory_data_param = 119;optional MVNParameter mvn_param = 120;optional ParameterParameter parameter_param = 145;optional PoolingParameter pooling_param = 121;optional PowerParameter power_param = 122;optional PReLUParameter prelu_param = 131;optional PythonParameter python_param = 130;optional RecurrentParameter recurrent_param = 146;optional ReductionParameter reduction_param = 136;optional ReLUParameter relu_param = 123;optional ReshapeParameter reshape_param = 133;optional ScaleParameter scale_param = 142;optional SigmoidParameter sigmoid_param = 124;optional SoftmaxParameter softmax_param = 125;optional SPPParameter spp_param = 132;optional SliceParameter slice_param = 126;optional SwishParameter swish_param = 147;optional TanHParameter tanh_param = 127;optional ThresholdParameter threshold_param = 128;optional TileParameter tile_param = 138;optional WindowDataParameter window_data_param = 129;
}

【AI】caffe使用步骤(二):设计网络模型prototxt相关推荐

  1. 【AI】caffe使用步骤(四):训练和预测

    一.训练 1.直接训练 ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt ./build/tools/ca ...

  2. AI框架精要:设计思想

    AI框架精要:设计思想 本文主要介绍飞桨paddle平台的底层设计思想,可以帮助用户理解飞桨paddle框架的运作过程,以便于在实际业务需求中,更好的完成模型代码编写与调试及飞桨paddle框架的二次 ...

  3. Caffe版Faster R-CNN可视化——网络模型,图像特征,Loss图,PR曲线

    可视化网络模型   Caffe目前有两种常用的可视化模型方式: 使用Netscope在线可视化 Caffe代码包内置的draw_net.py文件可以可视化网络模型 Netscope能可视化神经网络体系 ...

  4. Caffe学习系列(18): 绘制网络模型

    转载自: Caffe学习系列(18): 绘制网络模型 - denny402 - 博客园 http://www.cnblogs.com/denny402/p/5106764.html python/dr ...

  5. ai项目实施步骤_停止AI产品开发中道德责任的6个步骤

    ai项目实施步骤 这是官方的:人工智能(AI)并不是我们想要成为的公正的天才. Google的母公司Alphabet(Alphabet)使用其最新的年度报告来警告称,对其产品的道德顾虑可能会损害未来的 ...

  6. 计算机反求设计的一般步骤,逆向设计的概念和基本步骤

    一.逆向设计的概念: 讲逆向设计前,先来看下传统产品开发的流程:构思-设计-产品原型.顾名思义,所谓逆向设计理念恰好与正向设计相反. 逆向设计,又反求设计,逆向工程,是一种基于逆向推理的设计,通过对现 ...

  7. HTML设计的步骤,网页设计详细操作步骤

    网页设计详细操作步骤 网页设计是一个比较吃香的行业,要真正做一个好的网页,还必须有良好的设计功底.下面是小编分享的网页设计详细操作步骤,一起来看一下吧. 一.确定网页主题 网页主题就是你建立的网页所要 ...

  8. 全数字实时仿真软件SkyEye与可信编译器L2C的核心翻译步骤的设计与实现

    有关翻译正确性验证的重点疑难问题及其设计实现方案 在L2C可信编译器的设计与实现中, 对于实线所对应的翻译过程 (CompCert编译器除外) 均借助于Coq证明了正确性 (语义保持性), 然后得出L ...

  9. iPhone App创建与审核步骤二:如何在developer.apple.com网站中设置App预览和截屏以完成App上架

    iPhone App创建与审核步骤二:如何在developer.apple.com网站中设置App预览和截屏以完成App上架,根据图标规范RAD Studio 10.4 for delphi XE 或 ...

最新文章

  1. 资料分享:数学建模资料分享 -- 神经网络部分
  2. linux下的zz命令,linux中cut命令的用法
  3. 云计算技术 — 公有云
  4. 需求用例分析之八:用例颗粒度
  5. Nginx 源码分析-- 模块module 解析执行 nginx.conf 配置文件流程分析 一
  6. Java中toString函数干嘛用?
  7. 蘑菇街2015校招 Java研发笔试题 详解,2015java
  8. 重言式判别c语言中文网,重言式判别 重言式判别源码及课程设计 c语言版.doc
  9. mgg mysql_mgg文件怎么转换mp3格式?
  10. webpack代理解决跨域
  11. 数据结构:队列的了解与示例(CPU处理任务的时间)
  12. 关于groupby与层次化索引的联系和层次化标签的使用
  13. 【Flutter】Dart中的Mixins混入你知道是什么吗?
  14. Swift给每个开发者赢取500万的机会!不看一生后悔。
  15. NC文件数据提取完成(1.16)
  16. Chrome 插件PPAPI 开发(一)环境搭建
  17. 全国各省五等份收入统计(2000-2017年)
  18. 【狂神说】Spring学习笔记(全)
  19. 自然语言处理——基于预训练模型的方法——第1章 绪论
  20. Android ViewGroup介绍+实例

热门文章

  1. 【camera】3.相机成像颜色及其组成
  2. Qt开发环境的下载地址
  3. MXNET源码中TShape值的获取和打印
  4. python创建对象的格式为_Python入门基础学习(面向对象)
  5. 微擎url模式解读_微擎开发文档之微擎执行主流程介绍
  6. 解决Qt+OpenGL更换图像纹理的问题
  7. 在CentOS 6.6 x86_64上安装SystemTap/Perf+FlameGraph玩转火焰图实录
  8. 在Ubuntu 14.04 64bit上升级安装ATS 5.3.2/6.1.1实录
  9. 在Ubuntu 14.04 64bit上安装epub阅读器Sigil 0.8.2
  10. 学习在Unity中创建一个动作RPG游戏