Skip to content

Commit 5274c21

Browse files
committed
update week 13
1 parent de9b068 commit 5274c21

File tree

7 files changed

+1085
-211
lines changed

7 files changed

+1085
-211
lines changed

doc/pub/week13/html/week13-bs.html

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@
163163
2,
164164
None,
165165
'back-to-the-more-realistic-cases'),
166+
('Quantum SVMs', 2, None, 'quantum-svms'),
167+
('What will we need in the case of a quantum computer?',
168+
2,
169+
None,
170+
'what-will-we-need-in-the-case-of-a-quantum-computer'),
171+
('The most general ansatz', 2, None, 'the-most-general-ansatz'),
172+
('Quantum SVM', 2, None, 'quantum-svm'),
173+
('Defining the Quantum Kernel',
174+
2,
175+
None,
176+
'defining-the-quantum-kernel'),
177+
('Side note', 2, None, 'side-note'),
178+
('Feature map', 2, None, 'feature-map'),
179+
('Classical functions', 2, None, 'classical-functions'),
166180
('Plans for next week', 2, None, 'plans-for-next-week')]}
167181
end of tocinfo -->
168182

@@ -255,6 +269,14 @@
255269
<!-- navigation toc: --> <li><a href="#rewriting-in-terms-of-vectors-and-matrices" style="font-size: 80%;">Rewriting in terms of vectors and matrices</a></li>
256270
<!-- navigation toc: --> <li><a href="#rewriting-inequalities" style="font-size: 80%;">Rewriting inequalities</a></li>
257271
<!-- navigation toc: --> <li><a href="#back-to-the-more-realistic-cases" style="font-size: 80%;">Back to the more realistic cases</a></li>
272+
<!-- navigation toc: --> <li><a href="#quantum-svms" style="font-size: 80%;">Quantum SVMs</a></li>
273+
<!-- navigation toc: --> <li><a href="#what-will-we-need-in-the-case-of-a-quantum-computer" style="font-size: 80%;">What will we need in the case of a quantum computer?</a></li>
274+
<!-- navigation toc: --> <li><a href="#the-most-general-ansatz" style="font-size: 80%;">The most general ansatz</a></li>
275+
<!-- navigation toc: --> <li><a href="#quantum-svm" style="font-size: 80%;">Quantum SVM</a></li>
276+
<!-- navigation toc: --> <li><a href="#defining-the-quantum-kernel" style="font-size: 80%;">Defining the Quantum Kernel</a></li>
277+
<!-- navigation toc: --> <li><a href="#side-note" style="font-size: 80%;">Side note</a></li>
278+
<!-- navigation toc: --> <li><a href="#feature-map" style="font-size: 80%;">Feature map</a></li>
279+
<!-- navigation toc: --> <li><a href="#classical-functions" style="font-size: 80%;">Classical functions</a></li>
258280
<!-- navigation toc: --> <li><a href="#plans-for-next-week" style="font-size: 80%;">Plans for next week</a></li>
259281

260282
</ul>
@@ -1822,10 +1844,134 @@ <h2 id="back-to-the-more-realistic-cases" class="anchor">Back to the more realis
18221844

18231845
<p>Using the <b>CVXOPT</b> library, the matrix \( P \) would then be defined by the above matrix while the KKT conditions would all be collected by the matrix \( G \).</p>
18241846

