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

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

首先我们先看一下 ScaleParameter

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

    • 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里面的书写:

  1. layer {
  2. name: "scale_conv1"
  3. type: "Scale"
  4. bottom: "conv1"
  5. top: "conv1"
  6.  scale_param {
  7.     bias_term: true
  8. }

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

例如在MobileNet中:

  1. layer {
  2. name: "conv6_4/scale"
  3. type: "Scale"
  4. bottom: "conv6_4/bn"
  5. top: "conv6_4/bn"
  6. param {
  7. lr_mult: 1
  8. decay_mult: 0
  9. }
  10. param {
  11. lr_mult: 1
  12. decay_mult: 0
  13. }
  14. scale_param {
  15. bias_term: true
  16. }
  17. }
  18.  
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
  1. </div>
  2. <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-095d4a0b23.css" rel="stylesheet">
  3. </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. 数组类的创建——StaticArray.h

    创建好的基于顺序存储结构的线性表存在两个方面的问题:1)功能上的问题:数组操作符的重载带来的问题,有可能线性表被无用为数组了,线性表被当做数组来使用了.2)效率方面的问题 本篇博客就要解决功能上的问题 ...

  2. 信号处理函数陷阱:调用malloc导致死锁[转]

    概览 因malloc是加锁的,上网了解的相关信息,额外了解到信号处理规范使用,mark 正文 在执行malloc的过程中,跳转到了信号处理函数中.而信号处理函数在调用某个系统api时,内部又调用了ma ...

  3. 面试知识点 html css(经常更新)

    1.HTML5语义化 什么是语义化 用合理.正确的标签来展示内容,比如h1~h6定义标题 好处 易于用户阅读,样式丢失的时候能让页面呈现清晰的结构. 有利于SEO,搜索引擎根据标签来确定上下文和各个关 ...

  4. vue 客户端渲染和服务端渲染

    参考链接 https://www.cnblogs.com/tiedaweishao/p/6644267.html

  5. mybatis无效比较:invalid comparison:java.util.data and java.lang.string

    原因: 时间与空字符串比较是无效的,如果拿传入的时间类型参数与空字符串''进行对比则会引发invalid comparison:java.util.data and java.lang.string异 ...

  6. JavaWeb入门——背景知识

    JavaWeb入门——背景知识 摘要:本文主要介绍了Web服务器的相关知识. 概念 什么是JavaWeb JavaWeb,是用Java技术来解决相关Web互联网领域的技术的总称.Web包括:Web服务 ...

  7. zabbix snmp监控与主被模式

    1.snmp基础介绍 snmp全称是简单网络管理协议 为什么要用? 路由器交换机无法安装agent程序,但是都提供snmp服务端, 我们可以使用zabbix的snmp方式监控snmp服务端的数据 2. ...

  8. Java面试基础 -- Linux篇

    0.日常命令 cd 目录路径: 跳转到指定目录 mkdir 目录名称:新增目录 pwd: 获取当前路径 su: 切换用户 ll: 查看当前目录侠的文件和目录 rm -rf 目录: 递归删除指定目录下的 ...

  9. echarts 柱状图

    效果: 图一:Y轴显示百分比  柱状图定点显示数量个数 图二:x轴  相同日期对应的每个柱子显示不同类型的数量 代码: 容器: <div id="badQuaAnalyze" ...

  10. localStorage本地存储技术

    localStorage 本地存储技术 本地存储技术,“不是永久的永久存储” 特点: 将数据存储到浏览器当中 存储的数据都是以字符串的形式存储的 和传统的数据库相比: 优点: 操作简单,容易学习 数据 ...