Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

padding aware im2col and col2im functions #128

Merged
merged 8 commits into from
Feb 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 8 additions & 40 deletions examples/imagenet.prototxt
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,14 @@ layers {
bottom: "pool1"
top: "norm1"
}
layers {
layer {
name: "pad2"
type: "padding"
pad: 2
}
bottom: "norm1"
top: "pad2"
}
layers {
layer {
name: "conv2"
type: "conv"
num_output: 256
group: 2
kernelsize: 5
pad: 2
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -94,7 +86,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad2"
bottom: "norm1"
top: "conv2"
}
layers {
Expand Down Expand Up @@ -127,21 +119,13 @@ layers {
bottom: "pool2"
top: "norm2"
}
layers {
layer {
name: "pad3"
type: "padding"
pad: 1
}
bottom: "norm2"
top: "pad3"
}
layers {
layer {
name: "conv3"
type: "conv"
num_output: 384
kernelsize: 3
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -155,7 +139,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad3"
bottom: "norm2"
top: "conv3"
}
layers {
Expand All @@ -166,22 +150,14 @@ layers {
bottom: "conv3"
top: "conv3"
}
layers {
layer {
name: "pad4"
type: "padding"
pad: 1
}
bottom: "conv3"
top: "pad4"
}
layers {
layer {
name: "conv4"
type: "conv"
num_output: 384
group: 2
kernelsize: 3
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -195,7 +171,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad4"
bottom: "conv3"
top: "conv4"
}
layers {
Expand All @@ -206,22 +182,14 @@ layers {
bottom: "conv4"
top: "conv4"
}
layers {
layer {
name: "pad5"
type: "padding"
pad: 1
}
bottom: "conv4"
top: "pad5"
}
layers {
layer {
name: "conv5"
type: "conv"
num_output: 256
group: 2
kernelsize: 3
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -235,7 +203,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad5"
bottom: "conv4"
top: "conv5"
}
layers {
Expand Down
48 changes: 8 additions & 40 deletions examples/imagenet_deploy.prototxt
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,14 @@ layers {
bottom: "pool1"
top: "norm1"
}
layers {
layer {
name: "pad2"
type: "padding"
pad: 2
}
bottom: "norm1"
top: "pad2"
}
layers {
layer {
name: "conv2"
type: "conv"
num_output: 256
group: 2
kernelsize: 5
pad: 2
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -85,7 +77,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad2"
bottom: "norm1"
top: "conv2"
}
layers {
Expand Down Expand Up @@ -118,21 +110,13 @@ layers {
bottom: "pool2"
top: "norm2"
}
layers {
layer {
name: "pad3"
type: "padding"
pad: 1
}
bottom: "norm2"
top: "pad3"
}
layers {
layer {
name: "conv3"
type: "conv"
num_output: 384
kernelsize: 3
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -146,7 +130,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad3"
bottom: "norm2"
top: "conv3"
}
layers {
Expand All @@ -157,22 +141,14 @@ layers {
bottom: "conv3"
top: "conv3"
}
layers {
layer {
name: "pad4"
type: "padding"
pad: 1
}
bottom: "conv3"
top: "pad4"
}
layers {
layer {
name: "conv4"
type: "conv"
num_output: 384
group: 2
kernelsize: 3
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -186,7 +162,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad4"
bottom: "conv3"
top: "conv4"
}
layers {
Expand All @@ -197,22 +173,14 @@ layers {
bottom: "conv4"
top: "conv4"
}
layers {
layer {
name: "pad5"
type: "padding"
pad: 1
}
bottom: "conv4"
top: "pad5"
}
layers {
layer {
name: "conv5"
type: "conv"
num_output: 256
group: 2
kernelsize: 3
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
Expand All @@ -226,7 +194,7 @@ layers {
weight_decay: 1.
weight_decay: 0.
}
bottom: "pad5"
bottom: "conv4"
top: "conv5"
}
layers {
Expand Down
48 changes: 8 additions & 40 deletions examples/imagenet_val.prototxt
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,16 @@ layers {
bottom: "pool1"
top: "norm1"
}
layers {
layer {
name: "pad2"
type: "padding"
pad: 2
}
bottom: "norm1"
top: "pad2"
}
layers {
layer {
name: "conv2"
type: "conv"
num_output: 256
group: 2
kernelsize: 5
pad: 2
}
bottom: "pad2"
bottom: "norm1"
top: "conv2"
}
layers {
Expand Down Expand Up @@ -103,23 +95,15 @@ layers {
bottom: "pool2"
top: "norm2"
}
layers {
layer {
name: "pad3"
type: "padding"
pad: 1
}
bottom: "norm2"
top: "pad3"
}
layers {
layer {
name: "conv3"
type: "conv"
num_output: 384
kernelsize: 3
pad: 1
}
bottom: "pad3"
bottom: "norm2"
top: "conv3"
}
layers {
Expand All @@ -130,24 +114,16 @@ layers {
bottom: "conv3"
top: "conv3"
}
layers {
layer {
name: "pad4"
type: "padding"
pad: 1
}
bottom: "conv3"
top: "pad4"
}
layers {
layer {
name: "conv4"
type: "conv"
num_output: 384
group: 2
kernelsize: 3
pad: 1
}
bottom: "pad4"
bottom: "conv3"
top: "conv4"
}
layers {
Expand All @@ -158,24 +134,16 @@ layers {
bottom: "conv4"
top: "conv4"
}
layers {
layer {
name: "pad5"
type: "padding"
pad: 1
}
bottom: "conv4"
top: "pad5"
}
layers {
layer {
name: "conv5"
type: "conv"
num_output: 256
group: 2
kernelsize: 3
pad: 1
}
bottom: "pad5"
bottom: "conv4"
top: "conv5"
}
layers {
Expand Down
8 changes: 4 additions & 4 deletions include/caffe/util/im2col.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ namespace caffe {

template <typename Dtype>
void im2col_cpu(const Dtype* data_im, const int channels,
const int height, const int width, const int ksize, const int stride,
const int height, const int width, const int ksize, const int pad, const int stride,
Dtype* data_col);

template <typename Dtype>
void col2im_cpu(const Dtype* data_col, const int channels,
const int height, const int width, const int psize, const int stride,
const int height, const int width, const int psize, const int pad, const int stride,
Dtype* data_im);

template <typename Dtype>
void im2col_gpu(const Dtype* data_im, const int channels,
const int height, const int width, const int ksize, const int stride,
const int height, const int width, const int ksize, const int pad, const int stride,
Dtype* data_col);

template <typename Dtype>
void col2im_gpu(const Dtype* data_col, const int channels,
const int height, const int width, const int psize, const int stride,
const int height, const int width, const int psize, const int pad, const int stride,
Dtype* data_im);

} // namespace caffe
Expand Down
Loading