Skip to content

Commit 73ea418

Browse files
davnov134facebook-github-bot
authored andcommitted
SimpleDataLoaderMapProvider sample batches without replacement if num_samples is not specified
Summary: Samples batches without replacement if the number of samples is not specified. This makes sure that we always iterate over the whole dataset in each epoch. Reviewed By: bottler Differential Revision: D39270786 fbshipit-source-id: 0c983d1f5e0af711463abfb23939bc0d2b5172a0
1 parent f6d43ea commit 73ea418

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: pytorch3d/implicitron/dataset/data_loader_map_provider.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,14 @@ def _make_data_loader(
130130
num_samples = self.batch_size * num_batches
131131
else:
132132
num_samples = None
133-
sampler = RandomSampler(dataset, replacement=True, num_samples=num_samples)
133+
134+
# sample with replacement only if a custom number of samples is specified
135+
sampler = RandomSampler(
136+
dataset,
137+
replacement=num_samples is not None,
138+
num_samples=num_samples,
139+
)
140+
134141
batch_sampler = BatchSampler(sampler, self.batch_size, drop_last=True)
135142
return DataLoader(
136143
dataset,

0 commit comments

Comments
 (0)