How to change a drop in Caffe?

How to change the shape of an element N x C x H x W to N x 1 x (C*H) x W in Caffe?

I want to create a convolution layer whose scales are identical between channels.

One of the ways I came up with is to change the bottom frame of the N x C x H x W shape to N x 1 x (C*H) x W and put a convolution layer on it. But I just don’t know how to change the shape of the drop.

Please help me, thanks.

+7
deep-learning neural-network caffe reshape
source share
4 answers

As pointed out by whjxnyzh , you can use the "Reshape" layer. Caffe is quite flexible in how it allows you to define the output form.
See the reshap_param in caffe.proto` :

 // Specify the output dimensions. If some of the dimensions are set to 0, // the corresponding dimension from the bottom layer is used (unchanged). // Exactly one dimension may be set to -1, in which case its value is // inferred from the count of the bottom blob and the remaining dimensions. 

In your case, I think you will have a layer like this:

 layer { name: "my_reshape" type: "Reshape" bottom: "in" top: "reshaped_in" reshape_param { shape: {dim: 0 dim: 1 dim: -1 dim: 0 } } } 

See also caffe.help .

+7
source share
+2
source share

If I understand your final goal correctly, the Caffe convolution level can already perform several I / O convolutions with common / shared filters, such as:

 layer { name: "conv" type: "Convolution" bottom: "in1" bottom: "in2" bottom: "in3" top: "out1" top: "out2" top: "out3" convolution_param { num_output : 10 #the same 10 filters for all 3 inputs kernel_size: 3 } } 

Assuming you have all the threads separated (the slice layer can do this), and finally, you can combine them if you wish using the concat or eltwise layer.

This avoids the need to change the blob shape, convolution, and then reformat it, which can lead to inter-channel interference near the fields.

+2
source share

Not sure if this exactly matches your specifications, but Caffe has flattened layers. Blob goes from n * c * h * w to n * (chw) * 1 * 1.

See http://caffe.berkeleyvision.org/tutorial/layers.html

0
source share

All Articles