Skip to content

liblaf.peach.optim.pncg

Preconditioned nonlinear conjugate-gradient optimizer.

Classes:

ConvergenceCriteria

Gradient-norm stopping criteria for Pncg.

Parameters:

  • max_steps (int, default: 1000 ) –
  • atol_primary (float, default: 0.0 ) –
  • rtol_primary (float, default: 1e-06 ) –
  • atol_secondary (float, default: <dynamic> ) –
  • rtol_secondary (float, default: <dynamic> ) –
  • patience (int, default: 20 ) –

Methods:

  • init

    Create an empty convergence state shaped like params.

  • primary_success

    Check the primary absolute-relative gradient tolerance.

  • secondary_success

    Check the looser secondary gradient tolerance.

  • terminate

    Return the convergence decision and result code.

  • update

    Record the current gradient and gradient norms.

Attributes:

atol_primary class-attribute instance-attribute

atol_primary: float = 0.0

atol_secondary class-attribute instance-attribute

atol_secondary: float = field(
    default=Factory(
        _default_atol_secondary, takes_self=True
    )
)

max_steps class-attribute instance-attribute

max_steps: int = 1000

patience class-attribute instance-attribute

patience: int = 20

rtol_primary class-attribute instance-attribute

rtol_primary: float = 1e-06

rtol_secondary class-attribute instance-attribute

rtol_secondary: float = field(
    default=Factory(
        _default_rtol_secondary, takes_self=True
    )
)

init

init() -> ConvergenceState

Create an empty convergence state shaped like params.

Source code in src/liblaf/peach/optim/pncg/_terminate.py
def init(self) -> ConvergenceState:
    """Create an empty convergence state shaped like `params`."""
    return ConvergenceState()

primary_success

primary_success(
    state: ConvergenceState,
) -> Bool[Tensor, ""]

Check the primary absolute-relative gradient tolerance.

Source code in src/liblaf/peach/optim/pncg/_terminate.py
def primary_success(self, state: ConvergenceState) -> Bool[Tensor, ""]:
    """Check the primary absolute-relative gradient tolerance."""
    return state.grad_norm <= max(
        self.atol_primary, self.rtol_primary * state.grad_norm_first
    )

secondary_success

secondary_success(
    state: ConvergenceState,
) -> Bool[Tensor, ""]

Check the looser secondary gradient tolerance.

Source code in src/liblaf/peach/optim/pncg/_terminate.py
def secondary_success(self, state: ConvergenceState) -> Bool[Tensor, ""]:
    """Check the looser secondary gradient tolerance."""
    return state.grad_norm <= max(
        self.atol_secondary, self.rtol_secondary * state.grad_norm_first
    )

terminate

terminate(state: ConvergenceState) -> tuple[bool, Result]

Return the convergence decision and result code.

Source code in src/liblaf/peach/optim/pncg/_terminate.py
def terminate(self, state: ConvergenceState) -> tuple[bool, Result]:
    """Return the convergence decision and result code."""
    if state.step < self.max_steps:
        if self.primary_success(state):
            return True, Result.PRIMARY_SUCCESS
        if state.stagnation_count > self.patience:
            return True, Result.STAGNATION
        return False, Result.INTERRUPT
    if self.secondary_success(state):
        return True, Result.SECONDARY_SUCCESS
    return True, Result.MAX_STEPS_REACHED

update

update(
    state: ConvergenceState,
    g: Vector,
    *,
    line_search_ok: bool,
) -> ConvergenceState

Record the current gradient and gradient norms.

Source code in src/liblaf/peach/optim/pncg/_terminate.py
def update(
    self, state: ConvergenceState, g: Vector, *, line_search_ok: bool
) -> ConvergenceState:
    """Record the current gradient and gradient norms."""
    grad_norm: Scalar = torch.linalg.vector_norm(g)
    if state.step == 0:
        state.grad_norm_first = grad_norm
    if line_search_ok:
        state.stagnation_count = 0
    else:
        state.stagnation_count += 1
    state.grad_norm = grad_norm
    state.step += 1
    return state

