ad_hoc_data#

ad_hoc_data(training_size, test_size, n, gap, plot_data=False, one_hot=True, include_sample_total=False)[исходный код]#

Generates a toy dataset that can be fully separated with ZZFeatureMap according to the procedure outlined in [1]. To construct the dataset, we first sample uniformly distributed vectors \(\vec{x} \in (0, 2\pi]^{n}\) and apply the feature map

\[|\Phi(\vec{x})\rangle = U_{{\Phi} (\vec{x})} H^{\otimes n} U_{{\Phi} (\vec{x})} H^{\otimes n} |0^{\otimes n} \rangle\]

where

\[U_{{\Phi} (\vec{x})} = \exp \left( i \sum_{S \subseteq [n] } \phi_S(\vec{x}) \prod_{i \in S} Z_i \right)\]

and

\[\begin{split}\begin{cases} \phi_{\{i, j\}} = (\pi - x_i)(\pi - x_j) \\ \phi_{\{i\}} = x_i \end{cases}\end{split}\]

We then attribute labels to the vectors according to the rule

\[\begin{split}m(\vec{x}) = \begin{cases} 1 & \langle \Phi(\vec{x}) | V^\dagger \prod_i Z_i V | \Phi(\vec{x}) \rangle > \Delta \\ -1 & \langle \Phi(\vec{x}) | V^\dagger \prod_i Z_i V | \Phi(\vec{x}) \rangle < -\Delta \end{cases}\end{split}\]

where \(\Delta\) is the separation gap, and \(V\in \mathrm{SU}(4)\) is a random unitary.

The current implementation only works with n = 2 or 3.

References:

[1] Havlíček V, Córcoles AD, Temme K, Harrow AW, Kandala A, Chow JM, Gambetta JM. Supervised learning with quantum-enhanced feature spaces. Nature. 2019 Mar;567(7747):209-12. arXiv:1804.11326

Параметры:
  • training_size (int) – the number of training samples.

  • test_size (int) – the number of testing samples.

  • n (int) – number of qubits (dimension of the feature space). Must be 2 or 3.

  • gap (int) – separation gap (\(\Delta\)).

  • plot_data (bool) – whether to plot the data. Requires matplotlib.

  • one_hot (bool) – if True, return the data in one-hot format.

  • include_sample_total (bool) – if True, return all points in the uniform grid in addition to training and testing samples.

Результат:

Training and testing samples.

Исключение:

ValueError – if n is not 2 or 3.

Тип результата:

Tuple[ndarray, ndarray, ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray, ndarray, ndarray]