Issue with datum.label dimension/type

189 views
Skip to first unread message

Daniel Salles Chevitarese

unread,
Jan 21, 2016, 2:14:42 PM1/21/16
to Caffe Users

Hi all,

to better understand caffe, I got an interesting example online training the iris database: https://github.com/Franck-Dernoncourt/caffe_demos. Summarizing, the model has 150 examples of three kinds of flowers (50 each) that is represented by 4 inputs floats and 1 output (0, 1, 2), where each output is codified using One-of-N, so the new classes are [1,0,0], [0,1,0] and [0,0,1].

However, instead of using the HDF5 format, I would like to use the LMDB one. In order to do so, I modified the script (attached) to create the LMDB files, but I faced a problem with caffe.datum that one supports int or long as label (???). How caffe codify the output? In our MNIST example, how caffe manage the label, since it varies from 0 to 9? Does anyone know how to modify my script to make it run?

Thanks.

iris_solver_lmdb.prototxt
iris_train_test_lmdb.prototxt
train_lmdb.py

Jan C Peters

unread,
Jan 25, 2016, 8:04:20 AM1/25/16
to Caffe Users
Actually the one-hot coding of classes is usually done by caffe internally, depending on the loss layer (SoftmaxWithLoss does it, CrossEntropyLoss does not do it I think). So for three classes just use the labels 0, 1 and 2.

The problem is that for the one-hot representation you are in a setting that is technically a multilabel-classification setting, since you have more than one label per sample (actually 3). This settings is not really well supported by the LMDB and LevelDB backends afaik. I have read that it could be done, but you have to jump through some hoops to get it there. The easiest solution would be to stick with HDF5 (which I would recommend anyway), or use SoftmaxWithLoss and the simple integer class specifiers.

Jan

Daniel Salles Chevitarese

unread,
Jan 26, 2016, 8:37:49 AM1/26/16
to Jan C Peters, Caffe Users
Hi Jan,

sorry for the late reply. In the end, I created 2 LMDBs: one for data and the other for labels and it worked well. My new network file is attached.

--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/x3QwPvJHUiQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/e031a261-51ff-4ce2-ad1e-596665a5db1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Daniel Salles Chevitarese
net_multidim.prototxt
Reply all
Reply to author
Forward
0 new messages