Unity-Technologies/ml-agents · error · TrainerConfigError
Minimum value is greater than maximum value in uniform sampl
Error message
Minimum value is greater than maximum value in uniform sampler.
What it means
UniformSamplerSettings is validated by an attrs validator that rejects configurations where min_value exceeds max_value, since a uniform distribution over an inverted range is undefined. The check runs whenever the settings object is constructed from the YAML config.
Source
Thrown at ml-agents/mlagents/trainers/settings.py:376
@attr.s(auto_attribs=True)
class UniformSettings(ParameterRandomizationSettings):
min_value: float = attr.ib()
max_value: float = 1.0
def __str__(self) -> str:
"""
Helper method to output sampler stats to console.
"""
return f"Uniform sampler: min={self.min_value}, max={self.max_value}"
@min_value.default
def _min_value_default(self):
return 0.0
@min_value.validator
def _check_min_value(self, attribute, value):
if self.min_value > self.max_value:
raise TrainerConfigError(
"Minimum value is greater than maximum value in uniform sampler."
)
def apply(self, key: str, env_channel: EnvironmentParametersChannel) -> None:
"""
Helper method to send sampler settings over EnvironmentParametersChannel
Calls the uniform sampler type set method.
:param key: environment parameter to be sampled
:param env_channel: The EnvironmentParametersChannel to communicate sampler settings to environment
"""
env_channel.set_uniform_sampler_parameters(
key, self.min_value, self.max_value, self.seed
)
@attr.s(auto_attribs=True)
class GaussianSettings(ParameterRandomizationSettings):
mean: float = 1.0View on GitHub (pinned to 3ecb446f75)
Solutions
- Swap min_value and max_value so min <= max.
- Lower min_value or raise max_value to restore a valid range.
- Add a pre-load config check that asserts min_value <= max_value for every uniform sampler.
Example fix
# before sampler_parameters: min_value: 5.0 max_value: 1.0 # after sampler_parameters: min_value: 1.0 max_value: 5.0
Defensive patterns
Strategy: validation
Validate before calling
sp = spec['sampler_parameters']
if sp['min_value'] > sp['max_value']:
raise ValueError('uniform sampler min_value must be <= max_value') Type guard
def is_valid_uniform_params(sp) -> bool:
return sp.get('min_value', 0) <= sp.get('max_value', 0) Try / catch
try:
sampler = UniformSamplerSettings(**sp)
except TrainerConfigError as e:
print(f'Fix sampler range: {e}')
sp['min_value'], sp['max_value'] = sorted([sp['min_value'], sp['max_value']]) Prevention
- Sanity-check all numeric ranges when editing configs
- Auto-swap min/max in a config preprocessing step
- Unit-test curriculum/sampler configs with a range assertion
When it happens
Trigger: Configuring a uniform sampler with `min_value` larger than `max_value`, e.g. {min_value: 5.0, max_value: 1.0}, in environment_parameters randomization.
Common situations: Swapping the two values when hand-editing, or changing max_value downward without updating min_value.
Related errors
- The sampling interval {interval} must contain exactly two va
- Minimum value is greater than maximum value in interval {int
- Unsupported parameter randomization configuration {d}.
- When using a recurrent network, memory size must be divisibl
- Unsupported reward signal configuration {d}.
AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02).
Data as JSON: /api/errors/0655a99b9bcc4e49.
Report an issue: GitHub.