SHARE
TWEET

Untitled

a guest May 25th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from torch.utils.data import Dataset
  2.  
  3. class NumbersDataset(Dataset):
  4.     def __init__(self, low, high):
  5.         self.samples = list(range(low, high))
  6.  
  7.     def __len__(self):
  8.         return len(self.samples)
  9.  
  10.     def __getitem__(self, idx):
  11.         return self.samples[idx]
  12.  
  13.  
  14. if __name__ == '__main__':
  15.     dataset = NumbersDataset(2821, 8295)
  16.     print(len(dataset))
  17.     print(dataset[100])
  18.     print(dataset[122:361])
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