mindquantum.simulator.GradOpsWrapper

View Source On Gitee
class mindquantum.simulator.GradOpsWrapper(grad_ops, hams, circ_right, circ_left, encoder_params_name, ansatz_params_name, parallel_worker, sim=None)[source]

Wrapper the gradient operator that with the information that generate this gradient operator.

Parameters
  • grad_ops (Union[FunctionType, MethodType]) – A function or a method that return forward value and gradient w.r.t parameters.

  • hams (Hamiltonian) – The hamiltonian that generate this grad ops.

  • circ_right (Circuit) – The right circuit that generate this grad ops.

  • circ_left (Circuit) – The left circuit that generate this grad ops.

  • encoder_params_name (list[str]) – The encoder parameters name.

  • ansatz_params_name (list[str]) – The ansatz parameters name.

  • parallel_worker (int) – The number of parallel worker to run the batch.

  • sim (Simulator) – The simulator that this grad ops used.

set_str(grad_str)[source]

Set expression for gradient operator.

Parameters

grad_str (str) – The string of QNN operator.