最近看到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. mysql 主从 Last_IO_Errno错误代码说明

    Last_IO_Errno错误代码说明:  1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件 ...

  2. スワコゥのパーフェクトコード教室 ~ Style of suwakow's for OI Codes

    "みんなー! スワコゥのコード教室はじまるよー!" "大家!\(\color{grey}{\text{suwakow}}\)的码风教室开始了哟!" " ...

  3. pandas的dataframe与spark的dataframe

  4. 第二篇【Zabbix客户端的完整布署】

    关于Zabbix服务端布署请查看 1.上传zabbix安装包(源码包默认(Server和Agent是一起的)) [root@sms-v2 ~]# ll /root/ -rw-r--r-- root r ...

  5. C++ - extern “C”含义深层探索

    C和C++函数的相互引用原文地址:http://blog.csdn.net/wfwd/archive/2006/05/30/763734.aspx=========================== ...

  6. Win10上安装Awvs 12原版程序和完美破解补丁详细步骤

    环境: Win10 Awvs12安装包 链接:https://pan.baidu.com/s/1FIwYHIEKfLf4XAyeXfhVnA 提取码:6sa8 复制这段内容后打开百度网盘手机App,操 ...

  7. oracle条件参数中 IN函数中的值最大只能为1000个

    delete from dep where id in(1,2,3.....) 括号里面字段个数最大只能为1000个

  8. C++入门经典-例6.15-通过字符串函数连接两个字符数组

    1:代码如下 // 6.15.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using ...

  9. C++入门经典-例5.1-输出变量的指针

    1:代码如下: // 5.1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using ...

  10. 第3周Java编程总结

    1.打印输出所有的“水仙花数”,所谓“水仙花数”是指一个3位数,其中各位数字立方和等于该数本身.例如,153是一个“水仙花数”. 2. 编写Java程序,求13-23+33-43+…+973-983+ ...