quara.minimization_algorithm.projected_gradient_descent_with_momentum module

class ProjectedGradientDescentWithMomentum(func_proj=None)[source]

Bases: quara.minimization_algorithm.projected_gradient_descent.ProjectedGradientDescent

This algorithm is based on the following paper:

Eliot Bolduc, George C. Knee, Erik M. Gauger & Jonathan Leach, “Projected gradient descent algorithms for quantum state tomography”,

Warning

This is an experimental implementation. It is not recommended to use this because of its poor accuracy when the maximum number of iterations is exceeded.

Constructor

Parameters

func_proj (Callable[[np.ndarray], np.ndarray], optional) – function of projection, by default None

is_loss_sufficient()[source]

returns whether the loss is sufficient.

Returns

whether the loss is sufficient.

Return type

bool

is_option_sufficient()[source]

returns whether the option is sufficient.

Returns

whether the option is sufficient.

Return type

bool

optimize(loss_function, loss_function_option, algorithm_option, on_iteration_history=False)[source]

optimizes using specified parameters.

Parameters
Returns

the result of the optimization.

Return type

ProjectedGradientDescentWithMomentumResult

Raises
  • ValueError – when on_value of loss_function is False.

  • ValueError – when on_gradient of loss_function is False.

class ProjectedGradientDescentWithMomentumOption(on_algo_eq_constraint=True, on_algo_ineq_constraint=True, var_start=None, max_iteration_optimization=1000, max_iteration_proj_physical=100000, r=2.0, moment_0=None, mode_stopping_criterion_gradient_descent='single_difference_loss', num_history_stopping_criterion_gradient_descent=1, mode_proj_order='eq_ineq', eps=None)[source]

Bases: quara.minimization_algorithm.projected_gradient_descent.ProjectedGradientDescentOption

Constructor

Parameters
  • on_algo_eq_constraint (bool, optional) – whether this algorithm needs on algorithm equality constraint, by default True

  • on_algo_ineq_constraint (bool, optional) – whether this algorithm needs on algorithm inequality constraint, by default True

  • var_start (np.ndarray, optional) – initial variable for the algorithm, by default None

  • max_iteration_optimization (int, optional) – maximun number of iterations of optimization, by default 1000.

  • max_iteration_proj_physical (int, optional) – maximun number of iterations of projection to physical, by default 100000.

  • r (float, optional) – algorithm option r, by default 2.0

  • moment_0 (List[float], optional) – algorithm option moment_0, by default None

  • mode_stopping_criterion_gradient_descent (str, optional) – mode of stopping criterion for gradient descent, by default “single_difference_loss”

  • num_history_stopping_criterion_gradient_descent (int, optional) – number of history to be used stopping criterion for gradient descent, by default 1 this must be a integer and greater than or equal to 1.

  • mode_proj_order (str, optional) – the order in which the projections are performed, by default “eq_ineq”.

  • eps (float, optional) – algorithm option epsilon, by default None

property moment_0: List[float]

returns algorithm option moment_0.

Returns

algorithm option moment_0.

Return type

List[float]

property r: float

returns algorithm option r.

\(\gamma = \frac{1}{2r\sqrt{n}}\)

Returns

algorithm option r.

Return type

float

class ProjectedGradientDescentWithMomentumResult(value, computation_time=None, k=None, fx=None, x=None, moment=None, zeta=None, error_values=None)[source]

Bases: quara.minimization_algorithm.projected_gradient_descent.ProjectedGradientDescentResult

Constructor

Parameters
  • value (np.ndarray) – the result of the minimization.

  • computation_time (float, optional) – computation time for the minimization, by default None

  • k (int) –

  • fx (List[numpy.ndarray]) –

  • x (List[numpy.ndarray]) –

  • moment (List[numpy.ndarray]) –

  • zeta (List[float]) –

  • error_values (List[float]) –

property moment: List[numpy.ndarray]

return the moment per iteration.

Returns

the moment per iteration.

Return type

List[np.ndarray]

property zeta: List[numpy.ndarray]

return the zeta per iteration.

Returns

the zeta per iteration.

Return type

List[np.ndarray]