caffe.io.array_to_datum does not produce data readable by caffe
I created some data and saved them in LMDB using the function
caffe.io.array_to_datum
dbenv = lmdb.open(filename, writemap=True)
db = dbenv.begin(write=True)
for i in range(num):
datum = caffe.io.array_to_datum(images(i), int(labels(i)))
str_id = '{:0>8d}'.format(i)
db.put(str_id, datum.SerializeToString())
dbenv.close()
I am able to load using datum_to_array right after I close the environment, but when it is loaded (with data dir specified in source in the .prototxt) using caffe.Net(), the data and label blob are all zeros.
Is anything broken??
Below is the output when loading the net
I0427 13:37:27.017026 20476 layer_factory.hpp:77] Creating layer data I0427 13:37:27.018026 20476 net.cpp:91] Creating Layer data I0427 13:37:27.024531 20476 net.cpp:399] data -> data I0427 13:37:27.026042 14552 common.cpp:36] System entropy source not available, using fallback algorithm to generate seed instead. I0427 13:37:27.026531 20476 net.cpp:399] data -> label I0427 13:37:27.029536 14552 db_lmdb.cpp:52] Opened lmdb data/gabor I0427 13:37:27.034039 20476 data_layer.cpp:41] output data size: 50,3,227,227 I0427 13:37:27.084075 20476 net.cpp:141] Setting up data I0427 13:37:27.084576 20476 net.cpp:148] Top shape: 50 3 227 227 (7729350) I0427 13:37:27.086074 20476 net.cpp:148] Top shape: 50 (50) I0427 13:37:27.086576 6472 common.cpp:36] System entropy source not available, using fallback algorithm to generate seed instead. I0427 13:37:27.088076 20476 net.cpp:156] Memory required for data: 30917600 I0427 13:37:27.093082 20476 layer_factory.hpp:77] Creating layer label_data_1_split I0427 13:37:27.095582 20476 net.cpp:91] Creating Layer label_data_1_split I0427 13:37:27.098086 20476 net.cpp:425] label_data_1_split <- label I0427 13:37:27.100586 20476 net.cpp:399] label_data_1_split -> label_data_1_split_0 I0427 13:37:27.103087 20476 net.cpp:399] label_data_1_split -> label_data_1_split_1 I0427 13:37:27.105590 20476 net.cpp:141] Setting up label_data_1_split I0427 13:37:27.108594 20476 net.cpp:148] Top shape: 50 (50) I0427 13:37:27.111093 20476 net.cpp:148] Top shape: 50 (50) I0427 13:37:27.113595 20476 net.cpp:156] Memory required for data: 30918000 I0427 13:37:27.116096 20476 layer_factory.hpp:77] Creating layer conv1 I0427 13:37:27.118597 20476 net.cpp:91] Creating Layer conv1 I0427 13:37:27.122099 20476 net.cpp:425] conv1 <- data I0427 13:37:27.125102 20476 net.cpp:399] conv1 -> conv1
Ok so I just have to run a forward But why is the behaviour different for memory_data? When I load data from memory, I can immediately see them in the data blob?
I'm closing this since it's a question about how to use caffe. Please ask questions like this on the mailing list.
If you think you've found a bug in caffe, please re-open the issue.
From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:
Please do not post usage, installation, or modeling questions, or other requests for help to Issues. Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.