huggingface/pytorch-image-models · error · ValueError
Invalid epsilon value: {}
Error message
Invalid epsilon value: {} What it means
Raised by timm's Adan optimizer constructor when eps is negative. eps is the numerical-stability term added to denominators, so it must be >= 0.
Source
Thrown at timm/optim/adan.py:76
no_prox: How to perform the weight decay
caution: Enable caution from 'Cautious Optimizers'
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)
View on GitHub (pinned to 9a5261e31b)
Solutions
- Use a small non-negative eps, typically 1e-8
- Check the config/CLI mapping that produced the negative eps
Example fix
# before opt = timm.optim.Adan(model.parameters(), lr=1e-3, eps=-1e-8) # after opt = timm.optim.Adan(model.parameters(), lr=1e-3, eps=1e-8)
Defensive patterns
Strategy: validation
Validate before calling
assert eps >= 0.0, f'eps must be >= 0, got {eps}' Type guard
def valid_eps(eps) -> bool:
return isinstance(eps, (int, float)) and eps >= 0.0 Prevention
- Default eps to 1e-8 and only override deliberately
- Validate all optimizer scalars in one helper
When it happens
Trigger: Calling timm.optim.Adan(params, eps=value) with value < 0.0.
Common situations: Typo in config (eps: -1e-8), or accidentally binding another hyperparameter's value into eps during a sweep.
Related errors
- Invalid learning rate: {}
- Invalid beta parameter at index 0: {}
- 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/50be02d0b224677d.
Report an issue: GitHub.