caffe中的Slice层,对hdf5读取的多标签数据进行切片,对于分割数据,图片数据量进行分割 caffe中的Slice层

caffe中的Slice层

Slice layer 的作用是将bottom按照需要分解成多个tops。(与split layer的不一样在于spliit的作用是将bottom复制多份,输出到tops) 
首先我们先看一下slice layer 在prototxt里面的书写


  
  
  1. layer {
  2. name: "slice"
  3. type: "Slice"
  4. bottom: "input"
  5. top: "output1"
  6. top: "output2"
  7. top: "output3"
  8. top: "output4"
  9. slice_param {
  10. axis: 1
  11. slice_point: 1
  12. slice_point: 3
  13. slice_point: 4
  14. }
  15. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

这里假设input的维度是N*5*H*W,tops输出的维度分别为N*1*H*W N*2*H*W N*1*H*W N*1*H*W 。 
这里需要注意的是,如果有slice_point,slice_point的个数一定要等于top的个数减一。 
axis表示要进行分解的维度。 
slice_point的作用是
将axis按照slic_point 进行分解。 
slice_point没有设置的时候则对axis进行均匀分解。


  
  
  1. message SliceParameter {
  2. // 下面两个指定沿哪个维度进行拆分,默认拆分channels通道
  3. optional int32 axis = 3[ default= 1];
  4. optional uint32 slice_dim = 1[ default= 1];
  5. // 指定拆分点
  6. repeated uint32 slice_point = 2;
  7. }
现在我们就要把之前concat合并的数据按照原样拆分:


   
   
  1. layer {
  2. name: "data_each"
  3. type: "Slice"
  4. bottom: "data_all"
  5. top: "data_classfier"
  6. top: "data_boundingbox"
  7. top: "data_facialpoints"
  8. slice_param {
  9. axis: 0
  10. slice_point: 100
  11. slice_point: 150
  12. }
  13. }

其中slice_point的个数必须等于top的个数减一。

输入的data_all维度为 250×3×24×24250×3×24×24

猜你喜欢

转载自blog.csdn.net/m0_37192554/article/details/86687007
今日推荐