版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。

Scale Layer是输入进行缩放和平移,常常出现在BatchNorm归一化后,Caffe中常用BatchNorm+Scale实现归一化操作(等同Pytorch中BatchNorm)

首先我们先看一下 ScaleParameter

message ScaleParameter {
// The first axis of bottom[0] (the first input Blob) along which to apply
// bottom[1] (the second input Blob). May be negative to index from the end
// (e.g., -1 for the last axis).
// 根据 bottom[0] 指定 bottom[1] 的形状
// For example, if bottom[0] is 4D with shape 100x3x40x60, the output
// top[0] will have the same shape, and bottom[1] may have any of the
// following shapes (for the given value of axis):
// (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
// (axis == 1 == -3) 3; 3x40; 3x40x60
// (axis == 2 == -2) 40; 40x60
// (axis == 3 == -1) 60
// Furthermore, bottom[1] may have the empty shape (regardless of the value of
// "axis") -- a scalar multiplier.
// 例如,如果 bottom[0] 的 shape 为 100x3x40x60,则 top[0] 输出相同的 shape;
// bottom[1] 可以包含上面 shapes 中的任一种(对于给定 axis 值).
// 而且,bottom[1] 可以是 empty shape 的,没有任何的 axis 值,只是一个标量的乘子.
optional int32 axis = 1 [default = 1];
  // (num_axes is ignored unless just one bottom is given and the scale is
// a learned parameter of the layer. Otherwise, num_axes is determined by the
// number of axes by the second bottom.)
// (忽略 num_axes 参数,除非只给定一个 bottom 及 scale 是网络层的一个学习到的参数.
// 否则,num_axes 是由第二个 bottom 的数量来决定的.)
// The number of axes of the input (bottom[0]) covered by the scale
// parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
// Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.
// bottom[0] 的 num_axes 是由 scale 参数覆盖的;
optional int32 num_axes = 2 [default = 1]; // (filler is ignored unless just one bottom is given and the scale is
// a learned parameter of the layer.)
// (忽略 filler 参数,除非只给定一个 bottom 及 scale 是网络层的一个学习到的参数.
// The initialization for the learned scale parameter.
// scale 参数学习的初始化
// Default is the unit (1) initialization, resulting in the ScaleLayer
// initially performing the identity operation.
// 默认是单位初始化,使 Scale 层初始进行单位操作.
optional FillerParameter filler = 3; // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but
// may be more efficient). Initialized with bias_filler (defaults to 0).
// 是否学习 bias,等价于 ScaleLayer+BiasLayer,只不过效率更高
// 采用 bias_filler 进行初始化. 默认为 0.
optional bool bias_term = 4 [default = false];
optional FillerParameter bias_filler = 5;

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47

Scale layer 在prototxt里面的书写:

layer {
name: "scale_conv1"
type: "Scale"
bottom: "conv1"
top: "conv1"
 scale_param {
bias_term: true

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

例如在MobileNet中:

layer {
name: "conv6_4/scale"
type: "Scale"
bottom: "conv6_4/bn"
top: "conv6_4/bn"
param {
lr_mult: 1
decay_mult: 0
}
param {
lr_mult: 1
decay_mult: 0
}
scale_param {
bias_term: true
}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
                                </div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-095d4a0b23.css" rel="stylesheet">
</div>
posted @
2019-09-24 17:47 
core! 
阅读(...) 
评论(...) 
编辑 
收藏

转caffe scale layer的更多相关文章

  1. Caffe中Layer注册机制

    Caffe内部维护一个注册表用于查找特定Layer对应的工厂函数(Layer Factory的设计用到了设计模式里的工厂模式).Caffe的Layer注册表是一组键值对(key, value)( La ...

  2. caffe自定义layer

    caffe自带layers: http://caffe.berkeleyvision.org/tutorial/layers.html Layers: Image Data - read raw im ...

  3. Caffe学习--Layer分析

    Caffe_Layer 1.基本数据结构 //Layer层主要的的参数 LayerParamter layer_param_; // protobuf内的layer参数 vector<share ...

  4. caffe rpn layer 中的 reshape layer

    Reshape层:(改变blob的形状,N,C,W,H) layer { name: "reshape" type: "Reshape" bottom: &qu ...

  5. caffe 学习(3)——Layer Catalogue

    layer是建模和计算的基本单元. caffe的目录包含各种state-of-the-art model的layers. 为了创建一个caffe model,我们需要定义模型架构在一个protocol ...

  6. caffe源码学习

    本文转载自:https://buptldy.github.io/2016/10/09/2016-10-09-Caffe_Code/ Caffe简介 Caffe作为一个优秀的深度学习框架网上已经有很多内 ...

  7. TensorRT加速 ——NVIDIA终端AI芯片加速用,可以直接利用caffe或TensorFlow生成的模型来predict(inference)

    官网:https://developer.nvidia.com/tensorrt 作用:NVIDIA TensorRT™ is a high-performance deep learning inf ...

  8. 深度学习工具caffe具体安装指南

    caffe安装指南-吐血整理 前言: 在一台系统环境较好的linux机器上能够非常easy的安装caffe,可是假设系统本身非常旧,又没有GPU的话.安装就太麻烦了,全部都得从头做起,本文档旨在尽可能 ...

  9. Caffe代码分析--crop_layer.cu

    因为要修改Caffe crop layer GPU部分的代码,现将自己对这部分GPU代码的理解总结一下,请大家多多指教! crop layer完成的功能(以matlab的方式表示):A(N,C,H,W ...

随机推荐

  1. Leetcode题解 - BFS部分题目代码+思路(896、690、111、559、993、102、103、127、433)

    和树有关的题目求深度 -> 可以利用层序遍历 -> 用到层序遍历就想到使用BFS 896. 单调数列 - 水题 class Solution: def isMonotonic(self, ...

  2. SpringBoot源码学习系列之@PropertySource不支持yaml读取原因

    然后,为什么@PropertySource注解默认不支持?可以简单跟一下源码 @PropertySource源码: 根据注释,默认使用DefaultPropertySourceFactory类作为资源 ...

  3. Web前端基础(14):jQuery基础(一)

    1. jQuery概述 1.1 为什么要使用jQuery 在用js写代码时,会遇到一些问题: window.onload 事件有事件覆盖的问题,因此只能写一个事件. 代码容错性差. 浏览器兼容性问题. ...

  4. Eclipse:批量将Java源代码文件的编码从GBK转为UTF-8

    很简单的几行代码,就可以批量将GBK格式的java文件转为UTF-8格式. 基本上所有文本文件的编码转换都可以采用这种方式. import java.io.File; import java.io.I ...

  5. git clone克隆项目太慢,或者直接导致克不下来的解决办法(转载请注明出处)

    从github下载项目下来,由于项目提交历史过多等各种原因导致文件太大,clone的时候非常的慢,或者直接出现 error: RPC failed; curl 18 transfer closed w ...

  6. 【JDBC】JDBC入门

    JDBC的入门 搭建开发环境 编写程序,在程序中加载数据库驱动 建立连接 创建用于向数据库发送SQL的Statement对象 从代表结果集的ResultSet中取出数据 断开与数据库的连接,并释放相关 ...

  7. raspberry-gpio-python(树莓派GPIO与Python编程)

    国外的设计接口设计得很棒,包括问题:读脏与防抖,还包括读这个数据提供了两种方式,一种是阻塞等待方式,还有一种是回调函数,前一种是通讯中常用的方式,后一种来自系统架构设计的整体性考虑.这种硬件接口设计的 ...

  8. gcc 4.9 编译安装 in Ubuntu 18.04(主要用于在无root权限下,进行更新系统 gcc 版本)

    gcc 4.9 编译安装教程,因为项目编译过程中,需要采用特定的gcc版本来进行编译,所以进行简要记录,进行备忘: 下载:curl -O -L https://mirrors.tuna.tsinghu ...

  9. [Linux] Nginx服务下统计网站的QPS

    单位时间的请求数就是QPS,那么在nginx服务的网站下,如果要统计QPS并且按从高到低排列,需要使用awk配合sort进行处理awk做的主要工作是把access每行日志按分隔符分开,然后循环每一行, ...

  10. 运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.

    运行springboot项目报错: *************************** APPLICATION FAILED TO START ************************** ...