{"record":{"id":"f0beee5df10ea4cb","repo":"huggingface/pytorch-image-models","slug":"schedule-epochs-must-be-a-positive-integer-for-a-p","errorCode":null,"errorMessage":"schedule_epochs must be a positive integer for a progressive schedule.","messagePattern":"schedule_epochs must be a positive integer for a progressive schedule\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/data/scheduled_sampler.py","lineNumber":76,"sourceCode":"            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        )\n        self.seed = seed\n        self.drop_last = drop_last\n        self.shuffle_schedule = shuffle_schedule\n        self.choice_schedule = choice_schedule\n        self.schedule_epochs = int(schedule_epochs) if schedule_epochs is not None else None","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/data/scheduled_sampler.py#L58-L94","documentation":"For choice_schedule='progressive', schedule_epochs defines over how many epochs the batch size grows and must be a positive integer; None, 0, negative, or fractional values are rejected.","triggerScenarios":"choice_schedule='progressive' with schedule_epochs omitted (defaults to None) or set to 0/10.5/-3.","commonSituations":"Enabling progressive mode without reading the required extra params; computing epochs from a fraction of total epochs (0.5*epochs) without rounding; config defaults of None leaking through.","solutions":["Set an explicit positive integer, e.g. schedule_epochs=20.","If computed, round and clamp: max(1, round(frac * total_epochs))."],"exampleFix":"# before\nScheduledBatchSampler(s, batch_sizes=[64,256], choice_schedule='progressive')\n\n# after\nScheduledBatchSampler(s, batch_sizes=[64,256], choice_schedule='progressive', schedule_epochs=20)","handlingStrategy":"validation","validationCode":"if choice_schedule == 'progressive':\n    assert schedule_epochs is not None and int(schedule_epochs) == schedule_epochs > 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set schedule_epochs explicitly when enabling progressive.","Round fractional epoch computations.","Config-schema-validate required keys per schedule mode."],"tags":["timm","sampler","schedule-epochs","validation"],"backgroundTag":"invalid-numeric-config-value","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}