forked from BVLC/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BVLC#203 from sergeyk/hdf5_data
HDF5DataLayer source now takes list of filenames, loads one at a time.
- Loading branch information
Showing
10 changed files
with
205 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
""" | ||
Generate data used in the HDF5DataLayer test. | ||
""" | ||
|
||
import os | ||
import numpy as np | ||
import h5py | ||
|
||
num_cols = 8 | ||
num_rows = 10 | ||
height = 5 | ||
width = 5 | ||
data = np.arange(num_cols * num_rows * height * width).reshape(num_rows, num_cols, height, width) | ||
total_size = num_cols * num_rows * height * width | ||
|
||
data = np.arange(total_size) | ||
data = data.reshape(num_rows, num_cols, height, width) | ||
data = data.astype('float32') | ||
label = np.arange(num_rows)[:, np.newaxis] | ||
label = label.astype('float32') | ||
|
||
print data | ||
print label | ||
|
||
with h5py.File('./sample_data.h5', 'w') as f: | ||
f['data'] = data.astype('float32') | ||
f['label'] = label.astype('float32') | ||
with h5py.File(os.path.dirname(__file__) + '/sample_data.h5', 'w') as f: | ||
f['data'] = data | ||
f['label'] = label | ||
|
||
with h5py.File(os.path.dirname(__file__) + '/sample_data_2_gzip.h5', 'w') as f: | ||
f.create_dataset( | ||
'data', data=data + total_size, | ||
compression='gzip', compression_opts=1 | ||
) | ||
f.create_dataset( | ||
'label', data=label, | ||
compression='gzip', compression_opts=1 | ||
) | ||
|
||
with open(os.path.dirname(__file__) + '/sample_data_list.txt', 'w') as f: | ||
f.write(os.path.dirname(__file__) + '/sample_data.h5\n') | ||
f.write(os.path.dirname(__file__) + '/sample_data_2_gzip.h5\n') |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/caffe/test/test_data/sample_data.h5 | ||
src/caffe/test/test_data/sample_data_2_gzip.h5 |
Oops, something went wrong.