Datum object in caffe - unsupervised networks

212 views Asked by At

from a script on preparing data for a caffe network, the following piece of code turns an image (numpy array representing an image) into a datum object.

datum = caffe_pb2.Datum(
        channels=3,
        width=224,
        height=224,
        label=label,
        data=np.rollaxis(img, 2).tostring())

If the network were unsupervised, do you just create the object the same way but do not fill the label parameter, as shown below?

datum = caffe_pb2.Datum(
            channels=3,
            width=224,
            height=224,
            data=np.rollaxis(img, 2).tostring())
1

There are 1 answers

1
Shai On BEST ANSWER

The label of Datum is optional:

optional int32 label = 5;

Meaning oyu do not have to provide it.

Side note:
Datum is a data structure used mainly for "Data" input layer and strictly speaking it is not part of the trained net.
Caffe uses N-D tensors Blobs to store both data and parameters of the net.