ConvergenceState

Gradient-norm convergence state.

Parameters:

  • grad_norm (Scalar, default: None ) –
  • grad_norm_first (Scalar, default: None ) –
  • stagnation_count (int, default: 0 ) –
  • step (int, default: 0 ) –

Attributes:

grad_norm class-attribute instance-attribute

grad_norm: Scalar = field(default=None)

grad_norm_first class-attribute instance-attribute

grad_norm_first: Scalar = field(default=None)

stagnation_count class-attribute instance-attribute

stagnation_count: int = 0

step class-attribute instance-attribute

step: int = 0

DirectionUpdate

Dai-Kou nonlinear conjugate-gradient direction update.

Methods:

  • __call__

    Compute a descent direction, restarting when requested.

__call__

__call__(
    g: Vector,
    g_prev: Vector,
    P: Vector,
    p_prev: Vector,
    *,
    restart: bool = False,
) -> Vector

Compute a descent direction, restarting when requested.

Source code in src/liblaf/peach/optim/pncg/_direction.py
def __call__(
    self,
    g: Vector,
    g_prev: Vector,
    P: Vector,
    p_prev: Vector,
    *,
    restart: bool = False,
) -> Vector:
    """Compute a descent direction, restarting when requested."""
    if restart:
        return -P * g
    beta: Scalar = dai_kou_plus(g=g, g_prev=g_prev, P=P, p_prev=p_prev)
    Pg: Vector = -P * g
    p: Vector = Pg + beta * p_prev
    return torch.where(torch.dot(p, g) < 0.0, p, Pg)

HessianDamping

Adaptive Levenberg-style diagonal Hessian damping.

Parameters:

  • initial (float, default: 0.0 ) –
  • factor_max (float, default: <dynamic> ) –
  • factor_min (float, default: <dynamic> ) –

Methods:

  • hess_diag

    Return abs(H_diag) + factor * mean(abs(H_diag)).

  • hess_quad

    Add the damping contribution to a Hessian quadratic form.

  • init

    Create damping state with the initial factor.

  • update

    Adapt the damping factor from line-search behavior.

Attributes:

factor_max class-attribute instance-attribute

factor_max: float = field(
    default=Factory(_default_factor_max, takes_self=True)
)

factor_min class-attribute instance-attribute

factor_min: float = field(
    default=Factory(_default_factor_min, takes_self=True)
)

initial class-attribute instance-attribute

initial: float = 0.0

hess_diag

hess_diag(
    state: HessianDampingState, H_diag: Vector
) -> Vector

Return abs(H_diag) + factor * mean(abs(H_diag)).

Source code in src/liblaf/peach/optim/pncg/_hess_damping.py
def hess_diag(self, state: HessianDampingState, H_diag: Vector) -> Vector:
    """Return `abs(H_diag) + factor * mean(abs(H_diag))`."""
    H_diag: Vector = torch.abs(H_diag)
    H_diag_mean: Scalar = torch.mean(H_diag)
    state.hess_diag_mean = H_diag_mean
    return H_diag + state.factor * H_diag_mean

hess_quad

hess_quad(
    state: HessianDampingState, p: Vector, pHp: Scalar
) -> Scalar

Add the damping contribution to a Hessian quadratic form.

Source code in src/liblaf/peach/optim/pncg/_hess_damping.py
def hess_quad(self, state: HessianDampingState, p: Vector, pHp: Scalar) -> Scalar:
    """Add the damping contribution to a Hessian quadratic form."""
    return pHp + state.factor * state.hess_diag_mean * torch.dot(p, p)

init

init() -> HessianDampingState

Create damping state with the initial factor.

