huggingface/pytorch-image-models · error · ValueError
schedule_random_mix must be between 0 and 1.
Error message
schedule_random_mix must be between 0 and 1.
What it means
schedule_random_mix — the fraction of batches randomly mixed between choice levels in a progressive schedule — must lie in [0, 1]; values outside that range are rejected at construction.
Source
Thrown at timm/data/scheduled_sampler.py:80
if len(sampler) <= 0:
raise ValueError('ScheduledBatchSampler requires a non-empty sampler.')
if not batch_sizes:
raise ValueError('batch_sizes must contain at least one value.')
if any(int(batch_size) != batch_size or batch_size <= 0 for batch_size in batch_sizes):
raise ValueError('All scheduled batch sizes must be positive integers.')
if num_batches is not None and (int(num_batches) != num_batches or num_batches <= 0):
raise ValueError('num_batches must be a positive integer when specified.')
if choice_schedule not in ('constant', 'progressive'):
raise ValueError("choice_schedule must be 'constant' or 'progressive'.")
if choice_schedule == 'progressive':
if len(batch_sizes) < 2:
raise ValueError('A progressive schedule requires at least two choices.')
if schedule_epochs is None or int(schedule_epochs) != schedule_epochs or schedule_epochs <= 0:
raise ValueError('schedule_epochs must be a positive integer for a progressive schedule.')
if schedule_spread < 0:
raise ValueError('schedule_spread must be non-negative.')
if not 0 <= schedule_random_mix <= 1:
raise ValueError('schedule_random_mix must be between 0 and 1.')
self.sampler = sampler
self.batch_sizes = tuple(int(batch_size) for batch_size in batch_sizes)
self.choice_weights = self._normalize_choice_weights(choice_weights)
self._active_choices = tuple(
choice_index
for choice_index, choice_weight in enumerate(self.choice_weights)
if choice_weight > 0
)
self.seed = seed
self.drop_last = drop_last
self.shuffle_schedule = shuffle_schedule
self.choice_schedule = choice_schedule
self.schedule_epochs = int(schedule_epochs) if schedule_epochs is not None else None
self.schedule_spread = schedule_spread
self.schedule_random_mix = schedule_random_mix
self.epoch = 0
self.average_batch_size = self._calculate_average_batch_size()View on GitHub (pinned to 9a5261e31b)
Solutions
- Express the value as a fraction in [0,1] (e.g. 0.1 for 10% random mixing).
- If it's not needed, leave it at the default 0.1 or set 0.
Example fix
# before schedule_random_mix=10 # meant 10% # after schedule_random_mix=0.1
Defensive patterns
Strategy: validation
Validate before calling
assert schedule_random_mix is None or 0 <= schedule_random_mix <= 1
Prevention
- Express mix as a fraction (0.1 not 10).
- Range-check probability-like hyperparameters in config validation.
When it happens
Trigger: choice_schedule='progressive' with schedule_random_mix=1.5, -0.1, or 10.
Common situations: Config typo (extra digit); expressing the mix as a percentage (10 for 10%) instead of a fraction (0.1).
Related errors
- All scheduled batch sizes must be positive integers.
- num_batches must be a positive integer when specified.
- A progressive schedule requires at least two choices.
- schedule_epochs must be a positive integer for a progressive
- schedule_spread must be non-negative.
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/f30e1fea9e0297cc.
Report an issue: GitHub.