Caffe: Understanding expected lmdb datastructure for blobs

落花浮王杯 提交于 2019-12-03 05:49:20

I realized that protocol buffers must come into play here. So I tried to deserialize it against some of the types defined in caffe.proto.

Datum seems to be the perfect fit:

{Caffe.Datum}
    Channels: 1
    Data: {byte[784]}
    Encoded: false
    FloatData: Count = 0
    Height: 28
    Label: 7
    Width: 28

So the answer is simply: It's a serialized representation of a 'Datum' typed instance as defined per caffe.proto

Btw. since english is not my native language I had to first realize that "Datum" is a singular form of "data"

When it comes to using your own data, it's structured as follows:

The conventional blob dimensions for data are number N x channel K x height H x width W. Blob memory is row-major in layout so the last / rightmost dimension changes fastest. For example, the value at index (n, k, h, w) is physically located at index ((n * K + k) * H + h) * W + w.

See Blobs, Layers, and Nets: anatomy of a Caffe model for reference

PrasannaDate

I can try to answer your second question. Since Caffe only takes data in a bunch of selected formats like lmdb, hdf5 etc., it is best to convert (or generate - in case of synthetic data) your data to these formats. Following links can help you in this. If you have trouble with import hdf5in Python, then you may refer to this page.

Creating an LMDB file in Python

Writing an HDF5 file in Python

HDF5 more examples

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!