最近看到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. AntisymmetricRNN: A Dynamical System View on Recurrent Neural Networks(解析)

    原文链接:https://arxiv.org/abs/1902.09689 发表在:ICLR 2019 ------------------------------------------------ ...

  2. ecshop新建增加独立页面的方法

    ecshop是通过php文件来指向dwt文件的,比如index.php是程序文件,那么其模板文件就是index.dwt 那么如果新建一个php文件来单独做其他作用呢?其实很简单 第一步: 将index ...

  3. 谈谈对MVC的认识?

    核心思想是:视图和用户交互通过事件导致控制器改变 控制器改变导致模型改变 或者控制器同时改变两者 模型改变 导致视图改变 或者视图改变 潜在的从模型里面获得参数 来改变自己.他的好处是可以将界面和业务 ...

  4. 亲爱的SAP从业者们,烦请做个SAP知识学习种类的小调查

    "世上再也没有比时钟更加冷漠的东西了:在您出生的那一刻,在您尽情地摘取青春幻梦的花朵的时刻,它都是同样分秒不差地滴答着." -- 高尔基 2019年马上又要离我们而去了,从2018 ...

  5. 阿里域名 ssl tomcat

    1.首先注册一个域名 2.添加一个信息模板(域名服务里边) 3.域名解析(默认解析127.0.0.1)  可以ping 域名试下看是否解析了(阿里有参考视频) 4.ssl 证书   免费版,网上有教程 ...

  6. 29.Jwt集成(3):token设置过期时间、异常判断

    token设置过期时间 package main import ( "fmt" "github.com/dgrijalva/jwt-go" "io/i ...

  7. MongoDB学习笔记之文档

    #向集合中插入文档有两种方式(insert.save) db.col.insert({title: 'MongoDB 教程', description: 'MongoDB 是一个 Nosql 数据库' ...

  8. qt5-自定义类

    创建一个自定义按钮类: 右击工程目录--->--->--->---> ---> --->

  9. 文件操作:fseek()

    int fseek(FILE *stream, long offset, int fromwhere); fseek 用于二进制方式打开的文件,移动文件读写指针位置.   int fseek( FIL ...

  10. sql 建立索引之前计算区分度

    select cutomer_id,title,content from product_comment where audit_status=1 and product_id=1 and produ ...