talha06
talha06

Reputation: 6466

PyTorch - How to use k-fold cross validation when the data is loaded through ImageFolder?

My data, which is images, is stored on the filesystem, and it is fed into my convolutional neural network through the ImageFolder data loader of PyTorch. Therefore, the training, validation, and test data is manually splitted into different folders on the filesystem. So, how can I apply k-fold cross validation when using ImageFolder?

Upvotes: 2

Views: 3224

Answers (1)

Shai
Shai

Reputation: 114906

You can merge the fixed train/val/test folds you currently have using data.ConcatDataset into a single Dataset. Then you can use data.Subset to randomly split the single dataset into different folds over and over.

Upvotes: 1

Related Questions