Configure dataset finiteness and shuffling in PyTorch
mainWhen using MultiTFRecordDataset or TFRecordDataset in PyTorch, you can control the following behaviors:
- Finiteness: By default,
MultiTFRecordDatasetis infinite. Setinfinite=Falseto make it finite. - Shuffling: Both datasets automatically shuffle data if you provide a
shuffle_queue_sizeargument.
# Finite dataset
dataset = MultiTFRecordDataset(..., infinite=False)
# Shuffled dataset
dataset = TFRecordDataset(..., shuffle_queue_size=1024)