Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split a Blob along channels in Caffe

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.

like image 357
user2987 Avatar asked Dec 19 '16 17:12

user2987


People also ask

What is a blob in Caffe model?

Mathematically, a blob is an N-dimensional array stored in a C-contiguous fashion. Caffe stores and communicates data using blobs. Blobs provide a unified memory interface holding data; e.g., batches of images, model parameters, and derivatives for optimization.

How does a caffe model work?

Caffe is released under the BSD 2-Clause license. Expressive architecture encourages application and innovation. Models and optimization are defined by configuration without hard-coding. Switch between CPU and GPU by setting a single flag to train on a GPU machine then deploy to commodity clusters or mobile devices.


1 Answers

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
  }
}
like image 192
hbaderts Avatar answered Nov 08 '22 10:11

hbaderts