Skip to content

Commit

Permalink
SimpleDataLoaderMapProvider sample batches without replacement if num…
Browse files Browse the repository at this point in the history
…_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
  • Loading branch information
davnov134 authored and facebook-github-bot committed Sep 6, 2022
1 parent f6d43ea commit 73ea418
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pytorch3d/implicitron/dataset/data_loader_map_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ def _make_data_loader(
num_samples = self.batch_size * num_batches
else:
num_samples = None
sampler = RandomSampler(dataset, replacement=True, num_samples=num_samples)

# sample with replacement only if a custom number of samples is specified
sampler = RandomSampler(
dataset,
replacement=num_samples is not None,
num_samples=num_samples,
)

batch_sampler = BatchSampler(sampler, self.batch_size, drop_last=True)
return DataLoader(
dataset,
Expand Down

0 comments on commit 73ea418

Please sign in to comment.