Introduce DataSource
#24
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ml4ht.data.data_source.DataIndexgeneralizes the idea of a sample id by replacing an integer id with a dictionary of values to select data with.The simplest
DataIndexis something like{"sample_id": 2}, but you might also want to include something like the dates for your modalities:{"sample_id": 2, "ecg_date": 01-01-2000, "af_date": 02-01-2000}.ml4ht.data.data_source.DataSourcegeneralizes the data-getting side ofml4hTensorMaps andDataDescription.get_raw_data.A
DataSourcereturns a dictionary of model inputs, and a dictionary of model outputs. For example,ECGHD5Sourcemight return{"ecg": np.array(...), "ecg_age": [12]}, {"AF": [0, 1]}.In order to train using multiple
DataSources, you can useml4ht.data.data_source.TrainingDataset, which integrates withpytorchsDataLoaderfor multiprocessing capabilities.If you want to skip errors, or change the indices each epoch, use
ml4ht.data.data_source.TrainingIterableDataset.