SHARE
TWEET

Untitled

a guest Oct 21st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top