Closed
Description
In running pathfinder with a more complex generated model, I get the following error:
File ~/miniconda3/envs/salk/lib/python3.12/site-packages/pymc_extras/inference/pathfinder/lbfgs.py:190, in LBFGS.minimize(self, x0)
[188](https://file+.vscode-resource.vscode-cdn.net/home/velochy/salk/sandbox/debug/kov1-full_fix_package/~/miniconda3/envs/salk/lib/python3.12/site-packages/pymc_extras/inference/pathfinder/lbfgs.py:188) lbfgs_status = LBFGSStatus.CONVERGED
--> [190](https://file+.vscode-resource.vscode-cdn.net/home/velochy/salk/sandbox/debug/kov1-full_fix_package/~/miniconda3/envs/salk/lib/python3.12/site-packages/pymc_extras/inference/pathfinder/lbfgs.py:190) return history.x, history.g, history.count, lbfgs_status
UnboundLocalError: cannot access local variable 'lbfgs_status' where it is not associated with a value
Looking at the code in lbfgs.py
# warnings and suggestions for LBFGSStatus are displayed at the end
if result.status == 1:
lbfgs_status = LBFGSStatus.MAX_ITER_REACHED
elif (result.status == 2) or (history.count <= 1):
if result.nit <= 1:
lbfgs_status = LBFGSStatus.INIT_FAILED
elif result.fun == np.inf:
lbfgs_status = LBFGSStatus.DIVERGED
else:
lbfgs_status = LBFGSStatus.CONVERGED
return history.x, history.g, history.count, lbfgs_status
There is a clear gap in the status==2 block that is causing this, but I don't understand the lbfgs algorithm nearly well enough to know what status that gap should be filled with.
Metadata
Metadata
Assignees
Labels
No labels