caffe icon indicating copy to clipboard operation
caffe copied to clipboard

HDF5 output layer produces incorrect output

Open to3i opened this issue 12 years ago • 2 comments

Using the HDF5 output layer to extract the label and the prediction of a network I run into the following problem. The created HDF5 file contains two tables, however, both seem to be populated with data from the first bottom blob specified in the network file. At least the first value in both tables is identical and depending on the dimensions sometimes the complete table. A boiled down network example that reproduces the issue is the following:

name: "dummy"
layers{
  name: "dummy1"
  type: DUMMY_DATA
  dummy_data_param {
    num: 32
    channels: 32
    height: 24
    width: 24
    data_filler {
      type: "uniform"
      min: 10
      max: 256
    }
  }
  top: "data1"
}
layers{
  name: "dummy0"
  type: DUMMY_DATA
  dummy_data_param {
    num: 32
    channels: 1
    height: 1
    width: 1
    data_filler {
      type: "uniform"
      min: 1
      max: 2
    }
  }
  top: "label1"
}
layers {
  name: "hdf5out"
  type: HDF5_OUTPUT
  bottom: "data1"
  bottom: "label1"
  hdf5_output_param {
    file_name: "dummy_output.h5"
  }
}

You will find that the dummy_output.h5 contains two tables (data and label) where both contain values that fall in the range of 10...256 and that the first entry in both tables is identical.

I assume that somehow the hdf5 ouput layer does not correctly access the second bottom blob. I remember having used this layer successfully before, so maybe the problem is due to some recent changes?!

to3i avatar Jul 21 '14 10:07 to3i

After having a look into the code I found the mistake. The second caffe_copy uses the wrong bottom blob (0 instead of 1) in the cpu and gpu version of the layer. Error was introduced recently when replacing mem_copy and probably only needs to be fixed in dev branch.

   caffe_copy(data_datum_dim, &bottom[0]->cpu_data()[i * data_datum_dim],
        &data_blob_.mutable_cpu_data()[i * data_datum_dim]);
    caffe_copy(label_datum_dim, &bottom[**0**]->cpu_data()[i * label_datum_dim],
        &label_blob_.mutable_cpu_data()[i * label_datum_dim]);

to3i avatar Jul 21 '14 12:07 to3i

thanks, i'll fix this!

sergeyk avatar Jul 28 '14 21:07 sergeyk