Linear regression problem

242 views
Skip to first unread message

william...@gmail.com

unread,
Jul 30, 2015, 4:49:27 AM7/30/15
to Caffe Users
Hi everyone,

I am newbie to this Caffe platform. I have been doing with simple image classification project using Caffe for training (e.g: age classification, facial expression classification, ..)
But my new project requires me to do a linear regression problem. In particular, I have a dataset of 100k images, each image have 3 labels that have values ranged from [-1,1] (e.g: -0.7, 0.1, 0.5). My job is to train this dataset so that later the model can be used to predict these 3 values from any images.
Thus, how should I approach this problem? Is it a multi-label regression problem? Is it necessary to use HDF5 database format, or I can just use lmdb? How should I design the last layers, such as InnerProduct and EuclideanLoss?

Thank you for your help!!!

npit

unread,
Jul 31, 2015, 4:32:37 AM7/31/15
to Caffe Users, william...@gmail.com
What do the values for each label represent?

Xi Yin

unread,
Nov 3, 2015, 6:17:12 PM11/3/15
to Caffe Users
Hi William, 

I have exactly the same problem. I use HDF5 data format. In the matlab folder, there is a function that can write HDF5 data. 

However, I have problem for testing. I can get the loss for testing, but I am not sure where I can output the three values. Have you solved this problem already? Any idea? 



在 2015年7月30日星期四 UTC-4上午4:49:27,William Ng写道:

Jan C Peters

unread,
Nov 4, 2015, 3:19:07 AM11/4/15
to Caffe Users
That is more or less what I have been doing on the past, you got it quite figured out:
  • Yes, use HDF5. To create a h5 file is not really that hard, and there should be more than enough samples out there. The things necessary to use this h5 file successfully with caffe:
    • The names of the tables in the h5 file need to match the names of the top blobs of the respective HDF5Data layer, usually they are called 'data' and 'label'
    • shape for 'data' should be (<numsamples>, <numchannels>, <height>, <width>) in your case (and any case where 2D images are the inputs)
    • shape for 'label' should be (<numsamples>, 3) in your case
    • <numsamples> will be 100000 in your case then
    • <numchannels> is 1 if your images are grayscale, or 3 if they are RGB (or BGR, or any kind of 3 channel color)
  • Yes that is a 'multi-label' regression problem
  • Yes, for the final part I also use an InnerProduct layer followed by an euclidean loss layer. Not sure if another loss layer can make sense in your particular situation. There have implemented quite some loss layers since I started with caffe.
  • Accuracy layers do not work for regression, as you might imagine.
  • Not sure if you can really use LMDB for regression, but most users switch to HDF5 for this.
@Xi Yin: what do mean by "where I can output the three values"? If you do "manual" feedforward in pycaffe you could just look at the top blob of the topmost inner product layer: net.blobs[<nameofthatblob>].data

Jan
Reply all
Reply to author
Forward
0 new messages