quantax.optimizer.SupervisedAdam#
- class quantax.optimizer.SupervisedAdam#
Bases:
StochasticQNGDSupervised optimization towards a target state with the Adam-like update of
AdamSR.- __init__(state: Variational, target_state: State, solver: Callable[[Array, Array], Array] | None = None, file: str | Path | BinaryIO | None = None, clip: float | None = None, mu: float = 0.95, beta: float = 0.995, norm_clip: float | None = None)#
- Parameters:
state – Variational state to be optimized.
target_state – The target state to be approximated.
solver – The numerical solver for the matrix inverse, default to
auto_shift_eig.file – The file with stored buffers of the optimizer.
clip – The clipping value of the centered amplitude ratios, default to no clipping.
mu – The first order momentum factor.
beta – The second order momentum factor.
norm_clip – The maximum norm of the step to be accumulated. If not None, the raw step will be clipped to this value.
- property VarE: Array | ndarray | bool | number | bool | int | float | complex | None#
Energy variance \(\left< (H - E)^2 \right>\) of the current step,
Nonewhen the gradient source doesn’t define it.
- property energy: Array | ndarray | bool | number | bool | int | float | complex | None#
Energy of the current step,
Nonewhen the gradient source doesn’t define it.
- get_Ebar(samples: Samples | Array) Array#
Compute \(\bar \epsilon\) of the gradient source for given samples.
- get_Obar(samples: Samples | Array) Array#
Calculate \(\bar O = \frac{1}{\sqrt{N_s}}(\frac{1}{\psi} \frac{\partial \psi}{\partial \theta} - \left< \frac{1}{\psi} \frac{\partial \psi}{\partial \theta} \right>)\) for given samples.
- get_step(samples: Samples | Array) Array#
Obtain the optimization step by solving the equation \(\bar O \dot \theta = \bar \epsilon\) for given samples.
- property hamiltonian: Operator | None#
The Hamiltonian for the evolution,
Nonewhen the gradient source doesn’t define it.
- property holomorphic: bool#
Whether the state is holomorphic.
- property imag_time: bool#
Whether to use imaginary-time evolution.
- save(file: str | Path | BinaryIO) None#
Save the optimizer buffers to a file.
- solve(Obar: Array, Ebar: Array, buffers: dict) tuple[Array, dict]#
Generate the optimization step for given \(\bar O\) and \(\bar \epsilon\) by applying the updater strategy around
solve_equation.
- solve_equation(Obar: Array, Ebar: Array, **solver_kwargs) Array#
Solve the linear equation \(\bar O \dot \theta = \bar \epsilon\) for given \(\bar O\) and \(\bar \epsilon\). Real and imaginary parts are stacked for non-holomorphic states, and extra keyword arguments are forwarded to the numerical solver.
A
diag_preconditionerkeyword is handled here: if the solver declares it as an argument (e.g.lsmr), it is passed through; otherwise the right preconditioning is emulated by solving with \(\bar O / d\) and rescaling the output by \(1 / d\).
- property state: Variational#
Variational state to be optimized.