Skip to content

Commit

Permalink
Merge pull request BVLC#1166 from pluskid/master
Browse files Browse the repository at this point in the history
bugfix: HDF5 layer reshape bug
  • Loading branch information
jeffdonahue committed Sep 29, 2014
2 parents 6d3e23b + e8589c6 commit 94927d2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/caffe/layers/hdf5_data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ void HDF5DataLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
// Reshape blobs.
const int batch_size = this->layer_param_.hdf5_data_param().batch_size();
(*top)[0]->Reshape(batch_size, data_blob_.channels(),
data_blob_.width(), data_blob_.height());
data_blob_.height(), data_blob_.width());
(*top)[1]->Reshape(batch_size, label_blob_.channels(),
label_blob_.width(), label_blob_.height());
label_blob_.height(), label_blob_.width());
LOG(INFO) << "output data size: " << (*top)[0]->num() << ","
<< (*top)[0]->channels() << "," << (*top)[0]->height() << ","
<< (*top)[0]->width();
Expand Down
2 changes: 1 addition & 1 deletion src/caffe/test/test_data/generate_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

num_cols = 8
num_rows = 10
height = 5
height = 6
width = 5
total_size = num_cols * num_rows * height * width

Expand Down
Binary file modified src/caffe/test/test_data/sample_data.h5
Binary file not shown.
Binary file modified src/caffe/test/test_data/sample_data_2_gzip.h5
Binary file not shown.
6 changes: 3 additions & 3 deletions src/caffe/test/test_hdf5data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TYPED_TEST(HDF5DataLayerTest, TestRead) {
hdf5_data_param->set_batch_size(batch_size);
hdf5_data_param->set_source(*(this->filename));
int num_cols = 8;
int height = 5;
int height = 6;
int width = 5;

// Test that the layer setup got the correct parameters.
Expand Down Expand Up @@ -93,8 +93,8 @@ TYPED_TEST(HDF5DataLayerTest, TestRead) {

// Every two iterations we are reading the second file,
// which has the same labels, but data is offset by total data size,
// which is 2000 (see generate_sample_data).
int file_offset = (iter % 4 < 2) ? 0 : 2000;
// which is 2400 (see generate_sample_data).
int file_offset = (iter % 4 < 2) ? 0 : 2400;

for (int i = 0; i < batch_size; ++i) {
EXPECT_EQ(
Expand Down

0 comments on commit 94927d2

Please sign in to comment.