1847+
<!-- !split -->
1848+
<h2 id="quantum-svms" class="anchor">Quantum SVMs </h2>
1849+
1850+
<p>The idea of a classical SVM is that we have a set of points
1851+
that are in either one group or another and we want to find a line that
1852+
separates these two groups. This line can be linear, but it can also be
1853+
much more complex, which can be achieved by the use of Kernels.
1854+
</p>
1855+
1856+
<!-- !split -->
1857+
<h2 id="what-will-we-need-in-the-case-of-a-quantum-computer" class="anchor">What will we need in the case of a quantum computer? </h2>
1858+
1859+
<div class="panel panel-default">
1860+
<div class="panel-body">
1861+
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
1862+
<p>We will have to translate the classical data point \(\vec{x}\)
1863+
into a quantum datapoint \(\vert \Phi{(\vec{x})} \rangle\). This can
1864+
be achieved by a circuit \( \mathcal{U}\_\{\Phi(\vec{x})\} \vert 0\rangle \).
1865+
</p>
1866+
1867+
<p>Here \(\Phi()\) could be any classical function applied
1868+
on the classical data \(\vec{x}\).
1869+
</p>
1870+
</div>
1871+
</div>
1872+
1873+
<div class="panel panel-default">
1874+
<div class="panel-body">
1875+
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
1876+
<p>We need a parameterized quantum circuit \(W( \theta )\) that
1877+
processes the data in a way that in the end we
1878+
can apply a measurement that returns a classical value \(-1\) or
1879+
\(1\) for each classical input \(\vec{x}\) that indentifies the label
1880+
of the classical data.
1881+
</p>
1882+
</div>
1883+
</div>
1884+
1885+
1886+
<!-- !split -->
1887+
<h2 id="the-most-general-ansatz" class="anchor">The most general ansatz </h2>
1888+
1889+
<p>Following these steps we can define an ansatz for this kind of problem
1890+
which is \(W(\theta) \mathcal{U}_{\Phi}(\vec{x}) \vert 0 \rangle\).
1891+
</p>
1892+
1893+
<p>These kind of ansatz are called quantum variational circuits.</p>
1894+
1895+
<!-- !split -->
1896+
<h2 id="quantum-svm" class="anchor">Quantum SVM </h2>
1897+
1898+
<p>In the case of a quantum SVM we will only used the quantum feature maps
1899+
\(\mathcal{U}_{\Phi(\vec{x})}\) to translate the classical data into
1900+
quantum states and build the Kernel of the SVM out of these quantum
1901+
states. After calculating the Kernel matrix on the quantum computer we
1902+
can train the Quantum SVM the same way as the classical SVM.
1903+
</p>
1904+
1905+
<!-- !split -->
1906+
<h2 id="defining-the-quantum-kernel" class="anchor">Defining the Quantum Kernel </h2>
1907+
1908+
<p>The idea of the quantum kernel is exactly the same as in the classical
1909+
case. We take the inner product
1910+
\(K(\vec{x}, \vec{z}) = \vert \langle \Phi (\vec{x}) \vert \Phi(\vec{z}) \rangle \vert^2 = \langle 0^n \vert \mathcal{U}_{\Phi(\vec{x})}^{t} \mathcal{U}_{\Phi(\vec{z})} \vert 0^n \rangle\),
1911+
but now with the quantum feature maps \(\mathcal{U}_{\Phi(\vec{x})}\).
1912+
The idea is that if we choose a quantum feature maps that is not easy to
1913+
simulate with a classical computer we might obtain a quantum advantage.
1914+
</p>
1915+
1916+
<!-- !split -->
1917+
<h2 id="side-note" class="anchor">Side note </h2>
1918+
1919+
<p>There is no proof yet that the QSVM brings a quantum
1920+
advantage, but the argument the authors of
1921+
<a href="https://arxiv.org/pdf/1804.11326.pdf" target="_self"><tt>https://arxiv.org/pdf/1804.11326.pdf</tt></a> make, is that there is
1922+
for sure no advantage if we use feature maps that are easy to simulate
1923+
classically, because then we would not need a quantum computer to
1924+
construct the Kernel.
1925+
</p>
1926+
1927+
<!-- !split -->
1928+
<h2 id="feature-map" class="anchor">Feature map </h2>
1929+
1930+
<p>For the feature maps we use the ansatz</p>
1931+
$$
1932+
\mathcal{U}_{\Phi(x)} = U_{\Phi(x)} \otimes H^{\otimes n},
1933+
$$
1934+
1935+
<p>where</p>
1936+
$$
1937+
U_{\Phi(x)} = \exp \left( i \sum_{S \in n} \phi_S(x) \prod_{i \in S} Z_i \right),
1938+
$$
1939+
1940+
<p>which simplifies a lot when we (like in <a href="https://arxiv.org/pdf/1804.11326.pdf" target="_self"><tt>https://arxiv.org/pdf/1804.11326.pdf</tt></a>) only consider
1941+
\(S \leq 2\) interactions, which means we only let two qubits interact
1942+
at a time. For \(S \leq 2\) the product \(\prod_{i \in S}\) only leads
1943+
to interactions \(Z_i Z_j\) and non interacting terms \(Z_i\). And the
1944+
sum \(\sum_{S \in n}\) over all these terms that are possible with \(n\)
1945+
qubits.
1946+
</p>
1947+
1948+
<!-- !split -->
1949+
<h2 id="classical-functions" class="anchor">Classical functions </h2>
1950+
1951+
<p>Finally we define the classical functions \(\phi_i(\vec{x}) = x_i\) and
1952+
\(\phi_{i,j}(\vec{x}) = (\pi - x_i)( \pi- x_j)\).
1953+
</p>
1954+
1955+
<p>If we write this ansatz for 2 qubits and \(S \leq 2\) we see how it
1956+
simplifies:
1957+
</p>
1958+
$$
1959+
U_{\Phi(x)} = \exp \left(i \left(x_1 Z_1 + x_2 Z_2 + (\pi - x_1)( \pi- x_2) Z_1 Z_2 \right) \right).
1960+
$$
1961+
1962+
<p>We won't get into details to much here, why we would take this ansatz.
1963+
It is simply an ansatz that is simple enough an leads to good results.
1964+
</p>
1965+
1966+
<p>Finally we can define a depth of these circuits. Depth 2 means we repeat
1967+
this ansatz two times. Which means our feature map becomes
1968+
\(U_{\Phi(x)} \otimes H^{\otimes n} \otimes U_{\Phi(x)} \otimes H^{\otimes n}\)
1969+
</p>
1970+
18251971
<!-- !split -->
18261972
<h2 id="plans-for-next-week" class="anchor">Plans for next week </h2>
18271973
<ol>
1828-
<li> Discussion of quantum support vector machines</li>
1974+
<li> Discussion of quantum support vector machines and quantum kernels</li>
18291975
<li> Introducing quantum neural networks</li>
18301976
</ol>
18311977
<!-- ------------------- end of main content --------------- -->

doc/pub/week13/html/week13-reveal.html

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1900,10 +1900,145 @@ <h2 id="back-to-the-more-realistic-cases">Back to the more realistic cases </h2>
19001900
<p>Using the <b>CVXOPT</b> library, the matrix \( P \) would then be defined by the above matrix while the KKT conditions would all be collected by the matrix \( G \).</p>
19011901
</section>
19021902

1903+
<section>
1904+
<h2 id="quantum-svms">Quantum SVMs </h2>
1905+
1906+
<p>The idea of a classical SVM is that we have a set of points
1907+
that are in either one group or another and we want to find a line that
1908+
separates these two groups. This line can be linear, but it can also be
1909+
much more complex, which can be achieved by the use of Kernels.
1910+
</p>
1911+
</section>
1912+
1913+
<section>
1914+
<h2 id="what-will-we-need-in-the-case-of-a-quantum-computer">What will we need in the case of a quantum computer? </h2>
1915+
1916+
<div class="alert alert-block alert-block alert-text-normal">
1917+
<b></b>
1918+
<p>
1919+
<p>We will have to translate the classical data point \(\vec{x}\)
1920+
into a quantum datapoint \(\vert \Phi{(\vec{x})} \rangle\). This can
1921+
be achieved by a circuit \( \mathcal{U}\_\{\Phi(\vec{x})\} \vert 0\rangle \).
1922+
</p>
1923+
1924+
<p>Here \(\Phi()\) could be any classical function applied
1925+
on the classical data \(\vec{x}\).
1926+
</p>
1927+
</div>
1928+
1929+
<div class="alert alert-block alert-block alert-text-normal">
1930+
<b></b>
1931+
<p>
1932+
<p>We need a parameterized quantum circuit \(W( \theta )\) that
1933+
processes the data in a way that in the end we
1934+
can apply a measurement that returns a classical value \(-1\) or
1935+
\(1\) for each classical input \(\vec{x}\) that indentifies the label
1936+
of the classical data.
1937+
</p>
1938+
</div>
1939+
</section>
1940+
1941+
<section>
1942+
<h2 id="the-most-general-ansatz">The most general ansatz </h2>
1943+
1944+
<p>Following these steps we can define an ansatz for this kind of problem
1945+
which is \(W(\theta) \mathcal{U}_{\Phi}(\vec{x}) \vert 0 \rangle\).
1946+
</p>
1947+
1948+
<p>These kind of ansatz are called quantum variational circuits.</p>
1949+
</section>
1950+
1951+
<section>
1952+
<h2 id="quantum-svm">Quantum SVM </h2>
1953+
1954+
<p>In the case of a quantum SVM we will only used the quantum feature maps
1955+
\(\mathcal{U}_{\Phi(\vec{x})}\) to translate the classical data into
1956+
quantum states and build the Kernel of the SVM out of these quantum
1957+
states. After calculating the Kernel matrix on the quantum computer we
1958+
can train the Quantum SVM the same way as the classical SVM.
1959+
</p>
1960+
</section>
1961+
1962+
<section>
1963+
<h2 id="defining-the-quantum-kernel">Defining the Quantum Kernel </h2>
1964+
1965+
<p>The idea of the quantum kernel is exactly the same as in the classical
1966+
case. We take the inner product
1967+
\(K(\vec{x}, \vec{z}) = \vert \langle \Phi (\vec{x}) \vert \Phi(\vec{z}) \rangle \vert^2 = \langle 0^n \vert \mathcal{U}_{\Phi(\vec{x})}^{t} \mathcal{U}_{\Phi(\vec{z})} \vert 0^n \rangle\),
1968+
but now with the quantum feature maps \(\mathcal{U}_{\Phi(\vec{x})}\).
1969+
The idea is that if we choose a quantum feature maps that is not easy to
1970+
simulate with a classical computer we might obtain a quantum advantage.
1971+
</p>
1972+
</section>
1973+
1974+
<section>
1975+
<h2 id="side-note">Side note </h2>
1976+
1977+
<p>There is no proof yet that the QSVM brings a quantum
1978+
advantage, but the argument the authors of
1979+
<a href="https://arxiv.org/pdf/1804.11326.pdf" target="_blank"><tt>https://arxiv.org/pdf/1804.11326.pdf</tt></a> make, is that there is
1980+
for sure no advantage if we use feature maps that are easy to simulate
1981+
classically, because then we would not need a quantum computer to
1982+
construct the Kernel.
1983+
</p>
1984+
</section>
1985+
1986+
<section>
1987+
<h2 id="feature-map">Feature map </h2>
1988+
1989+
<p>For the feature maps we use the ansatz</p>
1990+
<p>&nbsp;<br>
1991+
$$
1992+
\mathcal{U}_{\Phi(x)} = U_{\Phi(x)} \otimes H^{\otimes n},
1993+
$$
1994+
<p>&nbsp;<br>
1995+
1996+
<p>where</p>
1997+
<p>&nbsp;<br>
1998+
$$
1999+
U_{\Phi(x)} = \exp \left( i \sum_{S \in n} \phi_S(x) \prod_{i \in S} Z_i \right),
2000+
$$
2001+
<p>&nbsp;<br>
2002+
2003+
<p>which simplifies a lot when we (like in <a href="https://arxiv.org/pdf/1804.11326.pdf" target="_blank"><tt>https://arxiv.org/pdf/1804.11326.pdf</tt></a>) only consider
2004+
\(S \leq 2\) interactions, which means we only let two qubits interact
2005+
at a time. For \(S \leq 2\) the product \(\prod_{i \in S}\) only leads
2006+
to interactions \(Z_i Z_j\) and non interacting terms \(Z_i\). And the
2007+
sum \(\sum_{S \in n}\) over all these terms that are possible with \(n\)
2008+
qubits.
2009+
</p>
2010+
</section>
2011+
2012+
<section>
2013+
<h2 id="classical-functions">Classical functions </h2>
2014+
2015+
<p>Finally we define the classical functions \(\phi_i(\vec{x}) = x_i\) and
2016+
\(\phi_{i,j}(\vec{x}) = (\pi - x_i)( \pi- x_j)\).
2017+
</p>
2018+
2019+
<p>If we write this ansatz for 2 qubits and \(S \leq 2\) we see how it
2020+
simplifies:
2021+
</p>
2022+
<p>&nbsp;<br>
2023+
$$
2024+
U_{\Phi(x)} = \exp \left(i \left(x_1 Z_1 + x_2 Z_2 + (\pi - x_1)( \pi- x_2) Z_1 Z_2 \right) \right).
2025+
$$
2026+
<p>&nbsp;<br>
2027+
2028+
<p>We won't get into details to much here, why we would take this ansatz.
2029+
It is simply an ansatz that is simple enough an leads to good results.
2030+
</p>
2031+
2032+
<p>Finally we can define a depth of these circuits. Depth 2 means we repeat
2033+
this ansatz two times. Which means our feature map becomes
2034+
\(U_{\Phi(x)} \otimes H^{\otimes n} \otimes U_{\Phi(x)} \otimes H^{\otimes n}\)
2035+
</p>
2036+
</section>
2037+
19032038
<section>
19042039
<h2 id="plans-for-next-week">Plans for next week </h2>
19052040
<ol>
1906-
<p><li> Discussion of quantum support vector machines</li>
2041+
<p><li> Discussion of quantum support vector machines and quantum kernels</li>
19072042
<p><li> Introducing quantum neural networks</li>
19082043
</ol>
19092044
</section>

0 commit comments

Comments
 (0)