Skip to content

Commit

Permalink
enable dilated deconvolution
Browse files Browse the repository at this point in the history
Since the underlying routines are shared, we need only upgrade
compute_output_shape.
  • Loading branch information
longjon committed Dec 28, 2015
1 parent 0e99de0 commit 24ebd2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/caffe/layers/base_conv_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ void BaseConvolutionLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
for (int i = 0; i < num_spatial_axes_; ++i) {
dilation_data[i] = (num_dilation_dims == 0) ? kDefaultDilation :
conv_param.dilation((num_dilation_dims == 1) ? 0 : i);
if (reverse_dimensions()) {
CHECK_EQ(dilation_data[i], 1) << "Deconvolution doesn't support dilation";
}
}
// Special case: im2col is the identity for 1x1 convolution with stride 1
// and no padding, so flag for skipping the buffer and transformation.
Expand Down
4 changes: 3 additions & 1 deletion src/caffe/layers/deconv_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ void DeconvolutionLayer<Dtype>::compute_output_shape() {
const int* kernel_shape_data = this->kernel_shape_.cpu_data();
const int* stride_data = this->stride_.cpu_data();
const int* pad_data = this->pad_.cpu_data();
const int* dilation_data = this->dilation_.cpu_data();
this->output_shape_.clear();
for (int i = 0; i < this->num_spatial_axes_; ++i) {
// i + 1 to skip channel axis
const int input_dim = this->input_shape(i + 1);
const int kernel_extent = dilation_data[i] * (kernel_shape_data[i] - 1) + 1;
const int output_dim = stride_data[i] * (input_dim - 1)
+ kernel_shape_data[i] - 2 * pad_data[i];
+ kernel_extent - 2 * pad_data[i];
this->output_shape_.push_back(output_dim);
}
}
Expand Down

0 comments on commit 24ebd2d

Please sign in to comment.