9292 2,
9393 None,
9494 'kernels-and-non-linearity'),
95- ('The equations', 2, None, 'the-equations'),
96- ('Defining the kernel', 2, None, 'defining-the-kernel'),
9795 ('Kernel trick', 2, None, 'kernel-trick'),
9896 ('The problem to solve', 2, None, 'the-problem-to-solve'),
9997 ('Convex optimization', 2, None, 'convex-optimization'),
265263 <!-- navigation toc: --> < li > < a href ="#derivatives-with-respect-to-b-and-boldsymbol-w " style ="font-size: 80%; "> Derivatives with respect to \( b \) and \( \boldsymbol{w} \)</ a > </ li >
266264 <!-- navigation toc: --> < li > < a href ="#new-constraints " style ="font-size: 80%; "> New constraints</ a > </ li >
267265 <!-- navigation toc: --> < li > < a href ="#kernels-and-non-linearity " style ="font-size: 80%; "> Kernels and non-linearity</ a > </ li >
268- <!-- navigation toc: --> < li > < a href ="#the-equations " style ="font-size: 80%; "> The equations</ a > </ li >
269- <!-- navigation toc: --> < li > < a href ="#defining-the-kernel " style ="font-size: 80%; "> Defining the kernel</ a > </ li >
270266 <!-- navigation toc: --> < li > < a href ="#kernel-trick " style ="font-size: 80%; "> Kernel trick</ a > </ li >
271267 <!-- navigation toc: --> < li > < a href ="#the-problem-to-solve " style ="font-size: 80%; "> The problem to solve</ a > </ li >
272268 <!-- navigation toc: --> < li > < a href ="#convex-optimization " style ="font-size: 80%; "> Convex optimization</ a > </ li >
@@ -947,42 +943,6 @@ <h2 id="kernels-and-non-linearity" class="anchor">Kernels and non-linearity </h2
947943</ div >
948944
949945
950- <!-- !split -->
951- < h2 id ="the-equations " class ="anchor "> The equations </ h2 >
952-
953- < p > Suppose we define a polynomial transformation of degree two only (we
954- continue to live in a plane with \( x_i \) and \( y_i \) as variables)
955- </ p >
956- $$
957- z = \phi(x_i) =\left(x_i^2, y_i^2, \sqrt{2}x_iy_i\right).
958- $$
959-
960- < p > With our new basis, the equations we solved earlier are basically the same, that is we have now (without the slack option for simplicity)</ p >
961- $$
962- {\cal L}=\sum_i\lambda_i-\frac{1}{2}\sum_{ij}^n\lambda_i\lambda_jy_iy_j\boldsymbol{z}_i^T\boldsymbol{z}_j,
963- $$
964-
965- < p > subject to the constraints \( \lambda_i\geq 0 \), \( \sum_i\lambda_iy_i=0 \), and for the support vectors</ p >
966- $$
967- y_i(\boldsymbol{w}^T\boldsymbol{z}_i+b)= 1 \hspace{0.1cm}\forall i,
968- $$
969-
970- < p > from which we also find \( b \).</ p >
971-
972- <!-- !split -->
973- < h2 id ="defining-the-kernel " class ="anchor "> Defining the kernel </ h2 >
974-
975- < p > To compute \( \boldsymbol{z}_i^T\boldsymbol{z}_j \) we define the kernel \( K(\boldsymbol{x}_i,\boldsymbol{x}_j) \) as</ p >
976- $$
977- K(\boldsymbol{x}_i,\boldsymbol{x}_j)=\boldsymbol{z}_i^T\boldsymbol{z}_j= \phi(\boldsymbol{x}_i)^T\phi(\boldsymbol{x}_j).
978- $$
979-
980- < p > For the above example, the kernel reads</ p >
981- $$
982- K(\boldsymbol{x}_i,\boldsymbol{x}_j)=[x_i^2, y_i^2, \sqrt{2}x_iy_i]^T\begin{bmatrix} x_j^2 \\ y_j^2 \\ \sqrt{2}x_jy_j \end{bmatrix}=x_i^2x_j^2+2x_ix_jy_iy_j+y_i^2y_j^2.
983- $$
984-
985-
986946<!-- !split -->
987947< h2 id ="kernel-trick " class ="anchor "> Kernel trick </ h2 >
988948
@@ -1002,7 +962,7 @@ <h2 id="kernel-trick" class="anchor">Kernel trick </h2>
1002962< h2 id ="the-problem-to-solve " class ="anchor "> The problem to solve </ h2 >
1003963< p > Using our definition of the kernel We can rewrite again the Lagrangian</ p >
1004964$$
1005- {\cal L}=\sum_i\lambda_i-\frac{1}{2}\sum_{ij}^n\lambda_i\lambda_jy_iy_j\boldsymbol{x }_i^T\boldsymbol{z}_j,
965+ {\cal L}=\sum_i\lambda_i-\frac{1}{2}\sum_{ij}^n\lambda_i\lambda_jy_iy_j\boldsymbol{z }_i^T\boldsymbol{z}_j,
1006966$$
1007967
1008968< p > subject to the constraints \( \lambda_i\geq 0 \), \( \sum_i\lambda_iy_i=0 \) in terms of a convex optimization problem</ p >
@@ -1040,10 +1000,10 @@ <h2 id="different-kernels" class="anchor">Different kernels </h2>
10401000
10411001< p > There are several popular kernels being used. These are</ p >
10421002< ol >
1043- < li > Linear: \( K(\boldsymbol{x },\boldsymbol{y })=\boldsymbol{x }^T\boldsymbol{y } \),</ li >
1044- < li > Polynomial: \( K(\boldsymbol{x },\boldsymbol{y })=(\boldsymbol{x }^T\boldsymbol{y }+\gamma)^d \),</ li >
1045- < li > Gaussian Radial Basis Function: \( K(\boldsymbol{x },\boldsymbol{y })=\exp{\left(-\gamma\vert\vert\boldsymbol{x }-\boldsymbol{y }\vert\vert^2\right)} \),</ li >
1046- < li > Tanh: \( K(\boldsymbol{x },\boldsymbol{y })=\tanh{(\boldsymbol{x }^T\boldsymbol{y }+\gamma)} \),</ li >
1003+ < li > Linear: \( K(\boldsymbol{v },\boldsymbol{w })=\boldsymbol{v }^T\boldsymbol{w } \),</ li >
1004+ < li > Polynomial: \( K(\boldsymbol{v },\boldsymbol{w })=(\boldsymbol{v }^T\boldsymbol{w }+\gamma)^d \),</ li >
1005+ < li > Gaussian Radial Basis Function: \( K(\boldsymbol{v },\boldsymbol{w })=\exp{\left(-\gamma\vert\vert\boldsymbol{v }-\boldsymbol{w }\vert\vert^2\right)} \),</ li >
1006+ < li > Tanh: \( K(\boldsymbol{v },\boldsymbol{w })=\tanh{(\boldsymbol{v }^T\boldsymbol{w }+\gamma)} \),</ li >
10471007</ ol >
10481008< p > and many other ones.</ p >
10491009
@@ -1327,7 +1287,7 @@ <h2 id="input-dependence" class="anchor">Input dependence </h2>
13271287</ p >
13281288
13291289$$
1330- k (\boldsymbol{x},\boldsymbol{x}{\prime}) = \bigl\vert \langle \phi(\boldsymbol{x}) \mid \phi(\boldsymbol{x}{\prime}) \rangle\bigr\vert ^2.
1290+ K (\boldsymbol{x},\boldsymbol{x}{\prime}) = \bigl\vert \langle \phi(\boldsymbol{x}) \mid \phi(\boldsymbol{x}{\prime}) \rangle\bigr\vert ^2.
13311291$$
13321292
13331293
@@ -1338,7 +1298,7 @@ <h2 id="quantum-kernels" class="anchor">Quantum kernels </h2>
13381298the two quantum states. Another common (unnormalized) version is
13391299</ p >
13401300$$
1341- k ’(\boldsymbol{x},\boldsymbol{x}’) = \langle \phi(\boldsymbol{x}) \vert\phi(\boldsymbol{x}’) \rangle,
1301+ K ’(\boldsymbol{x},\boldsymbol{x}’) = \langle \phi(\boldsymbol{x}) \vert\phi(\boldsymbol{x}’) \rangle,
13421302$$
13431303
13441304< p > but measuring this amplitude directly can
@@ -1360,7 +1320,7 @@ <h2 id="what-is-a-quantum-kernel" class="anchor">What is a quantum kernel? </h2>
13601320these states . Concretely, one may write
13611321</ p >
13621322$$
1363- K_{ij} \;=\; k (\boldsymbol{x}_i,\boldsymbol{x}_j) \;=\; \bigl\vert \langle \phi(\boldsymbol{x}_i)\mid\phi(\boldsymbol{x}_j)\rangle\bigr\vert ^2.
1323+ K_{ij} = K (\boldsymbol{x}_i,\boldsymbol{x}_j) \;=\; \bigl\vert \langle \phi(\boldsymbol{x}_i)\mid\phi(\boldsymbol{x}_j)\rangle\bigr\vert ^2.
13641324$$
13651325
13661326< p > This forms a positive semidefinite kernel matrix \( K \) on the dataset,
@@ -1373,8 +1333,8 @@ <h2 id="what-will-we-need-in-the-case-of-a-quantum-computer" class="anchor">What
13731333< div class ="panel panel-default ">
13741334< div class ="panel-body ">
13751335<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
1376- < p > We will have to translate the classical data point \(\vec{x}\)
1377- into a quantum datapoint \(\vert \Phi{(\vec{x})} \rangle\). This can
1336+ < p > We will have to translate the classical data point \( \vec{x} \)
1337+ into a quantum datapoint \( \vert \Phi{(\vec{x})} \rangle \). This can
13781338be achieved by a circuit \( \mathcal{U}_{\Phi(\vec{x})} \vert 0\rangle \).
13791339</ p >
13801340
@@ -1389,8 +1349,8 @@ <h2 id="what-will-we-need-in-the-case-of-a-quantum-computer" class="anchor">What
13891349<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
13901350< p > We need a parameterized quantum circuit \( W(\theta) \) that
13911351processes the data in a way that in the end we
1392- can apply a measurement that returns a classical value \(-1 \) or
1393- \(1 \) for each classical input \(\vec{x}\) that indentifies the label
1352+ can apply a measurement that returns a classical value \( -1 \) or
1353+ \( 1 \) for each classical input \( \vec{x} \) that indentifies the label
13941354of the classical data.
13951355</ p >
13961356</ div >
@@ -1511,6 +1471,7 @@ <h2 id="estimating-quantum-kernels" class="anchor">Estimating quantum kernels </
15111471
15121472<!-- !split -->
15131473< h2 id ="code-example " class ="anchor "> Code example </ h2 >
1474+
15141475< p > For example, using PennyLane’s AngleEmbedding template, we can write:</ p >
15151476
15161477
0 commit comments