jax-ml/jax · error · ValueError
Method {method} not recognized
Error message
Method {method} not recognized What it means
jax.scipy.optimize.minimize only ships a small set of methods (BFGS and L-BFGS and a few others handled above the raise); any unrecognized method string falls through to this ValueError.
Source
Thrown at jax/_src/scipy/optimize/minimize.py:133
hess_inv=results.H_k,
nfev=results.nfev,
njev=results.ngev,
nit=results.k)
if method.lower() == 'l-bfgs-experimental-do-not-rely-on-this':
results = _minimize_lbfgs(fun_with_args, x0, **options)
success = results.converged & jnp.logical_not(results.failed)
return OptimizeResults(x=results.x_k,
success=success,
status=results.status,
fun=results.f_k,
jac=results.g_k,
hess_inv=None,
nfev=results.nfev,
njev=results.ngev,
nit=results.k)
raise ValueError(f"Method {method} not recognized")
View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Use a supported method such as 'BFGS' or 'L-BFGS'
- If you need other algorithms, use jaxopt/optax optimizers instead
- Check the method string spelling/case against the dispatch branches
Example fix
# before res = minimize(loss, x0, method='Nelder-Mead') # after import optax # or res = minimize(loss, x0, method='BFGS')
Defensive patterns
Strategy: validation
Validate before calling
assert method.lower() in ('bfgs', 'l-bfgs', 'l-bfgs-experimental-do-not-rely-on-this'), method Type guard
def method_supported(m: str) -> bool: return m.lower() in ('bfgs', 'l-bfgs') Prevention
- Check the dispatch list in your jax version's minimize source
When it happens
Trigger: Passing method='Nelder-Mead', method='CG', method='Powell', or a typo like 'lbfgs ' (note: match is on exact strings per-branch, commonly lowercase).
Common situations: Porting scipy.optimize scripts expecting the full scipy method menu; jax supports only a subset.
Related errors
- args argument to jax.scipy.optimize.minimize must be a tuple
- ind must be a positive integer; got {ind=}
- Expected kind to be on of: {valid_kind}; got {kind}
- Expected kind to be one of: {valid_kind}; got {kind}
- n must be a positive power of 2; got {n}.
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/77ae085910cfe546.
Report an issue: GitHub.