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 ...
随机推荐
- forget word out a~2
1● an 不,非,无 2● amphi 两个,两种 3● ad 做,加强:
- 跟我一起学习ASP.NET 4.5 MVC4.0(一)
跟我一起学习ASP.NET 4.5 MVC4.0(一) 由于上面一个项目使用的是ASP.NET4.0 MVC3.0,在招人的时候发现很多人有听说过MVC,但是却是没用过,对MVC也只是一知半解,最 ...
- repeat 中的 continue
repeat a := -; then ShowMessage('') else begin Caption := ''; Continue;//不是立即 向上 返回 执行,要先向下 检查循环条件 是 ...
- python3 win10_x64 安装pcapy
稀里糊涂就装上了 大概记录一下都有什么. visual studio build tools 2015 下载地址: http://landinghub.visualstudio.com/visual- ...
- Javascript的堆和栈的简单理解
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...
- DevExpress v18.1新版亮点——ASP.NET篇(四)
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress ASP.NET v18.1 的新功能,快来下载试用新版本!点 ...
- Python读取ini配置文件的方式
python configparser模块 ConfigParser模块在python中用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(section ...
- View的事件拦截机制浅析
为什么要去分析view的事件 记得上周刚立的flag就是关于view的事件机制.那现在我来说说我对view的感受.关于view的事件,百度google一搜.一批又一批.但是能让人理解的少之又少.换句话 ...
- Intellij Idea2016.3 svn服务器拉取代码
1.修改idea的默认配置,取消SVN设置里的两个勾 2.拉取代码 3.输入SVN仓库的地址,然后checkout 即可
- iOS-----使用CoreLocation定位
使用CoreLocation定位 CoreLocation框架 (CoreLocation.framework)可用于定位设备当前经纬度, 通过该框架, 应用程序可通过附近的蜂窝基站\WIFI信号 或 ...