-
Notifications
You must be signed in to change notification settings - Fork 184
Loader.__len__ is not a pure function #163
Copy link
Copy link
Closed
Labels
Milestone
Description
Counterintuitively, calling len() on a ffcv.loader.Loader instance modifies its internal state:
Lines 253 to 258 in bfd9b3d
| def __len__(self): | |
| next_order = self.next_traversal_order() | |
| if self.drop_last: | |
| return len(next_order) // self.batch_size | |
| else: | |
| return int(np.ceil(len(next_order) / self.batch_size)) |
This causes the bug in #140 when paired with OrderOption.QUASI_RANDOM.
I suppose the culprit is this line:
ffcv/ffcv/traversal_order/quasi_random.py
Line 24 in bfd9b3d
| random.shuffle(page_to_samples_array[page_ix, :page_size]) |
Reactions are currently unavailable