From e4650efaceeb2105ae1fd329a5a99b9fcf9522d3 Mon Sep 17 00:00:00 2001 From: Anna Petrovicheva Date: Thu, 21 Jul 2016 20:20:48 +0300 Subject: [PATCH] Fixed dilated convolutions --- modules/dnn/src/layers/convolution_layer.cpp | 1 - modules/dnn/src/layers/op_im2col.hpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp index 4934fba37..18da4f875 100644 --- a/modules/dnn/src/layers/convolution_layer.cpp +++ b/modules/dnn/src/layers/convolution_layer.cpp @@ -45,7 +45,6 @@ #include "convolution_layer.hpp" #include "op_im2col.hpp" #include "op_blas.hpp" -#include namespace cv { diff --git a/modules/dnn/src/layers/op_im2col.hpp b/modules/dnn/src/layers/op_im2col.hpp index d0458bad2..cafbf3600 100644 --- a/modules/dnn/src/layers/op_im2col.hpp +++ b/modules/dnn/src/layers/op_im2col.hpp @@ -108,8 +108,8 @@ public: { for (int w = 0; w < width_col; ++w) { - int h_pad = h * (stride_h + dilation_h) - pad_h + h_offset; - int w_pad = w * (stride_w + dilation_w) - pad_w + w_offset; + int h_pad = h * stride_h - pad_h + h_offset * dilation_h; + int w_pad = w * stride_w - pad_w + w_offset * dilation_w; if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width) data_col[(c * height_col + h) * width_col + w] = data_im[(c_im * height + h_pad) * width + w_pad]; @@ -146,8 +146,8 @@ void col2im_cpu(const Dtype* data_col, { for (int w = 0; w < width_col; ++w) { - int h_pad = h * (stride_h + dilation_h) - pad_h + h_offset; - int w_pad = w * (stride_w + dilation_w) - pad_w + w_offset; + int h_pad = h * stride_h - pad_h + h_offset * dilation_h; + int w_pad = w * stride_w - pad_w + w_offset * dilation_w; if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width) data_im[(c_im * height + h_pad) * width + w_pad] +=