Skip to content

Instantly share code, notes, and snippets.

@kabirahuja2431
Last active February 23, 2020 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kabirahuja2431/d0c61b007f833f443537c3501afc5e41 to your computer and use it in GitHub Desktop.
Save kabirahuja2431/d0c61b007f833f443537c3501afc5e41 to your computer and use it in GitHub Desktop.
from torch.utils.data import IterableDataset
class CustomIterableDataset(IterableDataset):
def __init__(self, filename):
#Store the filename in object's memory
self.filename = filename
#And that's it, we no longer need to store the contents in the memory
def __iter__(self):
#Create an iterator
file_itr = open(self.filename)
return file_itr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment