-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add IterableDataset support #323
Comments
Got it. Since it's impossible to know when to check validation, checkpoint or stop training the workaround is to add a really high number to the len of your dataloader. |
To support this we should modify the training loop so it does validation check, etc... every k batches. Might need to disable tqdm limit as well because we won't know the length. The use case is for streaming data or database-type reads. |
There is also a bit more simple case, when the length is actually known, but random access by index is not available. That is true in my case: my dataset generates samples on the fly, but always a fixed amount per epoch. Say, every epoch 10k samples are generated and fed into the model by batches on 100 samples. |
so, actually all of this can be solved by adding a way to say how many batches you want per epoch. then everything just works out. Trainer(max_epoch_batches=10000) |
@neggert any thoughts? |
In the past, I've handled this like by storing a def __len__(self):
return self.num_batches
def _get_batch(self):
...
def __iter__(self):
return iter((self._get_batch() for _ in range(self.num_batches)) This is probably not a good general solution, as it would have been a lot of work if I hadn't been planning on using a custom batch sampler anyway. For a general solution, think a We do need to be a little bit careful, as there are some pitfalls around using an |
Added in #405 To use: Trainer(val_check_interval=100) (checks val every 100 train batches interval) @falceeffect please verify it works as requested. Otherwise we can reopen |
Doesn't solve the problem |
Same here. Still give an error |
@calclavia which problem? compatibility? (@MikeScarp) |
@williamFalcon The original issue reported here is not fixed by #405. I am still unable to train with an instance of ItrableDataset. |
Right. Putting in |
@calclavia mind submitting a PR? where is the len being asked? i thought we specifically handled that case |
I tried defining the |
It appears there is a typo in the latest pip installable version 0.5.3.2 https://github.com/williamFalcon/pytorch-lightning/blob/0.5.3.2/pytorch_lightning/trainer/data_loading_mixin.py#L27. It should be This is later fixed in #549 but it has not been released. @williamFalcon will you be able to make a new release soon since there was no release in December? Thanks! |
Actually, even the latest master branch still has this problem.
|
@matthew-z Could you please reopen this issue or make another one? |
I don't have the privilege to re-open a closed issue, so I will open a new one |
Looks like currently there is no way to use an
IterableDataset
instance for training. Trying to do so results in a crash with this exception:The text was updated successfully, but these errors were encountered: