Unity-Technologies/ml-agents · error · UnityTrainerException
The schedule {self.schedule} is invalid.
Error message
The schedule {self.schedule} is invalid. What it means
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.
Source
Thrown at ml-agents/mlagents/trainers/torch_entities/utils.py:99
self.schedule = schedule
self.initial_value = initial_value
self.min_value = min_value
self.max_step = max_step
def get_value(self, global_step: int) -> float:
"""
Get the value at a given global step.
:param global_step: Step count.
:returns: Decayed value at this global step.
"""
if self.schedule == ScheduleType.CONSTANT:
return self.initial_value
elif self.schedule == ScheduleType.LINEAR:
return ModelUtils.polynomial_decay(
self.initial_value, self.min_value, self.max_step, global_step
)
else:
raise UnityTrainerException(f"The schedule {self.schedule} is invalid.")
@staticmethod
def polynomial_decay(
initial_value: float,
min_value: float,
max_step: int,
global_step: int,
power: float = 1.0,
) -> float:
"""
Get a decayed value based on a polynomial schedule, with respect to the current global step.
:param initial_value: Initial value before decay.
:param min_value: Decay value to this value by max_step.
:param max_step: The final step count where the return value should equal min_value.
:param global_step: The current step count.
:param power: Power of polynomial decay. 1.0 (default) is a linear decay.
:return: The current decayed value.
"""View on GitHub (pinned to 3ecb446f75)
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
Example fix
// before (trainer_config.yaml) learning_rate_schedule: exponential // after learning_rate_schedule: linear
Defensive patterns
Strategy: validation
Validate before calling
from mlagents.trainers.settings import ScheduleType
schedule = hyperparams.learning_rate_schedule
assert schedule in (ScheduleType.CONSTANT, ScheduleType.LINEAR), f"Invalid schedule {schedule}" Type guard
def is_valid_schedule(value) -> bool:
try:
return ScheduleType(value.lower()) in (ScheduleType.CONSTANT, ScheduleType.LINEAR)
except (ValueError, AttributeError):
return False Try / catch
from mlagents.trainers.exception import UnityTrainerException
try:
lr = lr_schedule.get_value(step)
except UnityTrainerException as e:
logger.error(f"Bad schedule config: {e}")
lr = hyperparams.learning_rate # fall back to constant Prevention
- 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
When it happens
Trigger: Setting hyperparameters.learning_schedule / learning_rate_schedule to a string other than 'constant' or 'linear' in the trainer YAML config and constructing the schedule.
Common situations: 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.
Related errors
- The trainer config contains an unknown trainer type {trainer
- The trainer was unable to process any of the provided inputs
- The one of the goals uses variable length observations. This
- Trainer was unable to process any of the goals provided as i
- Visual observation resolution ({width}x{height}) is too smal
AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02).
Data as JSON: /api/errors/3549aa0fba53194f.
Report an issue: GitHub.