caffe icon indicating copy to clipboard operation
caffe copied to clipboard

reopen 922 for HDF5

Open sammoes opened this issue 10 years ago • 2 comments

A bug occurs though when a Siamese network initiates with a shared (left and right) label array in an HDF5 database.

As @shelhamer wrote under that issue #922 : it doesn't allow reads from multiple processes or multiple threads that aren't sharing the same leveldb::DB object. .. .two nets are instantiated with the same input.

That sounds very similar as to what I see. Indeed, copying the label array and assigning it as follows:

h5create('trainPatches.h5','/data_left',[9 9 1 numTrain]); h5create('trainPatches.h5','/data_right',[9 9 1 numTrain]); h5create('trainPatches.h5','/labels_right',[1 numTrain]); <----- instead of using a single labels array h5create('trainPatches.h5','/labels_left',[1 numTrain]); <----- instead of using a single labels array

h5create('valPatches.h5','/data_left',[9 9 1 numVal]); h5create('valPatches.h5','/data_right',[9 9 1 numVal]); h5create('valPatches.h5','/labels_right',[1 numVal]); h5create('valPatches.h5','/labels_left',[1 numVal]);

h5write('trainPatches.h5','/data_left', dataL_perm(:, :, :, 1:numTrain)); h5write('trainPatches.h5','/data_right', dataR_perm(:, :, :, 1:numTrain)); h5write('trainPatches.h5','/labels_right', labels_perm(:, 1:numTrain)); h5write('trainPatches.h5','/labels_left', labels_perm(:, 1:numTrain));

h5write('valPatches.h5','/data_left', dataL_perm(:, :, :, numTrain+1:end)); h5write('valPatches.h5','/data_right', dataR_perm(:, :, :, numTrain+1:end)); h5write('valPatches.h5','/labels_right', labels_perm(:, numTrain+1:end)); h5write('valPatches.h5','/labels_left', labels_perm(:, numTrain+1:end));

allows NN training to start. Although I am not sure this is a correct way to do it (my net's loss doesn't converge). I will update this issue later with the error messages (and any other info per your request).

https://groups.google.com/forum/#!topic/caffe-users/11lObS-fr1U

sammoes avatar Jun 10 '16 05:06 sammoes

If you need two copies of the same database, why not just have a single database, and then use that output in two places?

seanbell avatar Jun 11 '16 23:06 seanbell

I use a single H5 database, containing data_left, labels_left, data_right and labels_right data structures. labels_left and labels right are identical (copies) because just a 'labels' causes the issue/bug that is filed right here.

Sean, please, why would someone not have thought of that? It is exactly what is the issue here. If you want to help please take a look at the files on the Google group and read more thoroughly. If it is or should be possible to have a single labels data structure in the H5 file, then please explain how.

sammoes avatar Jun 12 '16 06:06 sammoes