huggingface/pytorch-image-models · error · ValueError
Invalid epsilon value: {eps}
Error message
Invalid epsilon value: {eps} What it means
Raised by ADOPT's constructor when eps is negative. eps is added to denominators for numerical stability and must be >= 0.
Source
Thrown at timm/optim/adopt.py:91
corrected_weight_decay: bool = False,
*,
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,View on GitHub (pinned to 9a5261e31b)
Solutions
- Use a small non-negative eps, typically 1e-8
- Fix the YAML/CLI value bound to eps
Example fix
# before opt = timm.optim.Adopt(model.parameters(), lr=1e-3, eps=-1e-8) # after opt = timm.optim.Adopt(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
- Keep eps at the 1e-8 default
- Validate optimizer scalars centrally in config loading
When it happens
Trigger: Constructing timm.optim.Adopt(params, eps=-1e-8).
Common situations: Config typo on the eps key, or a sweep over log-spaced eps crossing zero.
Related errors
- Invalid learning rate: {lr}
- Invalid beta parameter at index 0: {betas[0]}
- 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/7d02ca9a7ab74cc5.
Report an issue: GitHub.