why don’t we use idx += 1 instead of idx = (idx + 1) % len(self) ?
A special or edge case is needed to explain.
why don’t we use idx += 1 instead of idx = (idx + 1) % len(self) ?
A special or edge case is needed to explain.
We want to cycle through the dataset (i.e. restart from index 0) once the last data point is encountered. This is why we use the modulus operator with respect to length of dataset.