Skip to content

Instantly share code, notes, and snippets.

@syaffers
Last active May 15, 2019 07:12
Show Gist options
  • Save syaffers/681721737aa75b8b926e504dec178f9d to your computer and use it in GitHub Desktop.
Save syaffers/681721737aa75b8b926e504dec178f9d to your computer and use it in GitHub Desktop.
The second iteration of the numbers dataset with user-defined range
from torch.utils.data import Dataset
class NumbersDataset(Dataset):
def __init__(self, low, high):
self.samples = list(range(low, high))
def __len__(self):
return len(self.samples)
def __getitem__(self, idx):
return self.samples[idx]
if __name__ == '__main__':
dataset = NumbersDataset(2821, 8295)
print(len(dataset))
print(dataset[100])
print(dataset[122:361])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment