huggingface/pytorch-image-models · error · ValueError
Invalid beta parameter at index 0: {}
Error message
Invalid beta parameter at index 0: {} What it means
Raised by timm's Adan optimizer constructor when betas[0] (beta1, first-moment decay) is outside [0.0, 1.0). Adan uses three decay coefficients; all must be in [0, 1) for the bias-corrected moment estimates to be well-defined.
Source
Thrown at timm/optim/adan.py:78
foreach: If True would use torch._foreach implementation. Faster but uses slightly more memory.
"""
def __init__(self,
params,
lr: float = 1e-3,
betas: Tuple[float, float, float] = (0.98, 0.92, 0.99),
eps: float = 1e-8,
weight_decay: float = 0.0,
no_prox: bool = False,
caution: bool = False,
foreach: Optional[bool] = None,
):
if not 0.0 <= lr:
raise ValueError('Invalid learning rate: {}'.format(lr))
if not 0.0 <= eps:
raise ValueError('Invalid epsilon value: {}'.format(eps))
if not 0.0 <= betas[0] < 1.0:
raise ValueError('Invalid beta parameter at index 0: {}'.format(betas[0]))
if not 0.0 <= betas[1] < 1.0:
raise ValueError('Invalid beta parameter at index 1: {}'.format(betas[1]))
if not 0.0 <= betas[2] < 1.0:
raise ValueError('Invalid beta parameter at index 2: {}'.format(betas[2]))
defaults = dict(
lr=lr,
betas=betas,
eps=eps,
weight_decay=weight_decay,
no_prox=no_prox,
caution=caution,
foreach=foreach,
)
super().__init__(params, defaults)
def __setstate__(self, state):
super(Adan, self).__setstate__(state)View on GitHub (pinned to 9a5261e31b)
Solutions
- Set beta1 in [0.0, 1.0), typically 0.98 for Adan
- Verify the betas tuple has three values in the order (beta1, beta2, beta3)
- Check the YAML/CLI for typos in the betas list
Example fix
# before opt = timm.optim.Adan(model.parameters(), lr=1e-3, betas=(9.8, 0.99, 0.9)) # after opt = timm.optim.Adan(model.parameters(), lr=1e-3, betas=(0.98, 0.92, 0.99))
Defensive patterns
Strategy: validation
Validate before calling
assert len(betas) == 3 and all(0.0 <= b < 1.0 for b in betas), f'betas out of range: {betas}' Type guard
def valid_adan_betas(betas: tuple) -> bool:
return len(betas) == 3 and all(isinstance(b, (int, float)) and 0.0 <= b < 1.0 for b in betas) Prevention
- Remember Adan takes THREE betas unlike Adam's two
- Validate tuple length and range together
- Use the paper defaults (0.98, 0.92, 0.99) unless tuned
When it happens
Trigger: Calling timm.optim.Adan(params, betas=(b1, b2, b3)) where b1 < 0.0 or b1 >= 1.0, e.g. betas=(1.0, 0.99, 0.9).
Common situations: Config typo in the three-element betas tuple, or copying two-element Adam betas plus appending an out-of-range third value incorrectly; reordered tuple values.
Related errors
- Invalid learning rate: {}
- Invalid epsilon value: {}
- Invalid beta parameter at index 1: {}
- Invalid beta parameter at index 2: {}
- Invalid beta parameter at index 0: {}
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/b0e02ba1966204a7.
Report an issue: GitHub.