caffe跑densenet的错误:Message type "caffe.PoolingParameter" has no field named "ceil_mode".【转自CSDN】
最近看了densenet这篇论文,论文作者给了基于caffe的源码,自己在电脑上跑了下,但是出现了Message type “caffe.PoolingParameter” has no field named “ceil_mode”.的错误,现将解决办法记载如下。主要是参考
(https://github.com/BVLC/caffe/pull/3057/files)。错误原因:由于caffe的版本的原因,现用的caffe的源码中的pooling层没有ceil_mode
这个函数,因此解决办法也是在现在的源码中网pooling层中添加这个参数以及相关的代码,并重新编译caffe即可。
1、修改pooling_layer.hpp文件PoolingLayer类
在pooling_layer.hpp中往PoolingLayer类中添加ceil_mode_这个参数,修改如下:
int height_, width_;
int pooled_height_, pooled_width_;
bool global_pooling_;
bool ceil_mode_; //添加的类成员变量
Blob<Dtype> rand_idx_;
Blob<int> max_idx_;
2、修改pooling_layer.cpp文件中相关参数
主要涉及到LayerSetUp函数和Reshape函数。LayerSetUp函数修改如下:
|| (!pool_param.has_stride_h() && !pool_param.has_stride_w()))
<< "Stride is stride OR stride_h and stride_w are required.";
global_pooling_ = pool_param.global_pooling();
ceil_mode_ = pool_param.ceil_mode(); //添加的代码,主要作用是从参数文件中获取ceil_mode_的参数数值。
if (global_pooling_) {
kernel_h_ = bottom[0]->height();
kernel_w_ = bottom[0]->width();
if (pad_h_ != 0 || pad_w_ != 0) {
CHECK(this->layer_param_.pooling_param().pool()
== PoolingParameter_PoolMethod_AVE
|| this->layer_param_.pooling_param().pool()
== PoolingParameter_PoolMethod_MAX)
<< "Padding implemented only for average and max pooling.";
CHECK_LT(pad_h_, kernel_h_);
CHECK_LT(pad_w_, kernel_w_);
.......
Reshape函数修改如下:
void PoolingLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
CHECK_EQ(4, bottom[0]->num_axes()) << "Input must have 4 axes, "
<< "corresponding to (num, channels, height, width)";
channels_ = bottom[0]->channels();
height_ = bottom[0]->height();
width_ = bottom[0]->width();
if (global_pooling_) {
kernel_h_ = bottom[0]->height();
kernel_w_ = bottom[0]->width();
}
- pooled_height_ = static_cast<int>(ceil(static_cast<float>(
- height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
- pooled_width_ = static_cast<int>(ceil(static_cast<float>(
- width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
+ // Specify the structure by ceil or floor mode
+
+ // 添加的代码-----------------------------------
+ if (ceil_mode_) {
+ pooled_height_ = static_cast<int>(ceil(static_cast<float>(
+ height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
+ pooled_width_ = static_cast<int>(ceil(static_cast<float>(
+ width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
+ } else {
+ pooled_height_ = static_cast<int>(floor(static_cast<float>(
+ height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
+ pooled_width_ = static_cast<int>(floor(static_cast<float>(
+ width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
+ }
+ // ------------------------------------------------------
+
if (pad_h_ || pad_w_) {
// If we have padding, ensure that the last pooling starts strictly
// inside the image (instead of at the padding); otherwise clip the last.
3、修改caffe.proto文件中PoolingParameter的定义
因为添加了pooling层的参数,因此需要修改caffe.proto文件中PoolingParameter中的定义,需要增加参数的声明。
// If global_pooling then it will pool over the size of the bottom by doing
// kernel_h = bottom->height and kernel_w = bottom->width
optional bool global_pooling = 12 [default = false];
+ // Specify floor/ceil mode
+ optional bool ceil_mode = 13 [default = true];// 为pooling层添加参数,这样可以在net.prototxt文件中为pooling层设置该参数,注意后面需要给其设置一个ID,同时设置一个默认值。
}
4、重新编译caffe
返回到caffe的根目录,使用make指令,即可。
make -j32 // 这里j后面的数字与电脑配置有关系,可以加速编译
注意:这个流程也是一般修改caffe的层的一般流程:1、主要修改相应层的hpp文件和cpp文件;2、如果有参数的添加或者减少,还需要修改caffe.proto文件对应层的参数即可(注意设置正确的ID以及默认值default);3、重新编译caffe
caffe跑densenet的错误:Message type "caffe.PoolingParameter" has no field named "ceil_mode".【转自CSDN】的更多相关文章
- win10编译caffe跑faster-rcnn(cuda7.5)
2017年1月13日 15:46:04 github.com/Microsoft/caffe这版现在不算是BVLC/caffe的官方windows分支:官方windows分支是一个叫willyd的家伙 ...
- 用caffe跑自己的数据,基于WINDOWS的caffe
本文详细介绍,如何用caffe跑自己的图像数据用于分类. 1 首先需要安装过程见 http://www.cnblogs.com/love6tao/p/5706830.html 同时依据上面教程,生成了 ...
- Windows下用Caffe跑自己的数据(遥感影像)
1 前言 Caffe对于像我这样的初学者来说是一款非常容易上手的深度学习框架.关于用Caffe跑自己的数据这样的博客已经非常多,感谢前辈们为我们提供的这么好的学习资源.这里我主要结合我所在的行业,说下 ...
- 【Caffe】Ubuntu16.04上配置安装caffe(Only CPU)
一.首先看看自己的系统,Ubuntu16.04,cpu,没有Nvidia,没有opencv 二.安装依赖包 安装protobuf,leveldb,snappy,OpenCV,hdf5, protobu ...
- Caffe学习笔记(三):Caffe数据是如何输入和输出的?
Caffe学习笔记(三):Caffe数据是如何输入和输出的? Caffe中的数据流以Blobs进行传输,在<Caffe学习笔记(一):Caffe架构及其模型解析>中已经对Blobs进行了简 ...
- CAFFE(三):Ubuntu下Caffe框架安装(仅仅Caffe框架安装)
步骤一. 从github上下载(克隆)安装包 1.1 在你要安装的路径下 clone 此处我直接安装到home目录,执行: ~$ cd ~ 2 :~$ git clone https://github ...
- 【ABAP系列】SAP 系统的消息类型分析 MESSAGE TYPE
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 系统的消息类型分析 ME ...
- 报错google.protobuf.text_format.ParseError: 166:8 : Message type "object_detection.protos.RandomHorizontalFlip" has no field named "i".解决方法
运行python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_ ...
- Caffe学习笔记1--Ubuntu 14.04 64bit caffe安装
本篇博客主要用于记录Ubuntu 14.04 64bit操作系统搭建caffe环境,目前针对的的是CPU版本: 1.安装依赖库 sudo apt-get install libprotobuf-dev ...
随机推荐
- POJ 2513 字典树+并查集+欧拉路径
Description: 给定一些木棒,木棒两端都涂上颜色,求是否能将木棒首尾相接,连成一条直线,要求不同木棒相接的一边必须是相同颜色的. 解题思路: 可以用图论中欧拉路的知识来解这道题,首先可以把木 ...
- jsonp 遍历文档
遍历文档 将html解析成一个Document后,就可以使用类似Dom的方法进行操作 File input = new File("/tmp/input.html"); Docum ...
- 51nod1482
题解: 发现是一个环,而环的题目有一些就是要转化成为链 首先找到一个最高点,中间断开 然后当作一条链来做 代码: #include<cstdio> #include<algorith ...
- Supervisor 配置过程
Supervisor 配置过程 (转自https://www.izixia.cn/2016/01/03/supervisor-pei-zhi-guo-cheng/) 1.安装 pip install ...
- 【DevExpress v17.2新功能预告】WinForms上的图表增强
在WinForms Charts v17.2中,我们新增了一些有用的功能,开发人员和最终用户可能都会喜欢. 基于标准的过滤 Chart控件已经支持一系列的过滤,但是在这个版本中,我们用FilterCr ...
- 教你如何打开android4.3和4.4中隐藏的AppOps
注:下面的方法在4.4.2更新后已失效! PreferenceActivity的switchToHeaderInner()函数中会调用isValidFragment函数来检查fragment是否合法. ...
- 【ssm】拦截器的原理及实现
一.背景: 走过了双11,我们又迎来了黑色星期五,刚过了黑五,双12又将到来.不管剁手的没有剁手的,估计这次都要剁手了!虽然作为程序猿的我,没有钱但是我们长眼睛了,我们关注到的是我们天猫.淘宝.支付宝 ...
- tensorflow读取训练数据方法
1. 预加载数据 Preloaded data # coding: utf-8 import tensorflow as tf # 设计Graph x1 = tf.constant([2, 3, 4] ...
- git中的分支管理
/*游戏或者运动才能让我短暂的忘记心痛,现如今感觉学习比游戏和运动还重要——曾少锋*/ 如果对git基础不太熟悉的可以参考:http://www.cnblogs.com/zengsf/p/750621 ...
- 辞树的QAQ水题(字符串统计,思维)
思路:统计一串字符有多少个'A',并分别统计出每个'A'前后有多少'Q'.然后让每个'A'前后的'Q'相乘并相加就能得出结果了. 注意:数据的类型,卡了int,要用long long. 还有就是在pc ...