Source code in src/liblaf/peach/optim/pncg/_hess_damping.py
def init(self) -> HessianDampingState:
    """Create damping state with the initial factor."""
    return HessianDampingState(factor=self.initial)

update

update(
    state: HessianDampingState,
    *,
    actual_decrease: Scalar,
    line_search_step: int,
    predicted_decrease: Scalar,
) -> None

Adapt the damping factor from line-search behavior.

Source code in src/liblaf/peach/optim/pncg/_hess_damping.py
def update(
    self,
    state: HessianDampingState,
    *,
    actual_decrease: Scalar,
    line_search_step: int,
    predicted_decrease: Scalar,
) -> None:
    """Adapt the damping factor from line-search behavior."""
    factor: float = state.factor
    if line_search_step == 0 and actual_decrease > predicted_decrease:
        factor *= 0.5
    else:
        factor *= (line_search_step + 1) ** 2
    state.factor = min(max(factor, self.factor_min), self.factor_max)

LineSearch

Armijo backtracking with Newton, norm, and problem-specific step bounds.

Parameters:

  • armijo (float, default: 0.0001 ) –
  • max_step_norm (float, default: inf ) –
  • max_steps (int, default: 10 ) –

Methods:

  • __call__

    Run line search along direction p from params.

  • armijo_condition

    Evaluate the Armijo sufficient-decrease condition.

  • init

    Create an empty line-search state.

  • line_search_newton

    Return the Newton step length or 1.0 when curvature is unsuitable.

  • line_search_upper

    Return the largest step satisfying the infinity-norm bound.

Attributes:

armijo class-attribute instance-attribute

armijo: float = field(default=0.0001)

max_step_norm class-attribute instance-attribute

max_step_norm: float = field(default=inf)

max_steps class-attribute instance-attribute

max_steps: int = field(default=10)

__call__

__call__[X](
    state: LineSearchState,
    problem: Problem[X],
    model_state: X,
    m: Scalar,
    p: Vector,
    params: Vector,
    pHp: Scalar,
) -> None

Run line search along direction p from params.

The initial step length is the smaller of the Newton proposal and the configured infinity-norm bound. If the problem implements Problem.max_step_size, that hook receives the proposed displacement alpha * p and returns a safe fraction of it. Every accepted or rejected trial is materialized through Problem.update.

Source code in src/liblaf/peach/optim/pncg/_line_search.py
def __call__[X](
    self,
    state: LineSearchState,
    problem: Problem[X],
    model_state: X,
    m: Scalar,
    p: Vector,
    params: Vector,
    pHp: Scalar,
) -> None:
    """Run line search along direction `p` from `params`.

    The initial step length is the smaller of the Newton proposal and the
    configured infinity-norm bound. If the problem implements
    [`Problem.max_step_size`][liblaf.peach.optim.base.Problem.max_step_size],
    that hook receives the proposed displacement `alpha * p` and returns a
    safe fraction of it. Every accepted or rejected trial is materialized
    through [`Problem.update`][liblaf.peach.optim.base.Problem.update].
    """
    alpha_upper: Scalar = self.line_search_upper(
        p=p, max_step_norm=self.max_step_norm
    )
    alpha_newton: Scalar = self.line_search_newton(m=m, pHp=pHp)
    alpha: Scalar = torch.minimum(alpha_upper, alpha_newton)
    if is_implemented(problem, Problem.max_step_size):
        step_fraction: Scalar = problem.max_step_size(model_state, alpha * p)
        step_fraction: Scalar = torch.as_tensor(step_fraction)
        alpha *= torch.clamp(step_fraction, 0.0, 1.0)

    f0: Scalar = state.f_alpha
    for step in range(self.max_steps + 1):
        if step > 0:
            alpha *= 0.5
        problem.update(model_state, params + alpha * p)
        f_alpha: Scalar = problem.fun(model_state)
        if self.armijo_condition(f_alpha=f_alpha, f0=f0, alpha=alpha, m=m):
            state.ok = True
            break
    else:
        state.ok = False
    state.alpha = alpha
    state.f_alpha = f_alpha
    state.f0 = f0
    state.step = step

