qrisp.vqe.VQEProblem.train_function#
- VQEProblem.train_function(qarg, depth, mes_kwargs={}, max_iter=50, init_type='random', init_point=None, optimizer='COBYLA', options={})[source]#
This function allows for training of a circuit with a given instance of a
VQEProblem
. It will then return a function that can be applied to a QuantumVariable, such that it prepares the ground state of the problem Hamiltonian. The function therefore applies a circuit for the problem instance with optimized parameters.- Parameters:
- qargQuantumVariable or callable
The argument to which the VQE circuit is applied, or a function returning a QuantumVariable to which the VQE circuit is applied.
- depthint
The amount of VQE ansatz layers.
- mes_kwargsdict, optional
The keyword arguments for the
expectation_value
function. Default is an empty dictionary. By default, the targetprecision
is set to 0.01. Precision refers to how accurately the Hamiltonian is evaluated. The number of shots the backend performs per iteration scales quadratically with the inverse precision.- max_iterint, optional
The maximum number of iterations for the optimization method. Default is 50.
- init_typestring, optional
Specifies the way the initial optimization parameters are chosen. Available is
random
. The default israndom
: Parameters are initialized uniformly at random in the interval \([0,\pi/2)]\).- init_pointndarray, shape (n,), optional
Specifies the initial optimization parameters.
- optimizerstr, optional
Specifies the SciPy optimization routine. Available are, e.g.,
COBYLA
,COBYQA
,Nelder-Mead
. The Default isCOBYLA
. In tracing mode (i.e. Jasp) Jax-traceable optimization routines must be utilized. Available areCOBYLA
,SPSA
.- optionsdict
A dictionary of solver options.
- Returns:
- callable
A function that can be applied to a QuantumVariable, with optimized parameters for the problem instance. The QuantumVariable then represents the ground state of the problem Hamiltonian.