| 262 | |
| 263 | |
| 264 | class DummyDataset(Dataset): |
| 265 | def __init__(self, num_samples: int = 10000000, **kwargs): |
| 266 | """ |
| 267 | kwargs must contain the output keys with their corresponding shapes, |
| 268 | e.g. image=(3, 32, 32), label=(1,) |
| 269 | """ |
| 270 | super().__init__() |
| 271 | self.num_samples = num_samples |
| 272 | self.kwargs = {k: tuple(v) if not isinstance(v, str) else v for k, v in kwargs.items()} |
| 273 | |
| 274 | def __len__(self): |
| 275 | return int(self.num_samples) |
| 276 | |
| 277 | def __getitem__(self, idx): |
| 278 | return { |
| 279 | k: v if isinstance(v, str) else torch.randn(v) |
| 280 | for k, v in self.kwargs.items() |
| 281 | } |
| 282 | |
| 283 | |
| 284 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected