{"record":{"id":"3549aa0fba53194f","repo":"Unity-Technologies/ml-agents","slug":"the-schedule-self-schedule-is-invalid","errorCode":null,"errorMessage":"The schedule {self.schedule} is invalid.","messagePattern":"The schedule (.+?) is invalid\\.","errorType":"exception","errorClass":"UnityTrainerException","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/torch_entities/utils.py","lineNumber":99,"sourceCode":"            self.schedule = schedule\n            self.initial_value = initial_value\n            self.min_value = min_value\n            self.max_step = max_step\n\n        def get_value(self, global_step: int) -> float:\n            \"\"\"\n            Get the value at a given global step.\n            :param global_step: Step count.\n            :returns: Decayed value at this global step.\n            \"\"\"\n            if self.schedule == ScheduleType.CONSTANT:\n                return self.initial_value\n            elif self.schedule == ScheduleType.LINEAR:\n                return ModelUtils.polynomial_decay(\n                    self.initial_value, self.min_value, self.max_step, global_step\n                )\n            else:\n                raise UnityTrainerException(f\"The schedule {self.schedule} is invalid.\")\n\n    @staticmethod\n    def polynomial_decay(\n        initial_value: float,\n        min_value: float,\n        max_step: int,\n        global_step: int,\n        power: float = 1.0,\n    ) -> float:\n        \"\"\"\n        Get a decayed value based on a polynomial schedule, with respect to the current global step.\n        :param initial_value: Initial value before decay.\n        :param min_value: Decay value to this value by max_step.\n        :param max_step: The final step count where the return value should equal min_value.\n        :param global_step: The current step count.\n        :param power: Power of polynomial decay. 1.0 (default) is a linear decay.\n        :return: The current decayed value.\n        \"\"\"","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/torch_entities/utils.py#L81-L117","documentation":"LearningRateSchedule.get_value raises UnityTrainerException when the configured schedule name is neither CONSTANT nor LINEAR. ML-Agents validates schedule types via the ScheduleType enum; an unrecognized value reaching get_value means an invalid hyperparameter got past (or bypassed) config validation.","triggerScenarios":"Setting hyperparameters.learning_schedule / learning_rate_schedule to a string other than 'constant' or 'linear' in the trainer YAML config and constructing the schedule.","commonSituations":"Typo in the YAML (e.g. 'exponential' or 'Cosine'); editing a config copied from an older ML-Agents version whose schedule names changed; generating configs programmatically with raw strings instead of ScheduleType enum values.","solutions":["Set learning_rate_schedule to exactly 'constant' or 'linear' in the trainer config YAML","Validate the config against the current ML-Agents trainer_config.schema.json before training","Upgrade/downgrade configs when migrating between ML-Agents versions (schedule options changed across releases)","If constructing programmatically, use ScheduleType.CONSTANT / ScheduleType.LINEAR enums instead of raw strings"],"exampleFix":"// before (trainer_config.yaml)\nlearning_rate_schedule: exponential\n// after\nlearning_rate_schedule: linear","handlingStrategy":"validation","validationCode":"from mlagents.trainers.settings import ScheduleType\nschedule = hyperparams.learning_rate_schedule\nassert schedule in (ScheduleType.CONSTANT, ScheduleType.LINEAR), f\"Invalid schedule {schedule}\"","typeGuard":"def is_valid_schedule(value) -> bool:\n    try:\n        return ScheduleType(value.lower()) in (ScheduleType.CONSTANT, ScheduleType.LINEAR)\n    except (ValueError, AttributeError):\n        return False","tryCatchPattern":"from mlagents.trainers.exception import UnityTrainerException\ntry:\n    lr = lr_schedule.get_value(step)\nexcept UnityTrainerException as e:\n    logger.error(f\"Bad schedule config: {e}\")\n    lr = hyperparams.learning_rate  # fall back to constant","preventionTips":["Only use 'constant' or 'linear' for learning_rate_schedule","Run run_options validation / schema check before training","When upgrading ML-Agents, diff your YAML against the released trainer_config.yaml samples"],"tags":["python","mlagents","config-validation","hyperparameters"],"backgroundTag":"invalid-schedule-type","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}