Rewrite QSVM examples with ExecutionSession#711
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
ff2a74f to
69adf88
Compare
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #1. ## Classiq imports
why 'Classiq imports'? there are other packages here as well
Reply via ReviewNB
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #5. def my_bloch_feature_map(data: CArray[CReal], qba: QArray[QBit]):
I personally don't like the my_xxx naming
maybe give it a descriptive name that does not collide with the library names?
Reply via ReviewNB
There was a problem hiding this comment.
OK. Actually, here I was trying to avoid future library names.
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #6. repeat(ceiling(data.len / 2), lambda i: RX(data[2 * i] / 2, qba[i]))
data[2 * i] / 2 - what does it mean? different than what you do on the next line. If this is the algorithm, maybe explain a bit why you do that? because it is not trivial
Reply via ReviewNB
There was a problem hiding this comment.
OK, this is just to get the bloch sphere \cos(x[0])|0> + e^{ix[1]}sin(x[1])|1>. The main point is to have the same scaling for x[0] and x[1] in the angles (the mapping I did gives a factor of 1/4 to both, I think). I will explain that.
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #16. QSVM_BLOCH_SHPERE = create_model(main, out_file="qsvm")
maybe QSVM_BLOCH_SHPERE-> QSVM_BLOCH_SHPERE_qmod?
Reply via ReviewNB
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #1. write_qmod(QSVM_BLOCH_SHPERE, "qsvm")
you can remove it if you use the out_file
Reply via ReviewNB
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #3. Generate execution parameters based on the mode (train or validate).
maybe validation should be replaced with 'prediction'? as somtimes you don't validate
Reply via ReviewNB
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #32. def construct_kernel_matrix(matrix_size, res_batch, train=False):
It seems that you can extract the kernel matrix from the res_batch without the matrix_size or train parameters, no?
Also I would rename contruct to extract.I would call it construct if it includes the executions as well
Reply via ReviewNB
There was a problem hiding this comment.
I am not sure how easy it is to extract the info from the res_batch, as it returns as a list, from which you need to infer whether you passed train or predict. In general, I could manage only with the train flag, I think.
Probably there are better ways to define the flow, I will try to figure out something.
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #56. res_batch[count].counts.get("0" * num_output_qubits, 0) / num_shots
why not use 'parsed_counts'?
Reply via ReviewNB
There was a problem hiding this comment.
I will check if it is shorter to do with parsed_counts, not sure.
| @@ -3,7 +3,9 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #80. - train_labels: List of labels corresponding to the training data.
what kind of labels? binary?
Reply via ReviewNB
| @@ -64,14 +64,7 @@ | |||
| "cell_type": "code", | |||
There was a problem hiding this comment.
Line #6. def generate_connectivity_map(list_size, sublist_size, type):
can you make it with networkx instead? or itertools?
if not - I think type is a saved name, would rename it
Reply via ReviewNB
| @@ -2,13 +2,30 @@ | |||
| "cells": [ | |||
There was a problem hiding this comment.
ST(H,t,...) = [ST[]]... - you used twice the term ST but once with 3 arguments and once with 4. maybe you need additional name?
Reply via ReviewNB
db6a582 to
2e0e180
Compare
2e0e180 to
af0a092
Compare
|
🔥 High five, @TomerGoldfriend! You've hit the incredible milestone of 5 merged PRs! 🖐️✨ Your dedication to classiq-library is outstanding. You're not just contributing code; you're shaping the future of quantum computing! 🌠 You're a superstar! 🌟 |
PR Description
This PR modifies three QSVM examples in the library. Instead of using the closed constructor we define feature maps with Qmod and use ExecutionSession for train, validate, and predict steps.
Some notes
Please make sure that you placed the files in an appropriate folder
And that the files have indicative names.
Please note that Classiq runs automatic code linting, which may minorly alter some files.
pre-commit, you may runpre-commit install, and then at each commit, your files will be altered in a similar way