armijo_condition

armijo_condition(
    f_alpha: Scalar, f0: Scalar, alpha: Scalar, m: Scalar
) -> Bool[Tensor, ""]

Evaluate the Armijo sufficient-decrease condition.

Source code in src/liblaf/peach/optim/pncg/_line_search.py
def armijo_condition(
    self, f_alpha: Scalar, f0: Scalar, alpha: Scalar, m: Scalar
) -> Bool[Tensor, ""]:
    """Evaluate the Armijo sufficient-decrease condition."""
    return f_alpha <= f0 + alpha * self.armijo * m

init

init(fun: Scalar) -> LineSearchState

Create an empty line-search state.

Source code in src/liblaf/peach/optim/pncg/_line_search.py
def init(self, fun: Scalar) -> LineSearchState:
    """Create an empty line-search state."""
    return LineSearchState(f_alpha=fun)

line_search_newton staticmethod

line_search_newton(m: Scalar, pHp: Scalar) -> Scalar

Return the Newton step length or 1.0 when curvature is unsuitable.

Source code in src/liblaf/peach/optim/pncg/_line_search.py
@staticmethod
def line_search_newton(m: Scalar, pHp: Scalar) -> Scalar:
    """Return the Newton step length or `1.0` when curvature is unsuitable."""
    alpha: Scalar = -m / pHp
    return torch.where((pHp <= 0.0) | (m >= 0.0), 1.0, alpha)

line_search_upper staticmethod

line_search_upper(
    p: Vector, max_step_norm: float
) -> Scalar

Return the largest step satisfying the infinity-norm bound.

Source code in src/liblaf/peach/optim/pncg/_line_search.py
@staticmethod
def line_search_upper(p: Vector, max_step_norm: float) -> Scalar:
    """Return the largest step satisfying the infinity-norm bound."""
    if not math.isfinite(max_step_norm):
        return torch.as_tensor(torch.inf)
    p_norm: Scalar = torch.linalg.vector_norm(p, ord=torch.inf)
    return torch.where(p_norm == 0.0, 0.0, max_step_norm / p_norm)

Pncg

Bases: Optimizer[PncgState, PncgStats]


              flowchart TD
              liblaf.peach.optim.pncg.Pncg[Pncg]
              liblaf.peach.optim.base._optimizer.Optimizer[Optimizer]

                              liblaf.peach.optim.base._optimizer.Optimizer --> liblaf.peach.optim.pncg.Pncg
                


              click liblaf.peach.optim.pncg.Pncg href "" "liblaf.peach.optim.pncg.Pncg"
              click liblaf.peach.optim.base._optimizer.Optimizer href "" "liblaf.peach.optim.base._optimizer.Optimizer"
            

Preconditioned nonlinear conjugate-gradient optimizer.

Pncg builds a diagonal preconditioner from a damped Hessian diagonal, computes a Dai-Kou conjugate-gradient direction, and accepts steps with Armijo backtracking. Accepted line-search trials mutate the model state in place, so each call to step expects model_state to already match opt_state.params.

Examples:

Minimize a one-dimensional quadratic objective.

>>> import torch
>>> class QuadraticProblem:
...     def __init__(self, target):
...         self.target = target
...
...     def update(self, state, params, /):
...         state.copy_(params)
...
...     def fun(self, state, /):
...         residual = state - self.target
...         return 0.5 * torch.dot(residual, residual)
...
...     def grad(self, state, /):
...         return state - self.target
...
...     def hess_diag(self, state, /):
...         return torch.ones_like(state)
...
...     def hess_quad(self, state, direction, /):
...         return torch.dot(direction, direction)
>>> problem = QuadraticProblem(target=torch.tensor([3.0]))
>>> params = torch.tensor([0.0])
>>> model_state = params.clone()
>>> solution = Pncg().minimize(problem, model_state, params)
>>> bool(solution.success)
True
>>> torch.testing.assert_close(solution.params, torch.tensor([3.0]))
>>> torch.testing.assert_close(model_state, solution.params)

