在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层、卷积操作层、pooling层、非线性变换层、内积运算层、归一化层、损失计算层等;本篇主要介绍卷积层

参考

1. 卷积层总述

下面首先给出卷积层的结构设置的一个小例子(定义在.prototxt文件中)

layer {

  name: "conv1" // 该层的名字
type: "Convolution" // 该层的类型,具体地,可选的类型有:Convolution、
bottom: "data" // 该层的输入数据Blob的名字
top: "conv1" // 该层的输出数据Blob的名字 // 该层的权值和偏置相关参数
param {
lr_mult: //weight的学习率
}
param {
lr_mult: // bias的学习率
} // 该层(卷积层)的卷积运算相关的参数
convolution_param {
num_output:
kernel_size:
stride:
weight_filler {
type: "xavier" // weights初始化方法
}
bias_filler {
type: "constant" // bias初始化方法
}
} }

注:在caffe的原始proto文件中,关于卷积层的参数ConvolutionPraram定义如下:

message ConvolutionParameter {
optional uint32 num_output = ; // The number of outputs for the layer
optional bool bias_term = [default = true]; // whether to have bias terms // Pad, kernel size, and stride are all given as a single value for equal dimensions in all spatial dimensions, or once per spatial dimension.
repeated uint32 pad = ; // The padding size; defaults to 0
repeated uint32 kernel_size = ; // The kernel size
repeated uint32 stride = ; // The stride; defaults to 1
// Factor used to dilate the kernel, (implicitly) zero-filling the resulting holes. (Kernel dilation is sometimes referred to by its use in the algorithme à trous from Holschneider et al. 1987.)
repeated uint32 dilation = ; // The dilation; defaults to 1 // For 2D convolution only, the *_h and *_w versions may also be used to specify both spatial dimensions.
optional uint32 pad_h = [default = ]; // The padding height (2D only)
optional uint32 pad_w = [default = ]; // The padding width (2D only)
optional uint32 kernel_h = ; // The kernel height (2D only)
optional uint32 kernel_w = ; // The kernel width (2D only)
optional uint32 stride_h = ; // The stride height (2D only)
optional uint32 stride_w = ; // The stride width (2D only) optional uint32 group = [default = ]; // The group size for group conv optional FillerParameter weight_filler = ; // The filler for the weight
optional FillerParameter bias_filler = ; // The filler for the bias
enum Engine {
DEFAULT = ;
CAFFE = ;
CUDNN = ;
}
optional Engine engine = [default = DEFAULT]; // The axis to interpret as "channels" when performing convolution.
// Preceding dimensions are treated as independent inputs;
// succeeding dimensions are treated as "spatial".
// With (N, C, H, W) inputs, and axis == 1 (the default), we perform
// N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for
// groups g>1) filters across the spatial axes (H, W) of the input.
// With (N, C, D, H, W) inputs, and axis == 1, we perform
// N independent 3D convolutions, sliding (C/g)-channels
// filters across the spatial axes (D, H, W) of the input.
optional int32 axis = [default = ]; // Whether to force use of the general ND convolution, even if a specific
// implementation for blobs of the appropriate number of spatial dimensions
// is available. (Currently, there is only a 2D-specific convolution
// implementation; for input blobs with num_axes != 2, this option is
// ignored and the ND implementation will be used.)
optional bool force_nd_im2col = [default = false];
}

2. 卷积层相关参数

接下来,分别对卷积层的相关参数进行说明

(根据卷积层的定义,它的学习参数应该为filter的取值和bias的取值,其他的相关参数都为hyper-paramers,在定义模型时是要给出的)

lr_mult:学习率系数

放置在param{}中

该系数用来控制学习率,在进行训练过程中,该层参数以该系数乘solver.prototxt配置文件中的base_lr的值为学习率

即学习率=lr_mult*base_lr

如果该层在结构配置文件中有两个lr_mult,则第一个表示fitler的权值学习率系数,第二个表示偏执项的学习率系数(一般情况下,偏执项的学习率系数是权值学习率系数的两倍)

convolution_praram:卷积层的其他参数

放置在convoluytion_param{}中

该部分对卷积层的其他参数进行设置,有些参数为必须设置,有些参数为可选(因为可以直接使用默认值)

  • 必须设置的参数

  1. num_output:该卷积层的filter个数

  2. kernel_size:卷积层的filter的大小(直接用该参数时,是filter的长宽相等,2D情况时,也可以设置为不能,此时,利用kernel_h和kernel_w两个参数设定)
  • 其他可选的设置参数

  1. stride:filter的步长,默认值为1

  2. pad:是否对输入的image进行padding,默认值为0,即不填充(注意,进行padding可能会带来一些无用信息,输入image较小时,似乎不太合适)
  3. weight_filter:权值初始化方法,使用方法如下
    weight_filter{
          type:"xavier"  //这里的xavier是一冲初始化算法,也可以是“gaussian”;默认值为“constant”,即全部为0
    }
  4. bias_filter:偏执项初始化方法
    bias_filter{
          type:"xavier"  //这里的xavier是一冲初始化算法,也可以是“gaussian”;默认值为“constant”,即全部为0
    }
  5. bias_term:是否使用偏执项,默认值为Ture

