diff --git a/paddle/gserver/layers/ROIPoolLayer.cpp b/paddle/gserver/layers/ROIPoolLayer.cpp index 131fd7e52bbed64aad063b5b96eb5d7c03d99d2d..99cfddb0cf3337745a716a8c329713c18b99eda3 100644 --- a/paddle/gserver/layers/ROIPoolLayer.cpp +++ b/paddle/gserver/layers/ROIPoolLayer.cpp @@ -91,6 +91,8 @@ void ROIPoolLayer::forward(PassType passType) { real* argmaxData = maxIdxs_->getData(); for (size_t n = 0; n < numROIs; ++n) { + // the first five elememts of each RoI should be: + // batch_idx, roi_x_start, roi_y_start, roi_x_end, roi_y_end size_t roiBatchIdx = bottomROIs[0]; size_t roiStartW = round(bottomROIs[1] * spatialScale_); size_t roiStartH = round(bottomROIs[2] * spatialScale_); diff --git a/paddle/gserver/layers/ROIPoolLayer.h b/paddle/gserver/layers/ROIPoolLayer.h index 796467a5c86e6374a64a457c8a6d259b054952d0..4f07e49d6fd1eda9fa7bd46e4cec771a75f571be 100644 --- a/paddle/gserver/layers/ROIPoolLayer.h +++ b/paddle/gserver/layers/ROIPoolLayer.h @@ -41,6 +41,7 @@ protected: size_t pooledHeight_; real spatialScale_; + // Since there is no int matrix, use real maxtrix instead. MatrixPtr maxIdxs_; public: diff --git a/python/paddle/trainer/config_parser.py b/python/paddle/trainer/config_parser.py index f31252882e516e447619822df6c980f308276ae2..43d02bf70e74c3903d50a4a2177059f4f474045a 100644 --- a/python/paddle/trainer/config_parser.py +++ b/python/paddle/trainer/config_parser.py @@ -1971,13 +1971,14 @@ class DetectionOutputLayer(LayerBase): @config_layer('roi_pool') class ROIPoolLayer(LayerBase): - def __init__(self, name, inputs, pooled_width, pooled_height, - spatial_scale): + def __init__(self, name, inputs, pooled_width, pooled_height, spatial_scale, + num_channels, **xargs): super(ROIPoolLayer, self).__init__(name, 'roi_pool', 0, inputs) config_assert(len(inputs) == 2, 'ROIPoolLayer must have 2 inputs') self.config.inputs[0].roi_pool_conf.pooled_width = pooled_width self.config.inputs[0].roi_pool_conf.pooled_height = pooled_height self.config.inputs[0].roi_pool_conf.spatial_scale = spatial_scale + self.set_cnn_layer(name, pooled_height, pooled_width, num_channels) @config_layer('data') diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index 623ca047cd91314864c0dd2d96ae31eea8e059ea..617fbff948bf03098eca4a31f44d4ff05e73dbcf 100644 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -1345,7 +1345,8 @@ def roi_pool_layer(input, inputs=[input.name, rois.name], pooled_width=pooled_width, pooled_height=pooled_height, - spatial_scale=spatial_scale) + spatial_scale=spatial_scale, + num_channels=num_channels) return LayerOutput( name, LayerType.ROI_POOL_LAYER, parents=[input, rois], size=size)