Parameters:

  • criteria (ConvergenceCriteria, default: <dynamic> ) –

    Gradient-norm stopping criteria for Pncg.

  • direction (DirectionUpdate, default: DirectionUpdate() ) –

    Dai-Kou nonlinear conjugate-gradient direction update.

  • hess_damping (HessianDamping, default: <dynamic> ) –

    Adaptive Levenberg-style diagonal Hessian damping.

  • line_search (LineSearch, default: <dynamic> ) –

    Armijo backtracking with Newton, norm, and problem-specific step bounds.

Type Aliases:

Classes:

  • Result

    Result code returned by optimizers.

Methods:

  • init

    Initialize Pncg state.

  • minimize

    Run optimization until the configured termination rule stops.

  • postprocess

    Build a Pncg solution object.

  • step

    Run one Pncg step.

  • terminate

    Delegate stopping to the configured convergence criteria.

Attributes:

criteria class-attribute instance-attribute

criteria: ConvergenceCriteria = field(
    factory=ConvergenceCriteria
)

direction class-attribute instance-attribute

direction: DirectionUpdate = field(factory=DirectionUpdate)

hess_damping class-attribute instance-attribute

hess_damping: HessianDamping = field(factory=HessianDamping)
line_search: LineSearch = field(factory=LineSearch)

Solution

Optimizer output bundle.

Parameters:

  • result (Result) –
  • state (S) –
  • stats (T) –

Result

Bases: StrEnum


              flowchart TD
              liblaf.peach.optim.pncg.Pncg.Result[Result]

              

              click liblaf.peach.optim.pncg.Pncg.Result href "" "liblaf.peach.optim.pncg.Pncg.Result"
            

Result code returned by optimizers.

Attributes:

INTERRUPT class-attribute instance-attribute

INTERRUPT = auto()

MAX_STEPS_REACHED class-attribute instance-attribute

MAX_STEPS_REACHED = auto()

NAN class-attribute instance-attribute

NAN = auto()

PRIMARY_SUCCESS class-attribute instance-attribute

PRIMARY_SUCCESS = auto()

SECONDARY_SUCCESS class-attribute instance-attribute

SECONDARY_SUCCESS = auto()

STAGNATION class-attribute instance-attribute

STAGNATION = auto()

SUCCESS class-attribute instance-attribute

SUCCESS = auto()

UNKNOWN_ERROR class-attribute instance-attribute

UNKNOWN_ERROR = auto()

success property

success: bool

Whether the result represents an accepted optimization outcome.

init

init[X](
    problem: BaseProblem[X],
    model_state: X,
    params: Vector,
) -> PncgState

Initialize Pncg state.

The stored parameter vector is cloned from params; subsequent steps mutate the clone instead of the caller-owned input tensor.

Source code in src/liblaf/peach/optim/pncg/_pncg.py
@override
def init[X](self, problem: BaseProblem[X], model_state: X, params: Vector) -> State:
    """Initialize `Pncg` state.

    The stored parameter vector is cloned from `params`; subsequent steps
    mutate the clone instead of the caller-owned input tensor.
    """
    problem: Problem[X] = cast("Problem[X]", problem)
    fun: Scalar = problem.fun(model_state)
    return self.State(
        fun=fun,
        params=params.clone(),
        convergence_state=self.criteria.init(),
        hess_damping_state=self.hess_damping.init(),
        line_search_state=self.line_search.init(fun=fun),
    )

minimize

minimize[X](
    problem: BaseProblem[X],
    model_state: X,
    params: Vector,
) -> Solution[S, T]

