squlearn.qnn.training.train

class squlearn.qnn.training.train(qnn: LowLevelQNNBase, input_values: list | ndarray, ground_truth: list | ndarray, param_ini: list | ndarray, param_op_ini: list | ndarray, loss: LossBase, optimizer: OptimizerBase, shot_control: ShotControlBase = None, weights: list | ndarray = None, opt_param_op: bool = True)

Function for training a given QNN.

Parameters:
  • QNN (LowLevelQNNBase) – QNN instance that is trained

  • input_values (Union[list,np.ndarray]) – List of input values, i.e. training data

  • ground_truth (Union[list,np.ndarray]) – List of ground truth values, e.g. labels of the training data

  • param_ini (Union[list,np.ndarray]) – Initial parameters of the encoding circuit

  • param_op_ini (Union[list,np.ndarray]) – Initial parameters of the observable

  • loss (LossBase) – Loss instance that is minimized

  • optimizer (OptimizerBase) – Optimizer instance that is used for the minimization

  • shot_control (ShotControlBase) – Shot control instance that is used for setting the shots for each optimization step (default: None)

  • weights (Union[list,np.ndarray]) – Weighting of the reference values. Has to be the same size as input and ground_truth (default : None)

  • opt_param_op (bool) – If True, observable parameters are optimized as well (default: True)

Returns:

Optimized parameters of the PQC, and, if opt_param_op=True, the optimized parameters of the observable