Skip to content

Commit

Permalink
[opt/pgd] Tell user when auto-inference breaks down.
Browse files Browse the repository at this point in the history
  • Loading branch information
SepandKashani committed Mar 28, 2024
1 parent c42d77d commit 47d8fba
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pyxu/opt/solver/pgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ def m_init(

if tau is None:
mst["tau"] = pxrt.coerce(1 / self._f.diff_lipschitz)
if math.isclose(mst["tau"], 0):
# _f does not provide any "useful" diff_lipschitz constant.
msg = "\n".join(
[
"No useful step size could be auto-determined from Parameter[f].",
"Consider initializing Parameter[tau] directly, or set (an estimate of) the diff-Lipschitz constant of Parameter[f] before calling fit().",
"Solver iterations as-is may stagnate.",
]
)
warnings.warn(msg, pxw.AutoInferenceWarning)
if math.isinf(mst["tau"]):
# _f is constant-valued: \tau is a free parameter.
mst["tau"] = 1
Expand Down

0 comments on commit 47d8fba

Please sign in to comment.