caffe之(一)卷积层的更多相关文章

  1. caffe源码 卷积层

    通俗易懂理解卷积 图示理解神经网络的卷积 input: 3 * 5 * 5 (c * h * w) pading: 1 步长: 2 卷积核: 2 * 3 * 3 * 3 ( n * c * k * k ...

  2. caffe中全卷积层和全连接层训练参数如何确定

    今天来仔细讲一下卷基层和全连接层训练参数个数如何确定的问题.我们以Mnist为例,首先贴出网络配置文件: name: "LeNet" layer { name: "mni ...

  3. TensorFlow与caffe中卷积层feature map大小计算

    刚刚接触Tensorflow,由于是做图像处理,因此接触比较多的还是卷及神经网络,其中会涉及到在经过卷积层或者pooling层之后,图像Feature map的大小计算,之前一直以为是与caffe相同 ...

  4. caffe Python API 之卷积层(Convolution)

    1.Convolution层: 就是卷积层,是卷积神经网络(CNN)的核心层. 层类型:Convolution lr_mult: 学习率的系数,最终的学习率是这个数乘以solver.prototxt配 ...

  5. 【caffe】卷积层代码解析

    1.Forward_cpu conv_layer.cpp template <typename Dtype> void ConvolutionLayer<Dtype>::For ...

  6. caffe中卷积层和pooling层计算下一层的特征map的大小

    pool层,其中ceil是向上取整函数 卷积层:

  7. caffe之(二)pooling层

    在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层.卷积操作层.pooling层.非线性变换层.内积运算层.归一化层.损失计算层等:本篇主要 ...

  8. 卷积层和BN层融合

    常规的神经网络连接结构如下  当网络训练完成, 在推导的时候为了加速运算, 通常将卷积层和 batch-norm 层融合, 原理如下 \[ \begin{align*} y_{conv} & ...

  9. 『TensorFlow』卷积层、池化层详解

    一.前向计算和反向传播数学过程讲解

随机推荐

  1. Spring + JDK Timer Scheduler Example--reference

    http://www.mkyong.com/spring/spring-jdk-timer-scheduler-example/ In this example, you will use Sprin ...

  2. WEB网站常见受攻击方式及解决办法

    一个网站建立以后,如果不注意安全方面的问题,很容易被人攻击,下面就讨论一下几种漏洞情况和防止攻击的办法. 一.跨站脚本攻击(XSS) 跨站脚本攻击(XSS,Cross-site scripting)是 ...

  3. Java基础知识强化之IO流笔记37:FileReader/FileWriter(转换流的子类)复制文本文件案例

    1. 转换流的简化写法: 由于我们常见的操作都是使用本地默认编码,所以,不用指定编码.而转换流的名称有点长,所以,Java就提供了其子类供我们使用:FileReader / FileWriterOut ...

  4. hbuilder用自己的服务

    2016-03-10 以后写测试demo用Sublime3 http://docs.emmet.io/cheat-sheet/ 更多炫酷信息和emmet语法请参见: 视频demo 语法文档 2016- ...

  5. SQLServer获取最后插入的ID值SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY的比较

    IDENT_CURRENT 返回为任何会话和任何作用域中的特定表最后生成的标识值.IDENT_CURRENT 不受作用域和会话的限制,而受限于指定的表. @@IDENTITY 返回为当前会话的所有作用 ...

  6. JS操作CSS样式

    一.样式表(css) 使用样式表可以更好的显示WEB文档,也可以结合javascript从而实现很好的控制样式表. 样式(css)与内容(html): HTML是处理文档结构的,HTML可以实现如何把 ...

  7. SQL Server 阻止了对组件 'xp_cmdshell' 的 过程'sys.xp_cmdshell' 的访问

    sql server 2005: EXEC sp_configure N'show advanced options', N'1' RECONFIGURE WITH OVERRIDEEXEC sp_c ...

  8. Java 十六进制转十进制

    public static int hexToDecimal(String hex) { int decimalValue = 0; for (int i = 0; i < hex.length ...

  9. ios NSHashTable & NSMapTable

    在ios开发中大家用到更多的集合类可能是像NSSet或者NSDictionary,NSArray这样的.这里要介绍的是更少人使用的两个类,一个是NSMapTable,另一个是NSHashTable. ...

  10. oracle_11g 不同用户之间的数据迁移

    众所周知,IMP工具的FROMUSER和TOUSER参数可以实现将一个用户的的数据迁移到另外一个用户.同样的功能在IMPPDP工具中如何得以体现呢?答案就是:使用IMPPDP的REMAP_SCHEMA ...