I wrote my own custom dataset class but when I try to iterate through its data one by one I get an infinite loop.
I went to the extreme and have the __len__ method always return 0 and that didn’t stop it from continually looping through my dataset. How do I stop it? Why does:
for i, data in enumerate(dataset):
    print(i)
    print(data)


why does this keep calling the next method? How does it stop?

In the hope of having a reproducible error I coded this:
class MyDataset(Dataset):
    def __init__(self):
        self.bob = [0,1,2]

    def __len__(self):
        return 0

    def __getitem__(self, idx):
        print(f'idx = {idx}')
        return self.bob[idx]

now it does stop even though __len__ is zero…