caffe之deconv
来源:互联网 发布:windows屏幕水印 编辑:程序博客网 时间:2024/06/05 16:50
卷积与反卷积的直观感受:
卷积: 反卷积:
特别说明,此处分析的反卷积主要针对 caffe中DeconvolutionLayer类别来说。
反向传播分析,参考博客:
https://grzegorzgwardys.wordpress.com/2016/04/22/8/
http://www.jefkine.com/general/2016/09/05/backpropagation-in-convolutional-neural-networks/
http://www.cnblogs.com/tornadomeet/p/3468450.html
http://blog.csdn.net/ck1798333105/article/details/52369122
http://www.cnblogs.com/pinard/p/6494810.html
反向传播结论: L层局部梯度
δ =L+1层局部梯度*(卷积)核的转秩
卷积核梯度 ▽W=输入*(卷积)本层局部梯度
卷积及反向传播
要想理解反卷积就要首先了解卷积的反向传播方式,因为他们之间有着千丝万缕的联系。
卷积之反向传播
见代码如下:
/////////////////////////////////////////////////////////////////////////// 正向传播/////////////////////////////////////////////////////////////////////////template <typename Dtype>void ConvolutionLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { const Dtype* weight = this->blobs_[0]->cpu_data(); for (int i = 0; i < bottom.size(); ++i) { const Dtype* bottom_data = bottom[i]->cpu_data(); Dtype* top_data = top[i]->mutable_cpu_data(); for (int n = 0; n < this->num_; ++n) { ///forward_cpu_gemm 实现卷积运算 // bottom_data*weight=top_data this->forward_cpu_gemm(bottom_data + n * this->bottom_dim_, weight, top_data + n * this->top_dim_); if (this->bias_term_) { const Dtype* bias = this->blobs_[1]->cpu_data(); this->forward_cpu_bias(top_data + n * this->top_dim_, bias); } } }}/***************************************************************** 反向传播******************************************************************/template <typename Dtype>void ConvolutionLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { const Dtype* weight = this->blobs_[0]->cpu_data(); Dtype* weight_diff = this->blobs_[0]->mutable_cpu_diff(); for (int i = 0; i < top.size(); ++i) { const Dtype* top_diff = top[i]->cpu_diff(); const Dtype* bottom_data = bottom[i]->cpu_data(); Dtype* bottom_diff = bottom[i]->mutable_cpu_diff(); // Bias gradient, if necessary. if (this->bias_term_ && this->param_propagate_down_[1]) { Dtype* bias_diff = this->blobs_[1]->mutable_cpu_diff(); for (int n = 0; n < this->num_; ++n) { // 计算▽b,偏移量梯度 this->backward_cpu_bias(bias_diff, top_diff + n * this->top_dim_); } } if (this->param_propagate_down_[0] || propagate_down[i]) { for (int n = 0; n < this->num_; ++n) { // gradient w.r.t. weight. Note that we will accumulate diffs. if (this->param_propagate_down_[0]) { this->weight_cpu_gemm(bottom_data + n * this->bottom_dim_, //计算 ▽W ,权重梯度 top_diff + n * this->top_dim_, weight_diff); } // gradient w.r.t. bottom data, if necessary. if (propagate_down[i]) { //// 重点,backward_cpu_gemm 实现矩阵局部梯度域反向计算 //// top_diff*weight^T(转制)=bottom_diff 实质上还是卷积运算 this->backward_cpu_gemm(top_diff + n * this->top_dim_, weight, //计算局部梯度δ bottom_diff + n * this->bottom_dim_); } } } }}
从convlayer 与 deconvlayer 对比来看,实现的功能是互逆的。
特别是两者在前向运算与后向计算局部梯度 相互对偶(使用同样的函数),而偏移量的计算方式一致。
阅读全文
0 0
- caffe之deconv
- Deconv
- 明白的deconv
- deconv--反褶积和多项式除法
- MATLAB中deconv函数用法
- Caffe中的工具之Caffe
- CNN之Caffe配置
- Caffe导读之layer
- CNN之Caffe配置
- Caffe之WindowDataLayer 解析
- caffe 之 protobuf
- 深度学习之caffe
- caffe 结构之Blob
- Caffe之Classification
- CAFFE-probuffer之二
- CAFFE-probuffer之三
- caffe之训练数据格式
- Caffe研究之blob
- servletRequestAndResponse
- Vue.js学习和第一个实例
- Google算法题:不同的子序列出现目标串的次数
- 使用 global key 一键启动应用程序
- 【2017年中总结】春宵一刻值千金
- caffe之deconv
- 直通bat算法课程优惠码(优惠10元)
- 301. Remove Invalid Parentheses 我的没ac
- Q137:PBRT-V3,各种采样(Sampling)之间的逻辑
- API VS SPI
- Spring的jdbcTemplate使用方法
- Hadoop YARN中内存和CPU两种资源的调度和隔离
- php7环境下安装php-devel
- 基于面向对象的编程的优势与劣势