Multi-label classification

834 views
Skip to first unread message

Hemanth Pidaparthy

unread,
Sep 23, 2015, 9:38:42 AM9/23/15
to Caffe Users
Hi, 

  I am new to caffe. I am trying to achieve multi-label classification of images into 14 classes on caffe. I saw this link on GitHub https://github.com/BVLC/caffe/pull/523 and it directed me to this code https://github.com/BVLC/caffe/tree/50a6ff0cc3a8525f310066c777fd6c4c9d8aa694. When I tried to build the code, I got error of missing cublas_v2.h. I resolved this and got an error of cublas_api.h. I realised that the master has many many more commits and hence, I am getting merge conflicts.

  Then after searching a bit more, I saw this link https://groups.google.com/forum/#!searchin/caffe-users/james$20guo/caffe-users/_NdX1tpHt5Y/4A7ln18nr3YJ. I also looked at the siamese example on caffe. I was unsure of how to save the image in HDF5 format and also how to generate the necessary listfile of all the labels. Is there a a version of the master commit that can be used? The master versions on GitHub are all giving build errors. Can someone please help me?

Jia Li

unread,
Sep 23, 2015, 9:48:04 AM9/23/15
to Caffe Users
Hi,

I think the PR is not finished (or aborted?).  Anyway, in order to do a multi label classification, you can pass to caffe a vector indicating the presence of each label (a vector, [1, 0, 0, 1] for class 1 and 4 present for example ).
- if use hdf5, you can directly store your label as matrix and pass it as input to your network
- if use lmdb, you need to store data and label seperately in 2 lmdb, then pass it to the network

Hope it help you.
Message has been deleted

Hemanth Pidaparthy

unread,
Sep 23, 2015, 12:33:34 PM9/23/15
to Caffe Users
Hi,

  There have been several builds have been pushed since the PR and hence I am getting build errors when trying to use that PR. I got an error of missing cublas_v2.h. Upon fixing this, I got an error of cublas_api.h missing. Upon fixing this, I got an error that many other files were missing. I was going in circles. 

  So I have the code working for single label classification in caffe. My data was stored in LMDB format. I tried to extend this to multi-label and I realised that convert_imageset does not support multiple labels. Is there a way to compress the data to hdf5? Also, is there an example of multi-label classification using hdf5 that I can refer to?

  I also looked at the siamese network example in caffe. In that they use two-label classification of MNIST data. I couldnt figure out the format for the listfile. I feel if I can get the format of listfile and the training data, I can easily extend that network to my application.

Cyprien Noel

unread,
Sep 25, 2015, 2:26:26 PM9/25/15
to Caffe Users
Is anybody working on this for multi-labels?

little solider Chang

unread,
Oct 4, 2015, 11:18:29 AM10/4/15
to Caffe Users
Thank you. But I still have one problem.

whether the shape of Input and label should be [100 1 96 96] and [100 30 1 1] respectively? where 100 represent the batch size and 30 is the dim of the label vector.

在 2015年9月23日星期三 UTC+1下午2:48:04,Jia Li写道:

Vimal Thilak

unread,
Oct 23, 2015, 9:43:04 PM10/23/15
to Caffe Users
Hi,

Did you get an answer to your question for the label shape? I'm interested in finding out the answer to this question as well.

Thanks!

robbyl...@gmail.com

unread,
Oct 26, 2015, 10:52:10 PM10/26/15
to Caffe Users
To the best of my understanding labels should be in the [100 30 1 1] format, if you have 30 different labels you want to provide the classifier. 
Look at the bottom of the parameters of the SigmoidCrossEntroyLoss:

This is what I am doing, and it seems like the network manage to get input and calculate the loss correctly. I am having problems converging the network, either because of Learning Rate definition (is it supposed to be smaller with multi-lablel?), or a problem with the creation of the LMDB's. Anyone know an example of a working multi-label?

Thanks!
Reply all
Reply to author
Forward
0 new messages