How to train the model with custom datasets
Elmiar0642 opened this issue · 1 comments
Elmiar0642 commented
I wish to use ADNI 3D MRI dataset. I saw training script. Idk how to modify it for custom datasets, especially like ADNI.
I just wish to normally create a model object and then train the model with the 3D images I have inside a directory. I just need to visualise the feature maps at each unit.
mdraw commented
If you want to use another dataset there are in principle two ways to proceed:
- Adapt the dataset to elektronn3's expected format for data loading (usually HDF5 files of the same layout as the ones you can find in the example data), so you can replace the data set in the
train_unet_neurodata.py
example with it. - Or use/write custom data loading code for your dataset. It just should be a subclass of
torch.utils.data.Dataset
and return a dict that contains an'inp'
key for input data asnp.float32
and a'target'
key for target (label) data asnp.int64
arrays if you want to train for classification. Everything else can be freely chosen. Then you can replace the reference toPatchCreator
in the example script by your ownDataset
class.