How to split a Blob along channels in Caffe

倖福魔咒の 提交于 2020-01-01 09:57:14

问题


I would like to split the Blob channels in Caffe, so that I can split one Blob of (N, c, w, h) into two output Blobs of size (N, c/2, w, h).

What I have described above is very general, what I want to do actually is to separate a two-channel input image into two different images. One goes to a convolutional layer and the other goes to a pooling layer. Finally, I concatenate the outputs.

So I am wondering if a Caffe layer that allows the user to do such thing exists, and how to define it in the prototxt file.


回答1:


Yes, the Slice layer is for that purpose. From the Layer Catalogue:

The Slice layer is a utility layer that slices an input layer to multiple output layers along a given dimension (currently num or channel only) with given slice indices.

To slice a Blob of size N x 2 x H x W into two Blobs of size N x 1 x H x W, you have to slice axis: 1 (along channels) at slice_point: 1 (after the first channel):

layer {
  name: "slice-conv-pool"
  type: "Slice"
  bottom: "data"
  top: "conv1"
  top: "pool1"
  slice_param {
    axis: 1
    slice_point: 1
  }
}


来源:https://stackoverflow.com/questions/41228315/how-to-split-a-blob-along-channels-in-caffe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!