Run optimization until the configured termination rule stops.

After every step, Problem.callback is called when the concrete problem implements it. The callback receives the current model state and the same mutable optimizer state that will be stored on the returned Solution.

Parameters:

  • problem (BaseProblem[X]) –

    Optimization problem that supplies objective hooks.

  • model_state (X) –

    Initial model state used by objective hooks.

  • params (Vector) –

    Initial optimizer parameter vector.

Returns:

  • Solution[S, T]

    The final solution.

Source code in src/liblaf/peach/optim/base/_optimizer.py
def minimize[X](
    self, problem: BaseProblem[X], model_state: X, params: Vector
) -> Solution[S, T]:
    """Run optimization until the configured termination rule stops.

    After every step, [`Problem.callback`][liblaf.peach.optim.base.Problem.callback]
    is called when the concrete problem implements it. The callback receives
    the current model state and the same mutable optimizer state that will be
    stored on the returned [`Solution`][liblaf.peach.optim.base.Solution].

    Args:
        problem: Optimization problem that supplies objective hooks.
        model_state: Initial model state used by objective hooks.
        params: Initial optimizer parameter vector.

    Returns:
        The final solution.
    """
    problem: Problem[X] = cast("Problem[X]", problem)
    opt_state: S = self.init(problem, model_state, params)
    while True:
        self.step(problem, model_state, opt_state)
        if is_implemented(problem, Problem.callback):
            problem.callback(model_state, opt_state)
        ok, result = self.terminate(problem, model_state, opt_state)
        if ok:
            break
    solution: Solution[S, T] = self.postprocess(
        problem, model_state, opt_state, result
    )
    return solution

postprocess

postprocess[X](
    problem: BaseProblem[X],
    model_state: X,
    opt_state: PncgState,
    result: Result,
) -> Solution

Build a Pncg solution object.

Source code in src/liblaf/peach/optim/pncg/_pncg.py
@override
def postprocess[X](
    self, problem: BaseProblem[X], model_state: X, opt_state: State, result: Result
) -> Solution:
    """Build a `Pncg` solution object."""
    stats: Pncg.Stats = self.Stats()
    return Solution(result=result, state=opt_state, stats=stats)

step

step[X](
    problem: BaseProblem[X],
    model_state: X,
    opt_state: PncgState,
) -> None

Run one Pncg step.

The method evaluates derivatives at model_state, writes the accepted direction, slope, Hessian diagnostics, line-search diagnostics, and parameter update into opt_state, then mutates model_state to the accepted trial.

Source code in src/liblaf/peach/optim/pncg/_pncg.py
@override
def step[X](
    self, problem: BaseProblem[X], model_state: X, opt_state: State
) -> None:
    """Run one `Pncg` step.

    The method evaluates derivatives at `model_state`, writes the accepted
    direction, slope, Hessian diagnostics, line-search diagnostics, and
    parameter update into `opt_state`, then mutates `model_state` to the
    accepted trial.
    """
    problem: Problem[X] = cast("Problem[X]", problem)

    g: Vector = problem.grad(model_state)
    H_diag: Vector = problem.hess_diag(model_state)
    H_diag_damp: Vector = self.hess_damping.hess_diag(
        state=opt_state.hess_damping_state, H_diag=H_diag
    )
    P: Vector = torch.reciprocal(H_diag_damp)

    p: Vector = self.direction(
        g=g,
        g_prev=opt_state.grad,
        P=P,
        p_prev=opt_state.direction,
        restart=opt_state.step == 0 or not opt_state.line_search_state.ok,
    )
    opt_state.direction = p
    opt_state.grad = g
    opt_state.hess_diag = H_diag
    slope: Scalar = torch.dot(g, p)
    opt_state.slope = slope

    pHp: Scalar = problem.hess_quad(model_state, p)
    opt_state.hess_quad = pHp
    pHp_damp: Scalar = self.hess_damping.hess_quad(
        state=opt_state.hess_damping_state, p=p, pHp=pHp
    )
    self.line_search(
        opt_state.line_search_state,
        problem=problem,
        model_state=model_state,
        m=slope,
        p=p,
        params=opt_state.params,
        pHp=pHp_damp,
    )
    ls_state: Pncg.LineSearchState = opt_state.line_search_state
    opt_state.fun = ls_state.f_alpha

    alpha: Scalar = ls_state.alpha
    actual_decrease: Scalar = ls_state.f0 - ls_state.f_alpha
    predicted_decrease: Scalar = -alpha * slope - 0.5 * alpha**2 * pHp_damp
    self.hess_damping.update(
        opt_state.hess_damping_state,
        actual_decrease=actual_decrease,
        line_search_step=ls_state.step,
        predicted_decrease=predicted_decrease,
    )

    self.criteria.update(
        opt_state.convergence_state, g=g, line_search_ok=ls_state.ok
    )

    opt_state.params += alpha * p

