最近看到prototxt里面有silence这个层,好奇是干什么用的,而且看源码也出奇的简单:

#include <vector>

#include "caffe/layers/silence_layer.hpp"
#include "caffe/util/math_functions.hpp" namespace caffe { template <typename Dtype>
void SilenceLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
for (int i = ; i < bottom.size(); ++i) {
if (propagate_down[i]) {
caffe_set(bottom[i]->count(), Dtype(),
bottom[i]->mutable_cpu_diff());
}
}
} #ifdef CPU_ONLY
STUB_GPU(SilenceLayer);
#endif INSTANTIATE_CLASS(SilenceLayer);
REGISTER_LAYER_CLASS(Silence); } // namespace caffe

仅仅是在反向的时候将diff置为0.

查到如下相关解释,

The use of this layer is simply to avoid that the output of unused blobs is reported in the log. 
Being an output manager layer, it is obviously zero its gradient. For instance, let us assume we are using AlexNet and we change the bottom of the 'fc7' layer to 'pool5' instead of 'fc6'.
If we do not delete the 'fc6' blob declaration, this layer is not used anymore but its ouput will be printed in stderr:
it is considered as an output of the whole architecture.
If we want to keep 'fc6' for some reasons, but without showing its values, we can use the 'SilenceLayer'.

SilenceLayer的作用就是避免在log中打印并没有使用的blobs的信息。作为一个output的管理层,梯度是0。

举例就是,我们在使用AlexNet,我们将fc7的bottom由fc6改为pool5,而且我们不想删除fc6声明的话,此时fc6 layer虽然不会用到但是会输出错误信息到stderr,

我们此时可以通过使用slicence layer 来保存fc6声明,而且不会报错。

参考:

https://stackoverflow.com/questions/42172871/explain-silence-layer-in-caffe

https://blog.csdn.net/Soleilhao/article/details/71775643

caffe-----silence 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 scale layer

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u011681952/article/det ...

  5. caffe rpn layer 中的 reshape layer

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

  6. unity之Layer作用

    1.使用layer做分层渲染 创建两个物体 添加AB两个层级 分别为两个物体设置对应的层级 为摄像机选择渲染层次(在这个例子中,取消对B层的渲染) 在游戏界面中,将不会显示B层的游戏对象

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

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

  8. caffe杂

    一.finetune命令: mpirun /home/zhangsuosheng/caffe_mpi/build/tools/caffe train -solver solver.prototxt - ...

  9. caffe源码学习

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

随机推荐

  1. C++中的变量属性小结

    其实在C++中,一个变量除了数据类型以外,还有3种属性: (1)存储类别:C++中允许使用auto,static,register,extern 4种存储类别. (2)作用域:指在程序中可以使用该变量 ...

  2. 百度网盘,FTP上传异常、上传失败的解决办法

    若你的宽带上传上限速度为50KB,那么将百度网盘或FTP的上行速度调为50KB以下即可,就不会出现网络异常的情况了.

  3. windows server没有这台电脑图标

    rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0

  4. ios json数据null的处理

    此处我把json数据中的null转换成了@"",防止出现null程序崩掉,可以把下边宏代码复制到pch中,就可以在整个程序中引用了 #define DSStringValue(va ...

  5. visudo修改编辑器vim

    update-alternatives --config editor

  6. JAVA基础编程之打印99乘法表

    需求:打印9*9乘法表 技术考核: 1.for嵌套循环 代码: // 打印99乘法表 public static void print99Table() { System.out.println(&q ...

  7. head&tail命令

    1.tail tail命令用途是按照要求将指定的文件的最后部分输出到标准设备, 一般是终端,通俗来讲,就是把某个档案文件的最后几行显示到终端上, 如果该档案有更新,tail会自动刷新,确保你看到最新的 ...

  8. thinkPHP5.0.22初体验---路由,url访问

    “豪情卷起万重浪,吼吼哈哈-”一学thinkPHP才知道这是个国内研究的php web开发框架,瞬间自豪感如电流一般传遍全身 这就不多不说说 一.控制器 所谓MVC编程,无外乎函数(sometimes ...

  9. 如何下载Direct3D9Ex

    其实就是DirectX june_10月版本,下载链接如下 DirectX Software Development Kit 错误:安装报错“S1023" 若要解决此问题,必须在安装2010 ...

  10. 千万级别数据量mysql优化策略

    表结构优化 1.  使用独立表空间 独立表空间指的是innodb表的一种数据结构 独占表空间:  每一个表都将会生成以独立的文件方式来进行存储,每一个表都有一个.frm表描述文件,还有一个.ibd文件 ...