@ptrblck, thank you for an example. My dataset is “endless” and stored externally, thus, unfeasible to store in the class instance. So currently __getitem__() retrieves just one sample from the external database.
I’m concerned with the high overhead for this sample-by-sample querying; for batch size of e.g. 64, __getitem__() gets called 64 times consequently, doesn’t it?
I thought I could build a cache in MyDataset, fetching and storing bunches of samples in the class instance before returning them individually via __getitem__(). Is there a better way / better place to implement it?