Is there a layer in Caffe that can get an arbitrary sub block in a blob?
Asked
Active
Viewed 188 times
1 Answers
1
AFAIK there is not a completely general slicing layer in caffe.
If you want to extract sub-blocks that are specific channels of a blob, you can use "Slice"
layer.
Depending on your requirements, you might find "Crop"
layer sufficient for your needs.
If you need more flexible access to sub-blocks, you might want to consider using a "Python"
layer.
An example using "Crop"
layer
As you pointed out "Crop"
layer expects two "bottom"s but since the second one is only used for reference shape, you can produce it using "DummyData"
layer.
Suppose you want to select x[:,:,3:20,5:40]
, this is a 17x35 crop
layer {
name: "ref_shape_17x35"
type: "DummyData"
top: "ref_shape_17x35"
dummy_data_param { shape { dim: 1 dim: 1 dim: 17 dim: 35 } }
}
layer {
name: "crop_x"
type: "Crop"
bottom: "x"
bottom: "ref_shape_17x35"
top: "crop_x"
crop_param {
axis: 2 # do not crop the first two dimensions
offset: 3
offset: 5
}
}
I did not try it myself, but it should work (let me know if it doesn't).

Shai
- 111,146
- 38
- 238
- 371