{"record":{"id":"d3e0bb923d72d63f","repo":"huggingface/pytorch-image-models","slug":"choice-schedule-must-be-constant-or-progressive","errorCode":null,"errorMessage":"choice_schedule must be 'constant' or 'progressive'.","messagePattern":"choice_schedule must be 'constant' or 'progressive'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/data/scheduled_sampler.py","lineNumber":71,"sourceCode":"            shuffle_schedule: bool = True,\n            num_batches: Optional[int] = None,\n            choice_schedule: str = 'constant',\n            schedule_epochs: Optional[int] = None,\n            schedule_spread: float = 0.65,\n            schedule_random_mix: float = 0.1,\n    ) -> None:\n        if not hasattr(sampler, '__len__'):\n            raise TypeError('ScheduledBatchSampler requires a sampler with a length.')\n        if len(sampler) <= 0:\n            raise ValueError('ScheduledBatchSampler requires a non-empty sampler.')\n        if not batch_sizes:\n            raise ValueError('batch_sizes must contain at least one value.')\n        if any(int(batch_size) != batch_size or batch_size <= 0 for batch_size in batch_sizes):\n            raise ValueError('All scheduled batch sizes must be positive integers.')\n        if num_batches is not None and (int(num_batches) != num_batches or num_batches <= 0):\n            raise ValueError('num_batches must be a positive integer when specified.')\n        if choice_schedule not in ('constant', 'progressive'):\n            raise ValueError(\"choice_schedule must be 'constant' or 'progressive'.\")\n        if choice_schedule == 'progressive':\n            if len(batch_sizes) < 2:\n                raise ValueError('A progressive schedule requires at least two choices.')\n            if schedule_epochs is None or int(schedule_epochs) != schedule_epochs or schedule_epochs <= 0:\n                raise ValueError('schedule_epochs must be a positive integer for a progressive schedule.')\n            if schedule_spread < 0:\n                raise ValueError('schedule_spread must be non-negative.')\n            if not 0 <= schedule_random_mix <= 1:\n                raise ValueError('schedule_random_mix must be between 0 and 1.')\n\n        self.sampler = sampler\n        self.batch_sizes = tuple(int(batch_size) for batch_size in batch_sizes)\n        self.choice_weights = self._normalize_choice_weights(choice_weights)\n        self._active_choices = tuple(\n            choice_index\n            for choice_index, choice_weight in enumerate(self.choice_weights)\n            if choice_weight > 0\n        )","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/data/scheduled_sampler.py#L53-L89","documentation":"choice_schedule controls how batch-size choices are selected over epochs and only accepts 'constant' or 'progressive'; any other string hits this ValueError during constructor validation.","triggerScenarios":"choice_schedule='linear', 'cosine', 'Progressive' (capitalized), or a typo like 'progresive'.","commonSituations":"Copy-pasting schedule names from LR-scheduler configs (cosine/step) into the sampler config; case or spelling mistakes from hand-edited YAML.","solutions":["Use exactly 'constant' or 'progressive' (lowercase).","If you wanted a gradually increasing batch size, 'progressive' is the intended mode — also set schedule_epochs and >=2 batch_sizes."],"exampleFix":"# before\nScheduledBatchSampler(s, batch_sizes=[128,256], choice_schedule='linear')\n\n# after\nScheduledBatchSampler(s, batch_sizes=[128,256], choice_schedule='progressive', schedule_epochs=10)","handlingStrategy":"validation","validationCode":"assert choice_schedule in ('constant', 'progressive'), f'bad schedule: {choice_schedule}'","typeGuard":"def is_valid_schedule(v: str) -> bool:\n    return isinstance(v, str) and v in ('constant', 'progressive')","tryCatchPattern":null,"preventionTips":["Lowercase and whitelist-check schedule strings from configs.","Keep sampler config keys separate from LR-scheduler keys."],"tags":["timm","sampler","schedule","invalid-argument"],"backgroundTag":"invalid-enum-config-value","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}