skqulacs.qnn.solver module#

class skqulacs.qnn.solver.Adam(callback: Optional[Callable[[List[float]], NoneType]] = None, tolerance: float = 0.0001, n_iter_no_change: Optional[int] = None)[source]#

Bases: skqulacs.qnn.solver.Solver

callback: Optional[Callable[[List[float]], None]] = None#
n_iter_no_change: Optional[int] = None#
run(cost_func: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float], jac: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], theta: List[float], x: numpy.ndarray[Any, numpy.dtype[numpy.float64]], y: numpy.ndarray[Any, numpy.dtype[numpy.float64]], maxiter: Optional[int]) Tuple[float, List[float]][source]#

Run optimizer for given initial parameters and data.

Parameters
  • theta – Initial value of parameters to optimize.

  • x – Data to use in optimization.

  • y – Data to use in optimization.

  • maxiter – Maximum iteration count in optimization.

Returns

Loss and parameters after optimization.

Return type

(loss, theta_opt)

tolerance: float = 0.0001#
class skqulacs.qnn.solver.Bfgs[source]#

Bases: skqulacs.qnn.solver.Solver

run(cost_func: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float], jac: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], theta: List[float], x: numpy.ndarray[Any, numpy.dtype[numpy.float64]], y: numpy.ndarray[Any, numpy.dtype[numpy.float64]], maxiter: Optional[int]) Tuple[float, List[float]][source]#

Run optimizer for given initial parameters and data.

Parameters
  • theta – Initial value of parameters to optimize.

  • x – Data to use in optimization.

  • y – Data to use in optimization.

  • maxiter – Maximum iteration count in optimization.

Returns

Loss and parameters after optimization.

Return type

(loss, theta_opt)

class skqulacs.qnn.solver.GradientDescent[source]#

Bases: skqulacs.qnn.solver.Solver

run(cost_func: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float], jac: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], theta: List[float], x: numpy.ndarray[Any, numpy.dtype[numpy.float64]], y: numpy.ndarray[Any, numpy.dtype[numpy.float64]], lr: float = 0.1) Tuple[float, List[float]][source]#

Run optimizer for given initial parameters and data.

Parameters
  • theta – Initial value of parameters to optimize.

  • x – Data to use in optimization.

  • y – Data to use in optimization.

  • maxiter – Maximum iteration count in optimization.

Returns

Loss and parameters after optimization.

Return type

(loss, theta_opt)

class skqulacs.qnn.solver.NelderMead[source]#

Bases: skqulacs.qnn.solver.Solver

run(cost_func: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float], jac: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], theta: List[float], x: numpy.ndarray[Any, numpy.dtype[numpy.float64]], y: numpy.ndarray[Any, numpy.dtype[numpy.float64]], maxiter: Optional[int]) Tuple[float, List[float]][source]#

Run optimizer for given initial parameters and data.

Parameters
  • theta – Initial value of parameters to optimize.

  • x – Data to use in optimization.

  • y – Data to use in optimization.

  • maxiter – Maximum iteration count in optimization.

Returns

Loss and parameters after optimization.

Return type

(loss, theta_opt)

class skqulacs.qnn.solver.Solver[source]#

Bases: abc.ABC

abstract run(cost_func: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], float], jac: Callable[[List[float], numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]], theta: List[float], x: numpy.ndarray[Any, numpy.dtype[numpy.float64]], y: numpy.ndarray[Any, numpy.dtype[numpy.float64]], maxiter: Optional[int]) Tuple[float, List[float]][source]#

Run optimizer for given initial parameters and data.

Parameters
  • theta – Initial value of parameters to optimize.

  • x – Data to use in optimization.

  • y – Data to use in optimization.

  • maxiter – Maximum iteration count in optimization.

Returns

Loss and parameters after optimization.

Return type

(loss, theta_opt)