terminate

terminate[X](
    problem: BaseProblem[X],
    model_state: X,
    opt_state: PncgState,
) -> tuple[bool, Result]

Delegate stopping to the configured convergence criteria.

Source code in src/liblaf/peach/optim/pncg/_pncg.py
@override
def terminate[X](
    self, problem: BaseProblem[X], model_state: X, opt_state: State
) -> tuple[bool, Result]:
    """Delegate stopping to the configured convergence criteria."""
    return self.criteria.terminate(opt_state.convergence_state)

PncgState

Bases: State


              flowchart TD
              liblaf.peach.optim.pncg.PncgState[PncgState]
              liblaf.peach.optim.base._protocols.State[State]

                              liblaf.peach.optim.base._protocols.State --> liblaf.peach.optim.pncg.PncgState
                


              click liblaf.peach.optim.pncg.PncgState href "" "liblaf.peach.optim.pncg.PncgState"
              click liblaf.peach.optim.base._protocols.State href "" "liblaf.peach.optim.base._protocols.State"
            

State tracked by Pncg.

Parameters:

  • fun (Scalar) –
  • params (Vector) –

    Current optimizer parameters.

  • convergence_state (ConvergenceState) –
  • hess_damping_state (HessianDampingState) –
  • line_search_state (LineSearchState) –
  • direction (Vector, default: None ) –
  • grad (Vector, default: None ) –
  • hess_diag (Vector, default: None ) –
  • hess_quad (Vector, default: None ) –
  • slope (Vector, default: None ) –

Attributes:

convergence_state instance-attribute

convergence_state: ConvergenceState

direction class-attribute instance-attribute

direction: Vector = field(default=None)

fun instance-attribute

fun: Scalar

grad class-attribute instance-attribute

grad: Vector = field(default=None)

hess_damping_state instance-attribute

hess_damping_state: HessianDampingState

hess_diag class-attribute instance-attribute

hess_diag: Vector = field(default=None)

hess_quad class-attribute instance-attribute

hess_quad: Vector = field(default=None)

line_search_state instance-attribute

line_search_state: LineSearchState

params instance-attribute

params: Vector

Current optimizer parameters.

slope class-attribute instance-attribute

slope: Vector = field(default=None)

step property

step: int

PncgStats

Bases: Stats


              flowchart TD
              liblaf.peach.optim.pncg.PncgStats[PncgStats]
              liblaf.peach.optim.base._protocols.Stats[Stats]

                              liblaf.peach.optim.base._protocols.Stats --> liblaf.peach.optim.pncg.PncgStats
                


              click liblaf.peach.optim.pncg.PncgStats href "" "liblaf.peach.optim.pncg.PncgStats"
              click liblaf.peach.optim.base._protocols.Stats href "" "liblaf.peach.optim.base._protocols.Stats"
            

Stats placeholder for Pncg.