Add reshuffle_each_epoch argument to control mini-batch shuffling per… #99
+9
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the mini-batch generator in the reinforcement learning training pipeline by introducing the
reshuffle_each_epoch
parameter. This parameter controls whether data indices are reshuffled at each epoch or kept fixed.Motivation
In reinforcement learning, especially in PPO-style policy optimization, shuffling the training data indices at each epoch can improve generalization and reduce correlation between samples. However, some use cases require fixed mini-batch ordering across epochs to enable reproducible experiments and debugging. This PR introduces an explicit toggle to support both workflows.
Details
reshuffle_each_epoch
flag defaults toFalse
to maintain deterministic iteration over mini-batches across epochs.reshuffle_each_epoch=True
, mini-batch indices are reshuffled at the start of every epoch, enabling new mini-batch orders per epoch and improved generalization.References
The
reshuffle_each_epoch
argument implemented here serves a role analogous to theshuffle
parameter in PyTorch'storch.utils.data.DataLoader
. Settingshuffle=True
causes the data sampler to reshuffle dataset indices at the start of each epoch, which helps reduce model overfitting and improves generalization.Similarly, this PR's
reshuffle_each_epoch
flag controls whether mini-batch indices are reshuffled every epoch (True
), or fixed after the initial shuffle (False
), providing flexibility in how training data is fed during reinforcement learning updates.Testing
reshuffle_each_epoch=True
produces new mini-batch orders per epoch.reshuffle_each_epoch=False
preserves mini-batch order across epochs.Please review and advise if further adjustments are necessary.