squlearn.qnn.ShotsFromRSTD

class squlearn.qnn.ShotsFromRSTD(rstd_bound: float = 0.1, min_shots: int = 100, max_shots: int = 5000)

Shot control for setting the shots of the gradient evaluation after the RSTD of the loss.

The number of shots in the gradient evaluation is set to:

\[N_\text{shots} = \frac{\sigma_L^2}{L^2 \beta^2},\]

where \(\sigma_L\) is the standard deviation of the loss, \(L\) is the loss value and \(\text{\beta}\) is the bound for the relative standard deviation (RSTD) of the loss. See Ref. [1] for details:

Parameters:
  • rstd_bound (float) – Bound for the RSTD of the loss (default: 0.1)

  • min_shots (int) – Minimal number of shots (default: 100)

  • max_shots (int) – Maximal number of shots, is also used for function evaluation (default: 5000)

References

[1] D. A. Kreplin and M. Roth “Reduction of finite sampling noise in quantum neural networks”. arXiv:2306.01639 (2023).

reset_shots() None

Reset the shots to the initial value.

set_executor(executor: Executor) None

Function for setting the executor that is used for the shot control.

Parameters:

executor (Executor) – Executor instance

set_shots_for_grad(**kwargs)

Function for setting the shots for the gradient evaluation.

Sets the shots to the value that is determined by the RSTD of the loss.

Parameters:

kwargs – Keyword arguments for the loss function evaluation

set_shots_for_loss(**kwargs)

Function for setting the shots for the loss function evaluation.

Sets the shots to the maximal value.

Parameters:

kwargs – Keyword arguments for the loss function evaluation