Skip to content

Instantly share code, notes, and snippets.

@syaffers
Last active May 15, 2019 07:13
Show Gist options
  • Save syaffers/70e8b8f779f341de5ddc813efcd0d90b to your computer and use it in GitHub Desktop.
Save syaffers/70e8b8f779f341de5ddc813efcd0d90b to your computer and use it in GitHub Desktop.
The first iteration of the numbers dataset
from torch.utils.data import Dataset
class NumbersDataset(Dataset):
def __init__(self):
self.samples = list(range(1, 1001))
def __len__(self):
return len(self.samples)
def __getitem__(self, idx):
return self.samples[idx]
if __name__ == '__main__':
dataset = NumbersDataset()
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