Most of the efforts are splitting a python function of the pre-assignment material into different exercises. Also, the efforts come from recognizing the circuit barrier does not stop the continuous flow of circuit building in logical sense. It may look as physically barriers. In the beginning a lot of students have problem with the second training vector preparation, actually caused by the wrong check amplitude data. From course discussion panel we know the TA later changes the exercise contents to make it easier and corrects the wrong data.
Assignment Resetting. The student-TA discussion panel shows starting Exercise 3 there is some error in the check data of the Exercise and TA promises to simplify it. This is why I wait a while for TA’s assignment update. Today I did a submit and grade report shows all my exercises are wrong. So, I guess TA changed not only Exercise 3 but all 5 exercises. No one tells me I have to do a “reset assignment” but I figure out that must be what students should do after TA says his change of exercises got approved. If you don’t do “assignment reset”, the python notebook always loads the old version. However, before you do the reset, you must save all your work. Otherwise, your old effort will be gone forever! Well, I guess that is part of the learning curve for a first-timer of online learning! At any rate, here are the assignment text (I am glad I saved the old assignment text before the reset so that I can compare the new text with old to see how TA simplified the assignment) and my program for state preparation and circuit diagram followed:
State preparation: (the OLD text used to be: “preparing a state in a particular encoding can, in itself, give rise to interesting kernels. This is what talked about in the lecture on the interference Kernel, and Maria Schuld’s guest lecture expands on the idea.” Now the TA changes the old text to -->) As explained in Maria Schuld’s guest lecture, to prepare a state in a particular encoding is done by rotating vectors, in other words to map vectors into others, which is the basic idea of kernel learning. This procedure gives rise to interesting kernels, without the need of specifying the mapping function.
The result is:
|0000> [1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]
|0100> [0.70710678+0.j 0. +0.j 0.70710678+0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
|0010> [0.70710678+0.j 0. +0.j 0. +0.j 0. +0.j
0.70710678+0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j]
|0110> [0.5+0.j 0. +0.j 0.5+0.j 0. +0.j 0.5+0.j 0. +0.j 0.5+0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j]
Obviously, these amplitudes do not add to result in the correct solution. So, it is a wrong thinking. I guess the teacher simply wants us to verify ON PAPER with a pencil that two Hadamard operations on ancilla and index qubits are sufficient to get amplitudes of the |0000>, |0100> states as well as in the |0010>, |0110> states, but I don’t know how.
Quantum Circuit attribute: iden and Wrong thoughts about circuit initialization
Next, although I don’t know exactly how to program identity operators for the data_qubit and the class_qubit, to initialize them for amplitude measurements. I managed to add the following python statements for that and influence no amplitude outputs (It is worng to think when you build a circuit, you already initialized them…). The IBM qiskit document helps to tell you how to do “iden” regarding quantum circuit attributes and methods:
https://qiskit.org/documentation/api/qiskit.circuit.QuantumCircuit.html
(IMPORTANT LINK!)
The following code snippet is for the OLD Ex. 1 assignment (i.e. “Entangle the test instance with the ground state of the ancilla. Put an identity gate on the class qubit.”)
important to get the answer correctly match the check amplitude data. Thank God I got them all right.