Skip to content

Commit d5eb8e6

Browse files
committed
fix: take could result in more samples than max
1 parent 74c12db commit d5eb8e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

datastream/samplers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, length, proportion=1.0, replacement=False):
2424
replacement=replacement,
2525
sampler=torch.utils.data.WeightedRandomSampler(
2626
torch.ones(length).double(),
27-
num_samples=max(int(length * proportion), 1),
27+
num_samples=int(max(1, min(length, length * proportion))),
2828
replacement=replacement,
2929
)
3030
)

0 commit comments

Comments
 (0)