Open sorewachigauyo opened 6 months ago
@stavros11 besides this issue, could you please send to @sorewachigauyo our first notebook for quantum vqc regression, presented years ago to the TII team? Otherwise @MatteoRobbiati could you share the code used for the pdf fit? Thanks.
Thanks for opening this @sorewachigauyo. The reuploading classifier, according to the algorithm introduced in the original paper needs the state representation to compute the loss function, which is a state fidelity indeed.
If you consider a more hardware-friendly execution, e.g. shot-noise simulation or, indeed, execution on some quantum device, this strategy cannot be applied. In fact, what we can use to process information (at least without the gate set tomography) are only the frequencies we get after measurements.
For this reason, in other works involving reuploading models (like the aforementioned regression), we defined a different optimization strategy, computing a Mean Squared Error loss function and using expectation values as predictors.
An example of this approach can be found in a recent code we implemented to compute real time quantum error mitigation during a VQA.
To give you a practical example: In the case of a binary classification one can use a Pauli $Z$ as target observable and compute $$f = \langle 0 | U^{\dagger} Z U | 0\rangle,$$ where $U$ is your variational circuit. Then classify the point as class A if $f\leq0.5$ or class B if $f>0.5$.
The expressibility of the model remains untouched, since you are only changing the way of processing the final information.
In the end, I would say this error is well expected if the adopted strategy is the one implemented in the qclassifier
.
@stavros11 besides this issue, could you please send to @sorewachigauyo our first notebook for quantum vqc regression,
In case this is still helpful, I uploaded this notebook here: https://gist.github.com/stavros11/d737f45ef816911e1d40d0a0fd0fcce3
From a quick look it seems to only be using Circuit
s so it should still work, despite all the changes that have been done in qibolab since that time (the only issue may be the transpiler/native gates). However, this notebook was just for a very first demo and the problem presented is quite simple, so the code shared by @MatteoRobbiati may be more useful.
Thanks @stavros11 and @MatteoRobbiati !
In fact, what we can use to process information (at least without the gate set tomography) are only the frequencies we get after measurements.
The qubit state can be obtained as $$\rho = \frac 12 (I + \langle X\rangle\rho X+ \langle Y\rangle\rho Y+ \langle Z\rangle_\rho Z$$ so the qibolab backend could have this as a simple (and noisy) way of returning the single qubit state
@mho291 are you planning to add such very simple procedures to test GST? If not, then @scarrazza we should plan to have more simple procedures in place for the 20q iqm chip?
Describe the bug The reuploading classifier example expects a
state()
method for the circuit result object on line 85 ofqclassifier.py
. This method exists for theQuantumState
object which is a result of the numpy backend, but the qibolab backend returns aMeasurementOutcomes
object which does not have said method.To Reproduce
On numpy
On qibolab