问题
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
Slicelayer is a utility layer that slices an input layer to multiple output layers along a given dimension (currentlynumorchannelonly) 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