I am using caffe to do a classification task with every example is a float matrix, I am wondering whether there is a specific data layer which is able to handle such kind of inputs?
You can put any type of float data in leveldb or lmdb and it doesn't have to be images. You can refer convert_imageset.cpp and modify based on that to create leveldb for your matrix.
We welcome you to look at the extensive documentation, tutorials, and examples at http://caffe.berkeleyvision.org/
However, please ask usage questions on caffe-users -- this issues tracker is primarily for Caffe development discussion. Thanks!
@n-zhang Thank you very much!
To write data into lmdb:
if vector.dtype == np.int:
datum.data = vector.tostring()
elif vector.dtype == np.float:
datum.float_data.extend(vector.flat)
To read int data in lmdb:
flat_x = np.fromstring(datum.data, dtype=np.int)
x = flat_x.reshape(datum.channels, datum.height, datum.width)
y = datum.label
To read float data in lmdb:
x = np.array(datum.float_data).astype(float).reshape( datum.channels, datum.height, datum.width)
y = datum.label
@xulifan Thank you !
Most helpful comment
To write data into lmdb:
if vector.dtype == np.int:datum.data = vector.tostring()elif vector.dtype == np.float:datum.float_data.extend(vector.flat)To read int data in lmdb:
flat_x = np.fromstring(datum.data, dtype=np.int)x = flat_x.reshape(datum.channels, datum.height, datum.width)y = datum.labelTo read float data in lmdb:
x = np.array(datum.float_data).astype(float).reshape( datum.channels, datum.height, datum.width)y = datum.label