Skip to content

Commit

Permalink
previews: Support (path, key) tuples as data path
Browse files Browse the repository at this point in the history
Making it easier to reuse existing hdf5 files with multiple
data sets.
  • Loading branch information
mdraw committed Aug 20, 2017
1 parent de8f414 commit 81483b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion elektronn2/training/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ def _load_data(self):

def _load_preview_data(self):
if self.exp_config.preview_data_path is not None:
data = utils.h5load(self.exp_config.preview_data_path)
try: # Tuple of path and data set key
path, key = self.exp_config.preview_data_path
data = utils.h5load(path, key)
except (TypeError, ValueError): # Use default key
data = utils.h5load(self.exp_config.preview_data_path)
if not (isinstance(data, list) or isinstance(data, (tuple, list))):
data = [data,]
data = [d.astype(floatX)/d.max() for d in data]
Expand Down

0 comments on commit 81483b7

Please sign in to comment.