huggingface/pytorch-image-models · error · ValueError
Invalid beta parameter at index 0: {betas[0]}
Error message
Invalid beta parameter at index 0: {betas[0]} What it means
Raised by ADOPT's constructor when betas[0] (beta1) is outside [0.0, 1.0). ADOPT's moment estimates require decay coefficients strictly below 1 to converge.
Source
Thrown at timm/optim/adopt.py:93
caution: bool = False,
foreach: Optional[bool] = False,
maximize: bool = False,
capturable: bool = False,
differentiable: bool = False,
):
if isinstance(lr, Tensor):
if foreach and not capturable:
raise ValueError(
"lr as a Tensor is not supported for capturable=False and foreach=True"
)
if lr.numel() != 1:
raise ValueError("Tensor lr must be 1-element")
if not 0.0 <= lr:
raise ValueError(f"Invalid learning rate: {lr}")
if not 0.0 <= eps:
raise ValueError(f"Invalid epsilon value: {eps}")
if not 0.0 <= betas[0] < 1.0:
raise ValueError(f"Invalid beta parameter at index 0: {betas[0]}")
if not 0.0 <= betas[1] < 1.0:
raise ValueError(f"Invalid beta parameter at index 1: {betas[1]}")
if not 0.0 <= weight_decay:
raise ValueError(f"Invalid weight_decay value: {weight_decay}")
defaults = dict(
lr=lr,
betas=betas,
eps=eps,
weight_decay=weight_decay,
clip_exp=clip_exp,
decoupled=decoupled,
corrected_weight_decay=corrected_weight_decay,
caution=caution,
maximize=maximize,
foreach=foreach,
capturable=capturable,
differentiable=differentiable,View on GitHub (pinned to 9a5261e31b)
Solutions
- Set beta1 in [0.0, 1.0), typically 0.9
- Verify betas tuple order (beta1, beta2) and values in your config
Example fix
# before opt = timm.optim.Adopt(model.parameters(), lr=1e-3, betas=(9.0, 0.99)) # after opt = timm.optim.Adopt(model.parameters(), lr=1e-3, betas=(0.9, 0.99))
Defensive patterns
Strategy: validation
Validate before calling
assert len(betas) == 2 and all(0.0 <= b < 1.0 for b in betas), f'betas out of range: {betas}' Type guard
def valid_adopt_betas(betas: tuple) -> bool:
return len(betas) == 2 and all(isinstance(b, (int, float)) and 0.0 <= b < 1.0 for b in betas) Prevention
- Validate betas before optimizer construction
- ADOPT defaults (0.9, 0.99) are usually fine; only change deliberately
When it happens
Trigger: Constructing timm.optim.Adopt(params, betas=(b1, b2)) with b1 < 0.0 or b1 >= 1.0, e.g. betas=(1.0, 0.99) or betas=(0.9*10, 0.99).
Common situations: Typo in a two-element betas tuple, or copying a paper's hyperparameters with the decimal point dropped.
Related errors
- Invalid learning rate: {lr}
- Invalid epsilon value: {eps}
- Invalid beta parameter at index 1: {betas[1]}
- Invalid beta parameter at index 0: {}
- Invalid beta parameter at index 1: {}
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/9c4a6fe06da5e256.
Report an issue: GitHub.