squlearn.qnn.training.train_mini_batch

class squlearn.qnn.training.train_mini_batch(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, epochs: int = 10, batch_size: int = None, shuffle=False)

Minimize a loss function using mini-batch gradient descent.

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) epochs : Number of epochs of SGD to perform

  • batch_size – Number of data points in each batch

  • shuffle – If True, data points get shuffled before each epoch (default: False)

Returns:

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