GradientNormPanel#
- class lumopt2.utils.panels.GradientNormPanel(title: str | None = 'Gradient Norm', auto_log: bool = True, color: str = 'C3', marker: str = 's', linewidth: float = 2.0, markersize: float = 4.0)#
Live plot of the gradient L2 norm vs. iteration.
Renders a single line that auto-switches to a logarithmic y-axis once every observed gradient norm is strictly positive (the typical case for converging runs). Iterations without gradient data appear as
nanand matplotlib draws gaps for them, so the panel works transparently for gradient-free optimizers - it simply re-titles itself to'<title> (N/A)'until a gradient shows up.- Attributes:
- title
str,optional Panel title (default:
'Gradient Norm').- auto_logbool,
optional If
True, switch to a logarithmic y-axis whenever every non-NaN gradient norm is strictly positive. Set toFalseto force a linear scale (default:True).- color
str,optional Matplotlib color spec for the trace (default:
'C3').- marker
str,optional Matplotlib marker for the trace (default:
's').- linewidth
float,optional Line width for the trace (default:
2.0).- markersize
float,optional Marker size for the trace (default:
4.0).
- title
Methods
Optional hook called once when the optimization completes.
GradientNormPanel.setup(ax, fig, project)Create the persistent gradient-norm line on
ax.GradientNormPanel.update(ax, fig, project, state)Push the latest gradient-norm history into the persistent line.
Attributes