2

I want to use HDF5 file to input my data and labels in my CNN. I created the hdf5 file with matlab.

Here is my code:

h5create(['uNetDataSet.h5'],'/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/train/image',[522 775 3 numFrames]);
h5create(['uNetDataSet.h5'],'/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/train/anno',[522 775 3 numFrames]);
h5create(['uNetDataSet.h5'],'/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/label',[1 numFrames]);`


h5write(['uNetDataSet.h5'],'/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/train/image',images);
h5write(['uNetDataSet.h5'],'/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/train/anno',anno);
h5write(['uNetDataSet.h5'],'/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/label',label);`

Where image, anno are 4D unit8 and label is a 1x85 unit16 vector.

When I display my .h5 file I got this:

HDF5 uNetDataSet.h5
Group '/'
  Group '/home'
    Group '/home/alexandra'
        Group '/home/alexandra/Documents'
            Group '/home/alexandra/Documents/my-u-net'
                Group '/home/alexandra/Documents/my-u-net/warwick_dataset'
                    Group '/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset'
                        Dataset 'label'
                            Size:  1x85
                            MaxSize:  1x85
                            Datatype:   H5T_IEEE_F64LE (double)
                            ChunkSize:  []
                            Filters:  none
                            FillValue:  0.000000
                        Group '/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/train'
                            Dataset 'anno'
                                Size:  522x775x3x85
                                MaxSize:  522x775x3x85
                                Datatype:   H5T_IEEE_F64LE (double)
                                ChunkSize:  []
                                Filters:  none
                                FillValue:  0.000000
                            Dataset 'image'
                                Size:  522x775x3x85
                                MaxSize:  522x775x3x85
                                Datatype:   H5T_IEEE_F64LE (double)
                                ChunkSize:  []
                                Filters:  none
                                FillValue:  0.000000`

When I read the label dataset with h5read it works.

But when I try to train my network I got this error:

I0713 09:47:18.620510  4278 layer_factory.hpp:77] Creating layer loadMydata
I0713 09:47:18.620535  4278 net.cpp:91] Creating Layer loadMydata
I0713 09:47:18.620550  4278 net.cpp:399] loadMydata -> label
I0713 09:47:18.620580  4278 net.cpp:399] loadMydata -> anno
I0713 09:47:18.620600  4278 net.cpp:399] loadMydata -> image
I0713 09:47:18.620622  4278 hdf5_data_layer.cpp:79] Loading list of HDF5     filenames from: /home/alexandra/Documents/my-u-net/my_data.txt
I0713 09:47:18.620656  4278 hdf5_data_layer.cpp:93] Number of HDF5 files: 1
F0713 09:47:18.621317  4278 hdf5.cpp:14] Check failed:     H5LTfind_dataset(file_id, dataset_name_) Failed to find HDF5 dataset label
*** Check failure stack trace: ***
    @     0x7f2edf557daa  (unknown)
    @     0x7f2edf557ce4  (unknown)
    @     0x7f2edf5576e6  (unknown)
    @     0x7f2edf55a687  (unknown)
    @     0x7f2edf908597  caffe::hdf5_load_nd_dataset_helper<>()
    @     0x7f2edf907365  caffe::hdf5_load_nd_dataset<>()
    @     0x7f2edf9579fe  caffe::HDF5DataLayer<>::LoadHDF5FileData()
    @     0x7f2edf956818  caffe::HDF5DataLayer<>::LayerSetUp()
    @     0x7f2edf94fcbc  caffe::Net<>::Init()
    @     0x7f2edf950b45  caffe::Net<>::Net()
    @     0x7f2edf91d08a  caffe::Solver<>::InitTrainNet()
    @     0x7f2edf91e18c  caffe::Solver<>::Init()
    @     0x7f2edf91e4ba  caffe::Solver<>::Solver()
    @     0x7f2edf930ed3  caffe::Creator_SGDSolver<>()
    @           0x40e67e  caffe::SolverRegistry<>::CreateSolver()
    @           0x40794b  train()
    @           0x40590c  main
    @     0x7f2ede865f45  (unknown)
    @           0x406041  (unknown)
    @              (nil)  (unknown)
Aborted (core dumped)

In my .prototxt file :

layer {
  top: 'label'
  top:'anno'
  top: 'image'
  name: 'loadMydata'
  type: "HDF5Data"
  hdf5_data_param { source: '/home/alexandra/Documents/my-u-net/my_data.txt' batch_size: 1 } 
  include: { phase: TRAIN }
}

I don't know where I did something wrong, if anyone could help me it would be great !

Shai
  • 111,146
  • 38
  • 238
  • 371
Alex_AMC
  • 27
  • 1
  • 3

1 Answers1

1

your hdf5 file 'uNetDataSet.h5' does not have label in it.
What you have instead is '/home/alexandra/Documents/my-u-net/warwick_dataset/Warwick_Dataset/label' - I hope you can spot the difference.

Try creating the dataset with

h5create(['uNetDataSet.h5'],'/image',[522 775 3 numFrames]);
h5create(['uNetDataSet.h5'],'/anno',[522 775 3 numFrames]);
h5create(['uNetDataSet.h5'],'/label',[1 numFrames]);

Please see this answer for more details. Also note that you might need to permute the input data before saving it to hdf5 using matlab.

Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371