Search code examples
machine-learningneural-networkdeep-learningcaffelmdb

Single Float label , LMDB Format in caffe


I am using caffe for a regression problem and I want to know how is possible to use format for single float label.

Right now, caffe only supports int32 type label for lmdb data (type of label in Datum is int32).
In order to change this default behavior, I changed some of files in caffe as follows but the problem has stayed and after converting my labels all are zero.

caffe.proto -> line36 : int32 to float
convert_imageset.cpp -> line 75 and 77 : int to float
io.cpp and io.hpp -> all the labels were int , I changed them to float 

After all I compiled caffe again but it doesn't work.

Is there anyone to solve this problem. it is very important to me to solve it as soon as possible.

Thanks in advance.


Solution

  • If you insist to force caffe to support float labels, you might need to change convert_imageset.cpp line 81 as well.
    Currently this line uses atoi to convert string to int:

    label = atoi(line.substr(pos + 1).c_str());
    

    You should convert it to user atof to convert string to float:

    label = atof(line.substr(pos + 1).c_str());