-
Notifications
You must be signed in to change notification settings - Fork 871
Qsvm #1418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qsvm #1418
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| qfunc bloch_feature_map_expanded___0(data: real[2], qba: qbit[1]) { | ||
| repeat (i: 1) { | ||
| RX(data[2 * i] / 2, qba[i]); | ||
| } | ||
| repeat (i: 1) { | ||
| RZ(data[(2 * i) + 1], qba[i]); | ||
| } | ||
| } | ||
|
|
||
| qfunc main(data1: real[2], data2: real[2], output qba: qnum<1, False, 0>) { | ||
| allocate(1, qba); | ||
| bloch_feature_map_expanded___0(data1, qba); | ||
| invert { | ||
| bloch_feature_map_expanded___0(data2, qba); | ||
| } | ||
| } |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,20 +6,33 @@ | |
| from testbook.client import TestbookNotebookClient | ||
|
|
||
|
|
||
| @wrap_testbook("qsvm", timeout_seconds=204) | ||
| @wrap_testbook("qsvm", timeout_seconds=300) | ||
| def test_notebook(tb: TestbookNotebookClient) -> None: | ||
| """ | ||
| A notebook for a hybrid classical quantum neural network. | ||
| The test verifies that the pre-trained model is indeed well trained. | ||
| """ | ||
| # test models | ||
| validate_quantum_model(tb.ref("QSVM_BLOCH_SHPERE_qmod")) | ||
| validate_quantum_model(tb.ref("QSVM_PAULI_Z_ZZ")) | ||
| # test quantum programs | ||
| validate_quantum_program_size( | ||
| tb.ref_pydantic("qprog"), | ||
| tb.ref_pydantic("qprog_bloch"), | ||
| expected_width=1, # actual width: 1 | ||
| expected_depth=10, # actual depth: 4 | ||
| ) | ||
|
|
||
| validate_quantum_program_size( | ||
| tb.ref_pydantic("qprog_pauli"), | ||
| expected_width=2, # actual width: 2 | ||
| expected_depth=30, # actual depth: 30 | ||
| ) | ||
| # test notebook content | ||
| assert tb.ref("test_score") == 1 | ||
|
|
||
| # test notebook content | ||
| assert tb.ref("test_score_pauli") == 1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, and in the line before (which you did not modify), maybe change this to 1.0? or even to <0.98?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
|
||
| success_rate = tb.ref( | ||
| "100 * np.count_nonzero(predicted_labels_pauli == predict_real_labels_2) / len(predicted_labels_pauli)" | ||
| ) | ||
| assert success_rate == 100 | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe take some buffer fo the depth here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, thanks!