split = int(len(train_dataset) * 0.8)
    index_list = list(range(len(train_dataset)))
    train_idx, valid_idx = index_list[:split], index_list[split:]
48000 12000

I got this 48000 and 12000 index for train_idx and valid_idx

Then I apply this number to the dataloader.

train_loader = DataLoader(train_dataset, batch_size=batch_size, sampler= SubsetRandomSampler(train_idx))
valid_loader = DataLoader(train_dataset, batch_size=batch_size, sampler=SubsetRandomSampler(valid_idx))

60000 60000

However, the length does not seem to be right.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.