understand about Slice layer in caffe

3,377 views
Skip to first unread message

Farik John

unread,
Mar 14, 2016, 10:17:48 AM3/14/16
to Caffe Users
I can't figure out about the slice layer in caffe.
caffe is saying like below.
layer {
  name: "slicer_label"
  type: "Slice"
  bottom: "label"
  ## Example of label with a shape N x 3 x 1 x 1
  top: "label1"
  top: "label2"
  top: "label3"
  slice_param {
    axis: 1
    slice_point: 1
    slice_point: 2
  }
}
axis indicates the target axis; slice_point indicates indexes in the selected dimension (the number of indices must be equal to the number of top blobs minus one).
So, axis: 1 means N num axis? or 3 channel axis?
and what does slice_point mean exactly?

Jan

unread,
Mar 15, 2016, 4:23:34 AM3/15/16
to Caffe Users
Everything is zero-based, as it usually is in C/C++/Python. That means it refers to the "3" axis. This slice layer just separates the Nx3x1x1 (bottom) blob into three Nx1x1x1 (top) blobs.

The slice_point allows you to do even more complicated slices, for example you could just specify slice_point: 1 to slice the (same) bottom blob into only two top blobs, the first with shape Nx1x1x1 and the second with shape Nx2x1x1.

Jan

Farik John

unread,
Mar 15, 2016, 10:06:14 AM3/15/16
to Caffe Users
Thanks Jan for you obvious explaination.

ngc...@gmail.com

unread,
Apr 3, 2017, 11:26:09 PM4/3/17
to Caffe Users
Hi,

In this case, for multitask learning, if I use an ImageData layer, do I specify my source text file like this:

filename  label1 label2  label3
Message has been deleted

ngc...@gmail.com

unread,
Apr 4, 2017, 4:52:21 AM4/4/17
to Caffe Users
How do I specify the source text file if I want to have labels for multi tasks?
I write like this:
image1.jpg 0 1 0
image2.jpg 1 1 0
....
and got the error below.


I0404 16:10:18.711613 15973 net.cpp:67] Creating Layer data
I0404 16:10:18.711624 15973 net.cpp:356] data -> data
I0404 16:10:18.711639 15973 net.cpp:356] data -> label
I0404 16:10:18.711653 15973 net.cpp:96] Setting up data
I0404 16:10:18.711668 15973 image_data_layer.cpp:31] Opening file examples/mtask/train-mtask.txt
I0404 16:10:18.711720 15973 image_data_layer.cpp:48] A total of 60 images.
I0404 16:10:18.713490 15973 image_data_layer.cpp:78] output data size: 30,3,227,227
I0404 16:10:18.713510 15973 base_data_layer.cpp:36] Loading mean file fromdata/ilsvrc12/imagenet_mean.binaryproto
I0404 16:10:18.716722 15973 net.cpp:103] Top shape: 30 3 227 227 (4637610)
I0404 16:10:18.716749 15973 net.cpp:103] Top shape: 30 1 1 1 (30)
I0404 16:10:18.716763 15973 net.cpp:67] Creating Layer slice0
I0404 16:10:18.716768 15973 net.cpp:394] slice0 <- label
I0404 16:10:18.716780 15973 net.cpp:356] slice0 -> label1
I0404 16:10:18.716790 15973 net.cpp:356] slice0 -> label2
I0404 16:10:18.716801 15973 net.cpp:356] slice0 -> label3
I0404 16:10:18.716811 15973 net.cpp:96] Setting up slice0
F0404 16:10:18.716831 15973 slice_layer.cpp:36] Check failed: top->size() <= channels_ (3 vs. 1)
*** Check failure stack trace: ***
    @     0x7fbf2ecaddaa  (unknown)
E0404 16:10:18.718168 15981 io.cpp:77] Could not open or find file 1

MOHANA LAHARI Tanguturi

unread,
Jun 6, 2017, 12:06:18 AM6/6/17
to Caffe Users
Could please tell me what are the changes you made in image_data_layer.cpp for multilabeling?????
Reply all
Reply to author
Forward
0 new messages