| 91 | |
| 92 | |
| 93 | class Subset(Dataset): |
| 94 | def __init__(self, dataset, indices): |
| 95 | self.dataset = dataset |
| 96 | self.indices = indices |
| 97 | |
| 98 | def __getitem__(self, idx): |
| 99 | return self.dataset[self.indices[idx]] |
| 100 | |
| 101 | def __len__(self): |
| 102 | return len(self.indices) |
| 103 | |
| 104 | |
| 105 | def random_split(dataset, lengths): |