Skip to content
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

Why even use PyTorch's DataLoader in dataloader.py #35

Open
LexSong opened this issue Sep 6, 2018 · 4 comments
Open

Why even use PyTorch's DataLoader in dataloader.py #35

LexSong opened this issue Sep 6, 2018 · 4 comments

Comments

@LexSong
Copy link

LexSong commented Sep 6, 2018

It seems that the only way to get data from self.dataloader, is from get_batch(), and in get_batch() we recreate a new iterator of self.dataloader every time it is called. Therefore we always use only the first item returned by self.dataloader, which looks very pointless to create self.dataloader in the first place.

@akanimax
Copy link

akanimax commented Sep 6, 2018

Hi @LexSong,

You are right about the dataloader always returning first element of the iterator. But since the dataloader while creation has set shuffle=True, It will return different data-points (well, hopefully 😄). I wrote a package for pytorch for ProGANs (well structured code), you can check it out at https://github.com/akanimax/pro_gan_pytorch. Examples for using this package are at https://github.com/akanimax/pro_gan_pytorch-examples which validates that my code works.

Cheers!

@LexSong
Copy link
Author

LexSong commented Sep 6, 2018

It's really inefficient though.

By default RandomSampler chooses samples without replacements, so it will generate a random indices list (by torch.randperm(n).tolist()) every time we call it. If randomly sampling with replacements is what we want here, just create a dataset properly.

@akanimax
Copy link

akanimax commented Sep 6, 2018

@LexSong, Yes, I know it is inefficient. BTW, I am not the author of this code, was just helping. Did you check out the links?

@shamanez
Copy link

@akanimax your codes are perfect. I even followed the VDB code which is very efficient and informative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants