Custom `DataLoader` for On-the-Fly Image Generation
Create a custom torch.utils.data.Dataset
that doesn't load data from disk. Instead, the __getitem__
method should generate an image on the fly (e.g., a simple geometric shape, a random pattern, or even a fractal). This is a useful skill for when you don't have a pre-existing dataset. The __len__
method should simply return a large number of samples, and __getitem__
should create a new tensor with the image and a corresponding label for each call.
Verification: Iterate through your DataLoader
and visualize a few of the generated images. Each image in the batch should be unique and should correspond to the logic you defined in __getitem__
, proving that the generation is working correctly.