-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NotImplementedError for __len__ function in SafeDataLoader #2
Comments
Hi @sannawag, |
@msamogh, given the large size of my training dataset, I wish to validate more often than once per epoch. For this reason, when enumerating the dataloader, I check whether the index equals the length of the dataloader - 1. I do not directly have access to the dataset length because I initialize the dataloaders in a separate function. |
So if I understand you correctly, you wish to enumerate through a single DataLoader in a nested fashion? |
I do wish to enumerate through DataLoaders in a nested fashion, but one is a built from a training set, the other from a validation set. |
So what's preventing you from enumerating through the validation set in the usual way (using |
Here is the basic structure I am trying to obtain:
The catch is computing Thanks! |
Ah, I see. The bad news is you can't call This is because without actually checking every element, Hope that helps! |
Thank you @msamogh, this makes perfect sense. |
Hi @msamogh,
Having a __len__ function in SafeDataLoader, identical to the one in torch.utils.data.Dataloader, would be very helpful. I currently get the following error:
dataloader = nc.SafeDataLoader(dataset)
if i == len(dataloader):
File "envs/deep/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 504, in __len__
return len(self.batch_sampler)
File "envs/deep/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 150, in __len__
return (len(self.sampler) + self.batch_size - 1) // self.batch_size
File "envs/deep/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 20, in __len__
raise NotImplementedError
NotImplementedError
Thank you,
The text was updated successfully, but these errors were encountered: