victoresque / pytorch-template

PyTorch deep learning projects made easy.
MIT License
4.75k stars 1.09k forks source link

Removing the transformations in the validation phase #62

Closed denadai2 closed 4 years ago

denadai2 commented 5 years ago

Hi, I would like to remove some of the transformations in the data loader when there is the validation phase. Any suggestion to do it in a clean way through your template?

thanks

SunQpark commented 5 years ago

train / valid splitting of BaseDataLoader in this project, or torch.utils.data.random_split only split the indices of dataset. I think the best method of doing this is to have different dataset object for train and validation set.

  1. modify your dataset class to have training=True in __init__, and use different data by this flag.
  2. initialize train_dataset and valid_dataset respectively.
  3. self.valid_loader = torch.utils.data.DataLoader(valid_dataset, ...)
  4. override the split_validation method to just return self.valid_loader
denadai2 commented 5 years ago

Thank you