huggingface/pytorch-image-models · error · ValueError
Invalid epsilon value: {eps}
Error message
Invalid epsilon value: {eps} What it means
NAdamW optimizer constructor validation: epsilon must satisfy 0.0 <= eps. Negative epsilon is rejected because it would break the sqrt(v)+eps denominator computation.
Source
Thrown at timm/optim/nadamw.py:58
"""
def __init__(
self,
params: ParamsT,
lr: float = 1e-3,
betas: Tuple[float, float] = (0.9, 0.999),
eps: float = 1e-8,
weight_decay: float = 1e-2,
caution: bool = False,
corrected_weight_decay: bool = False,
maximize: bool = False,
foreach: Optional[bool] = None,
capturable: bool = False,
):
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,
caution=caution,
corrected_weight_decay=corrected_weight_decay,
foreach=foreach,
maximize=maximize,
capturable=capturable,
)
super().__init__(params, defaults)View on GitHub (pinned to 9a5261e31b)
Solutions
- Use a positive eps like 1e-8 (the default)
- Audit config files for sign errors on numerical stability constants
Example fix
# before opt = NAdamW(model.parameters(), eps=-1e-8) # after opt = NAdamW(model.parameters(), eps=1e-8)
Defensive patterns
Strategy: validation
Validate before calling
assert eps >= 0.0
Prevention
- Rely on default eps unless needed
- Sanity check config diffs for sign errors
When it happens
Trigger: Calling timm.optim.NAdamW(params, eps=-1e-8) or any negative epsilon value.
Common situations: Config typo on eps, or eps accidentally set from another parameter's value during refactoring.
Related errors
- Invalid learning rate: {lr}
- Invalid beta parameter at index 0: {betas[0]}
- Invalid beta parameter at index 1: {betas[1]}
- Invalid weight_decay value: {weight_decay}
- Invalid epsilon value: {}
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/acdc7aca2272fbea.
Report an issue: GitHub.