Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. from torch.utils.data import IterableDataset
  2.  
  3. class CustomIterableDataset(IterableDataset):
  4.  
  5. def __init__(self, filename):
  6.  
  7. #Store the filename in object's memory
  8. self.filename = filename
  9.  
  10. #And that's it, we no longer need to store the contents in the memory
  11.  
  12. def __iter__(self):
  13.  
  14. #Create an iterator
  15. file_itr = open(self.filename)
  16.  
  17. return file_itr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement