Skip to content
Snippets Groups Projects

Add support for databases which contain more than one sample in one file

Closed Amir MOHAMMADI requested to merge mutilsample into master
1 unresolved thread
1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
@@ -73,6 +73,9 @@ The config files should have the following objects totally:
# this is False, the loaded samples from a file are iterated over and each
# of them is saved as an independent feature.
one_file_one_sample = True
# Converts the read data to this format. [default: float32]
data_type = "float32"
"""
from __future__ import absolute_import
@@ -96,7 +99,7 @@ def _int64_feature(value):
def write_a_sample(writer, data, label):
feature = {'train/data': _bytes_feature(data.astype('float32').tostring()),
feature = {'train/data': _bytes_feature(data.tostring()),
'train/label': _int64_feature(label)}
example = tf.train.Example(features=tf.train.Features(feature=feature))
@@ -127,6 +130,7 @@ def main(argv=None):
data_extension = getattr(config, 'data_extension', '.hdf5')
shuffle = getattr(config, 'shuffle', False)
one_file_one_sample = getattr(config, 'one_file_one_sample', True)
data_type = getattr(config, 'data_type', "float32")
create_directories_safe(output_dir)
if not isinstance(groups, (list, tuple)):
@@ -143,7 +147,7 @@ def main(argv=None):
logger.info('Processing file %d out of %d', i + 1, n_files)
path = f.make_path(data_dir, data_extension)
data = reader(path)
data = reader(path).astype(data_type)
label = file_to_label(f)
if one_file_one_sample:
Loading