1
$\begingroup$
    split = int(len(train_dataset) * 0.8)
    print(split)
    index_list = list(range(len(train_dataset)))
    train_idx, valid_idx = index_list[:split], index_list[split:]
    print(len(train_idx),len(valid_idx))
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))

print(len(train_loader.dataset),len(valid_loader.dataset))
60000 60000

However, the length does not seem to be right.

$\endgroup$

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.