matlab-lmdb
matlab-lmdb copied to clipboard
lmdb read and write with single value
Thanks for this great work. However, I wonder if the wrapper supported with single value. I used function ".put() " with single value but get a corresponding integer with function ".get() ". Could you make some instruction about read and write with single value? Thank your!
The wrapper does not include any serialization. You should serialize your variable before putting in the database. The easiest is to use char
.
database.put('key', num2str(X))
str2double(database.get('key'))
If you don't like string, you might find matlab-serialization useful.
Thank you .But I have tried matlab-serialization package. It seemed it did data transformation within matlab. However, I want to store single values into lmdb file. if I used serialize(), I would store uint8 array into lmdb file. I want to use the lmdb file for caffe. Would the caffe recognize the data and change it back to the single value? Or I have to make scaling like dividing 255 in the caffe.Could you make some further explanation for me about how can I store single value into lmdb file. Thank you!
@llyydd007 Are you trying to save a single value as a 4-byte binary? Then use typecast
, e.g.
typecast(single(20), 'uint8')
Thank you,I'm not familiar with lmdb. I means whether I can save values like 0.5678 into the lmdb file. Then the caffe package can read the lmdb file and get the value like 0.5678
@llyydd007 LMDB is only a key-value store for any binary. There is nothing fancy. It can only save and retrieve binaries. You have to take care of how you represent your data in a string or a binary.
If you're using Caffe, you perhaps want to serialize your data using protocol buffer. I do not have a generic protobuf converter, but you can implement one for Datum like this.
Thank you! I would try to modified some other codes like the one in the caffe example for data storing. But I still learn a lot from matlab-lmdb package. Thank you!
I have .mat files which I need to convert to .db format. Could you please specify the sequence of steps?