在Caffe中平铺层的用途是什么?它似乎是一种重塑输入的形式,但是我想知道它到底是如何工作的,它可以应用在哪里?
源代码如下:
template <typename Dtype>
void TilingLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
TilingParameter tiling_param = this->layer_param_.tiling_param();
tile_dim_ = tiling_param.tile_dim();
tile_dim_sq_ = tile_dim_ * tile_dim_;
CHECK(tile_dim_) << "tile_dim must be specified.";
CHECK_GT(tile_dim_, 0) << "tile_dim must be positive.";
}
template <typename Dtype> void TilingLayer<Dtype>::Reshape(const
vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
CHECK_EQ(top.size(), 1);
input_channels_ = bottom[0]->channels();
input_height_ = bottom[0]->height();
input_width_ = bottom[0]->width();
output_channels_ = bottom[0]->channels() / tile_dim_sq_;
output_width_ = input_width_ * tile_dim_;
output_height_ = input_height_ * tile_dim_;
count_per_output_map_ = output_width_ * output_height_;
count_per_input_map_ = input_width_ * input_height_;
CHECK_EQ(0, input_channels_ % tile_dim_sq_)
<< "The number of input channels for tiling layer must be multiples "
<< "of the tile_dim."; top[0]->Reshape(bottom[0]->num(),
input_channels_ / tile_dim_sq_,
input_height_ * tile_dim_, input_width_ * tile_dim_); }发布于 2018-10-09 08:11:35
瓦层不同于瓦层,瓦层类似于重塑,而瓦层则类似于repmat。
===============编辑以添加切片图层的更多详细信息==========,如源代码https://github.com/BVLC/caffe/blob/master/src/caffe/layers/tile_layer.cpp中所示
Dtype* top_data = top[0]->mutable_cpu_data();
for (int i = 0; i < outer_dim_; ++i) {
for (int t = 0; t < tiles_; ++t) {
caffe_copy(inner_dim_, bottom_data, top_data);
top_data += inner_dim_;
}
bottom_data += inner_dim_;
}顶部的数据是输入数据的tiles_倍,当NC_H_W和tile_dim =8时,你会得到形状为N_C*(H*8)*(W*8)的blob,但对于平铺层,它会展平图层,例如你有N_C_H_W blob和tiling_dim=8,然后在平铺层之后,计数不会改变,但你会得到形状为N(C/64)*(H*8)*(W*8)的blob。
https://stackoverflow.com/questions/49937434
复制相似问题