首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Caffe中平铺图层的目的是什么?

在Caffe中平铺图层的目的是什么?
EN

Stack Overflow用户
提问于 2018-04-20 16:35:08
回答 2查看 955关注 0票数 1

在Caffe中平铺层的用途是什么?它似乎是一种重塑输入的形式,但是我想知道它到底是如何工作的,它可以应用在哪里?

源代码如下:

代码语言:javascript
复制
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_); }
EN

回答 2

Stack Overflow用户

发布于 2018-10-09 08:11:35

瓦层不同于瓦层,瓦层类似于重塑,而瓦层则类似于repmat。

===============编辑以添加切片图层的更多详细信息==========,如源代码https://github.com/BVLC/caffe/blob/master/src/caffe/layers/tile_layer.cpp中所示

代码语言:javascript
复制
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。

票数 2
EN

Stack Overflow用户

发布于 2018-04-22 13:23:00

caffe中的"Tile"层实现了与numpy的tile或Matlab的repmat函数类似的操作:它沿指定的维数复制数组的内容。

例如,假设你有一个2D“注意力”(或“显着性”)图,你想根据这些权重对特征进行加权:给"salinet“区域更多的权重,给非”显着性“区域更少的权重。实现这一点的一种方法是将3D特征图乘以2D显着性图(按元素)。为此,您需要沿着通道维度(从2D到3D)对显着性贴图进行"Tile",然后应用"Eltwise"层。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49937434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档