After loading the data into val_loader, I need to divide the validation data into n (n=2 or 5 etc.) parts.
Here is what I tried, but it throws error, ‘DataLoader’ object is not subscriptable.
total=len(val_loader.dataset)
print(total)
val1=val_loader[0:41629] # error, object is not subscriptable
val2=val_loader[41629:]
print(len(val1.dataset), len(val2.dataset))
Any suggestion on how to divide the val_loader in n parts.
You could use a SubsetRandomSampler to create different validation DataLoader, which would use the specified sample indices. Slicing the DataLoader is not supported.