Last active
May 15, 2019 07:12
-
-
Save syaffers/681721737aa75b8b926e504dec178f9d to your computer and use it in GitHub Desktop.
The second iteration of the numbers dataset with user-defined range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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