Skip to content

Commit

Permalink
Merge pull request #368 from Quantum-TII/vclassifier
Browse files Browse the repository at this point in the history
Fix variational classifier
  • Loading branch information
scarrazza committed Mar 31, 2021
2 parents ec0f2e5 + 5c2f607 commit 6642e00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/variational_classifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Code at: [https://github.com/Quantum-TII/qibo/tree/master/examples/variational_c

## Problem overview

We want to perform a supervised classification task with a [variational quantum classifer](https://arxiv.org/abs/2001.03622). The classifier is trained to minimize a local loss function given by the quadratic deviation of the classifier's predictions from the actual labels of the examples in the training set. A variational quantum circuit is employed to perform the classification.
We want to perform a supervised classification task with a [variational quantum classifer](https://arxiv.org/abs/1802.06002). The classifier is trained to minimize a local loss function given by the quadratic deviation of the classifier's predictions from the actual labels of the examples in the training set. A variational quantum circuit is employed to perform the classification.

## Implementing the solution

Expand Down Expand Up @@ -42,4 +42,4 @@ Note that nclases must be 3 and cannot be changed in this example, because we ar

## Results

The classification accuracy for the training and test sets is found to be around 70% and 67%, respectively.
The classification accuracy for the training and test sets is found to be around 70% and 73%, respectively.
2 changes: 1 addition & 1 deletion examples/variational_classifier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main(nclasses, nqubits, nlayers, nshots, training, RxRzRx, method):
np.save('data/optimal_angles_rxrzrx_{}q_{}l.npy'.format(nqubits,nlayers), optimal_angles)

# We define our test set (both kets and labels)
data_test = np.concatenate((data[35:49], data[85:99], data[135:149]))
data_test = np.concatenate((data[35:50], data[85:100], data[135:150]))
labels_test = [[1,1]]*15 + [[1,-1]]*15 + [[-1,1]]*15

# We run an accuracy check for the training and the test sets
Expand Down

0 comments on commit 6642e00

Please sign in to comment.