Skip to content

Commit be9ca6e

Browse files
committed
typos
1 parent e33008b commit be9ca6e

File tree

8 files changed

+272
-594
lines changed

8 files changed

+272
-594
lines changed

doc/pub/week14/html/week14-bs.html

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@
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'),
@@ -265,8 +263,6 @@
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>
13381298
the 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>
13601320
these 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
13781338
be 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
13911351
processes 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
13941354
of 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&#8217;s AngleEmbedding template, we can write:</p>
15151476

15161477

doc/pub/week14/html/week14-reveal.html

Lines changed: 13 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -858,53 +858,6 @@ <h2 id="kernels-and-non-linearity">Kernels and non-linearity </h2>
858858
</div>
859859
</section>
860860

861-
<section>
862-
<h2 id="the-equations">The equations </h2>
863-
864-
<p>Suppose we define a polynomial transformation of degree two only (we
865-
continue to live in a plane with \( x_i \) and \( y_i \) as variables)
866-
</p>
867-
<p>&nbsp;<br>
868-
$$
869-
z = \phi(x_i) =\left(x_i^2, y_i^2, \sqrt{2}x_iy_i\right).
870-
$$
871-
<p>&nbsp;<br>
872-
873-
<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>
874-
<p>&nbsp;<br>
875-
$$
876-
{\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,
877-
$$
878-
<p>&nbsp;<br>
879-
880-
<p>subject to the constraints \( \lambda_i\geq 0 \), \( \sum_i\lambda_iy_i=0 \), and for the support vectors</p>
881-
<p>&nbsp;<br>
882-
$$
883-
y_i(\boldsymbol{w}^T\boldsymbol{z}_i+b)= 1 \hspace{0.1cm}\forall i,
884-
$$
885-
<p>&nbsp;<br>
886-
887-
<p>from which we also find \( b \).</p>
888-
</section>
889-
890-
<section>
891-
<h2 id="defining-the-kernel">Defining the kernel </h2>
892-
893-
<p>To compute \( \boldsymbol{z}_i^T\boldsymbol{z}_j \) we define the kernel \( K(\boldsymbol{x}_i,\boldsymbol{x}_j) \) as</p>
894-
<p>&nbsp;<br>
895-
$$
896-
K(\boldsymbol{x}_i,\boldsymbol{x}_j)=\boldsymbol{z}_i^T\boldsymbol{z}_j= \phi(\boldsymbol{x}_i)^T\phi(\boldsymbol{x}_j).
897-
$$
898-
<p>&nbsp;<br>
899-
900-
<p>For the above example, the kernel reads</p>
901-
<p>&nbsp;<br>
902-
$$
903-
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.
904-
$$
905-
<p>&nbsp;<br>
906-
</section>
907-
908861
<section>
909862
<h2 id="kernel-trick">Kernel trick </h2>
910863

@@ -926,7 +879,7 @@ <h2 id="the-problem-to-solve">The problem to solve </h2>
926879
<p>Using our definition of the kernel We can rewrite again the Lagrangian</p>
927880
<p>&nbsp;<br>
928881
$$
929-
{\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,
882+
{\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,
930883
$$
931884
<p>&nbsp;<br>
932885

@@ -971,10 +924,10 @@ <h2 id="different-kernels">Different kernels </h2>
971924

972925
<p>There are several popular kernels being used. These are</p>
973926
<ol>
974-
<p><li> Linear: \( K(\boldsymbol{x},\boldsymbol{y})=\boldsymbol{x}^T\boldsymbol{y} \),</li>
975-
<p><li> Polynomial: \( K(\boldsymbol{x},\boldsymbol{y})=(\boldsymbol{x}^T\boldsymbol{y}+\gamma)^d \),</li>
976-
<p><li> Gaussian Radial Basis Function: \( K(\boldsymbol{x},\boldsymbol{y})=\exp{\left(-\gamma\vert\vert\boldsymbol{x}-\boldsymbol{y}\vert\vert^2\right)} \),</li>
977-
<p><li> Tanh: \( K(\boldsymbol{x},\boldsymbol{y})=\tanh{(\boldsymbol{x}^T\boldsymbol{y}+\gamma)} \),</li>
927+
<p><li> Linear: \( K(\boldsymbol{v},\boldsymbol{w})=\boldsymbol{v}^T\boldsymbol{w} \),</li>
928+
<p><li> Polynomial: \( K(\boldsymbol{v},\boldsymbol{w})=(\boldsymbol{v}^T\boldsymbol{w}+\gamma)^d \),</li>
929+
<p><li> Gaussian Radial Basis Function: \( K(\boldsymbol{v},\boldsymbol{w})=\exp{\left(-\gamma\vert\vert\boldsymbol{v}-\boldsymbol{w}\vert\vert^2\right)} \),</li>
930+
<p><li> Tanh: \( K(\boldsymbol{v},\boldsymbol{w})=\tanh{(\boldsymbol{v}^T\boldsymbol{w}+\gamma)} \),</li>
978931
</ol>
979932
<p>
980933
<p>and many other ones.</p>
@@ -1267,7 +1220,7 @@ <h2 id="input-dependence">Input dependence </h2>
12671220

12681221
<p>&nbsp;<br>
12691222
$$
1270-
k(\boldsymbol{x},\boldsymbol{x}{\prime}) = \bigl\vert \langle \phi(\boldsymbol{x}) \mid \phi(\boldsymbol{x}{\prime}) \rangle\bigr\vert ^2.
1223+
K(\boldsymbol{x},\boldsymbol{x}{\prime}) = \bigl\vert \langle \phi(\boldsymbol{x}) \mid \phi(\boldsymbol{x}{\prime}) \rangle\bigr\vert ^2.
12711224
$$
12721225
<p>&nbsp;<br>
12731226
</section>
@@ -1280,7 +1233,7 @@ <h2 id="quantum-kernels">Quantum kernels </h2>
12801233
</p>
12811234
<p>&nbsp;<br>
12821235
$$
1283-
k’(\boldsymbol{x},\boldsymbol{x}’) = \langle \phi(\boldsymbol{x}) \vert\phi(\boldsymbol{x}’) \rangle,
1236+
K’(\boldsymbol{x},\boldsymbol{x}’) = \langle \phi(\boldsymbol{x}) \vert\phi(\boldsymbol{x}’) \rangle,
12841237
$$
12851238
<p>&nbsp;<br>
12861239

@@ -1305,7 +1258,7 @@ <h2 id="what-is-a-quantum-kernel">What is a quantum kernel? </h2>
13051258
</p>
13061259
<p>&nbsp;<br>
13071260
$$
1308-
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.
1261+
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.
13091262
$$
13101263
<p>&nbsp;<br>
13111264

@@ -1320,8 +1273,8 @@ <h2 id="what-will-we-need-in-the-case-of-a-quantum-computer">What will we need i
13201273
<div class="alert alert-block alert-block alert-text-normal">
13211274
<b></b>
13221275
<p>
1323-
<p>We will have to translate the classical data point \(\vec{x}\)
1324-
into a quantum datapoint \(\vert \Phi{(\vec{x})} \rangle\). This can
1276+
<p>We will have to translate the classical data point \( \vec{x} \)
1277+
into a quantum datapoint \( \vert \Phi{(\vec{x})} \rangle \). This can
13251278
be achieved by a circuit \( \mathcal{U}_{\Phi(\vec{x})} \vert 0\rangle \).
13261279
</p>
13271280

@@ -1335,8 +1288,8 @@ <h2 id="what-will-we-need-in-the-case-of-a-quantum-computer">What will we need i
13351288
<p>
13361289
<p>We need a parameterized quantum circuit \( W(\theta) \) that
13371290
processes the data in a way that in the end we
1338-
can apply a measurement that returns a classical value \(-1\) or
1339-
\(1\) for each classical input \(\vec{x}\) that indentifies the label
1291+
can apply a measurement that returns a classical value \( -1 \) or
1292+
\( 1 \) for each classical input \( \vec{x} \) that indentifies the label
13401293
of the classical data.
13411294
</p>
13421295
</div>
@@ -1475,6 +1428,7 @@ <h2 id="estimating-quantum-kernels">Estimating quantum kernels </h2>
14751428

14761429
<section>
14771430
<h2 id="code-example">Code example </h2>
1431+
14781432
<p>For example, using PennyLane&#8217;s AngleEmbedding template, we can write:</p>
14791433

14801434

0 commit comments

Comments
 (0)