213
213
None,
214
214
'a-simple-feedforward-qnn-structure'),
215
215
('Example', 2, None, 'example'),
216
- ('Training Output and Loss', 2, None, 'training-output-and-loss'),
216
+ ('Training output and Cost/Loss-function',
217
+ 2,
218
+ None,
219
+ 'training-output-and-cost-loss-function'),
217
220
('Exampe: Variational Classifier',
218
221
2,
219
222
None,
229
232
'training-qnns-and-loss-landscapes'),
230
233
('Gradient Computation', 2, None, 'gradient-computation'),
231
234
('Barren Plateaus', 2, None, 'barren-plateaus'),
232
- ('Loss Landscape Visualization ',
235
+ ('Cost/ Loss-landscape visualization ',
233
236
2,
234
237
None,
235
- 'loss-landscape-visualization'),
238
+ 'cost- loss-landscape-visualization'),
236
239
('Exercises', 2, None, 'exercises'),
237
240
('Implementing QNNs with PennyLane',
238
241
2,
365
368
<!-- navigation toc: --> < li > < a href ="#qnn-architecture-and-models " style ="font-size: 80%; "> QNN Architecture and Models</ a > </ li >
366
369
<!-- navigation toc: --> < li > < a href ="#a-simple-feedforward-qnn-structure " style ="font-size: 80%; "> A simple feedforward QNN structure</ a > </ li >
367
370
<!-- navigation toc: --> < li > < a href ="#example " style ="font-size: 80%; "> Example</ a > </ li >
368
- <!-- navigation toc: --> < li > < a href ="#training-output-and-loss " style ="font-size: 80%; "> Training Output and Loss</ a > </ li >
371
+ <!-- navigation toc: --> < li > < a href ="#training-output-and-cost- loss-function " style ="font-size: 80%; "> Training output and Cost/ Loss-function </ a > </ li >
369
372
<!-- navigation toc: --> < li > < a href ="#exampe-variational-classifier " style ="font-size: 80%; "> Exampe: Variational Classifier</ a > </ li >
370
373
<!-- navigation toc: --> < li > < a href ="#variational-layer-algebra " style ="font-size: 80%; "> Variational Layer Algebra</ a > </ li >
371
374
<!-- navigation toc: --> < li > < a href ="#short-summary " style ="font-size: 80%; "> Short summary</ a > </ li >
372
375
<!-- navigation toc: --> < li > < a href ="#training-qnns-and-loss-landscapes " style ="font-size: 80%; "> Training QNNs and Loss Landscapes</ a > </ li >
373
376
<!-- navigation toc: --> < li > < a href ="#gradient-computation " style ="font-size: 80%; "> Gradient Computation</ a > </ li >
374
377
<!-- navigation toc: --> < li > < a href ="#barren-plateaus " style ="font-size: 80%; "> Barren Plateaus</ a > </ li >
375
- <!-- navigation toc: --> < li > < a href ="#loss-landscape-visualization " style ="font-size: 80%; "> Loss Landscape Visualization </ a > </ li >
378
+ <!-- navigation toc: --> < li > < a href ="#cost- loss-landscape-visualization " style ="font-size: 80%; "> Cost/ Loss-landscape visualization </ a > </ li >
376
379
<!-- navigation toc: --> < li > < a href ="#exercises " style ="font-size: 80%; "> Exercises</ a > </ li >
377
380
<!-- navigation toc: --> < li > < a href ="#implementing-qnns-with-pennylane " style ="font-size: 80%; "> Implementing QNNs with PennyLane</ a > </ li >
378
381
<!-- navigation toc: --> < li > < a href ="#using-pennylane " style ="font-size: 80%; "> Using PennyLane</ a > </ li >
@@ -2189,19 +2192,19 @@ <h2 id="example" class="anchor">Example </h2>
2189
2192
</ p >
2190
2193
2191
2194
<!-- !split -->
2192
- < h2 id ="training-output-and-loss " class ="anchor "> Training Output and Loss </ h2 >
2195
+ < h2 id ="training-output-and-cost- loss-function " class ="anchor "> Training output and Cost/ Loss-function </ h2 >
2193
2196
2194
2197
< p > Given a QNN with output \( f(\mathbf{x};\boldsymbol\theta) \) (a real
2195
2198
number or vector of real values), one must define a loss function to
2196
2199
train on data. Common choices are the mean squared error (MSE) for
2197
2200
regression or cross-entropy for classification. For a training set
2198
- \( {\mathbf{x}i,y_i} \), the MSE loss is
2201
+ \( {\mathbf{x}i,y_i} \), the MSE cost/ loss-function is
2199
2202
</ p >
2200
2203
$$
2201
- L (\boldsymbol\theta) = \frac{1}{N} \sum {i=1}^N \bigl(f(\mathbf{x}i;\boldsymbol\theta) - y_i\bigr)^2.
2204
+ C (\boldsymbol\theta) = \frac{1}{N} \sum_ {i=1}^N \bigl(f(\mathbf{x}i;\boldsymbol\theta) - y_i\bigr)^2.
2202
2205
$$
2203
2206
2204
- < p > One then computes gradients \( \nabla{\boldsymbol\theta}L \) and updates
2207
+ < p > One then computes gradients \( \nabla{\boldsymbol\theta}C \) and updates
2205
2208
parameters via gradient descent or other optimizers.
2206
2209
</ p >
2207
2210
@@ -2210,9 +2213,7 @@ <h2 id="exampe-variational-classifier" class="anchor">Exampe: Variational Classi
2210
2213
2211
2214
< p > A binary classifier can output
2212
2215
\( f(\mathbf{x};\boldsymbol\theta)=\langle Z_0\rangle \) on qubit 0, and
2213
- predict label \( +1 \) if \( f\ge0 \), else \( -1 \). In [50], a code snippet
2214
- defines such a classifier and uses a square loss . We will build
2215
- similar models in Chapter 4.
2216
+ predict label \( +1 \) if \( f\ge0 \), else \( -1 \).
2216
2217
</ p >
2217
2218
2218
2219
<!-- !split -->
@@ -2240,7 +2241,7 @@ <h2 id="short-summary" class="anchor">Short summary </h2>
2240
2241
<!-- !split -->
2241
2242
< h2 id ="training-qnns-and-loss-landscapes " class ="anchor "> Training QNNs and Loss Landscapes </ h2 >
2242
2243
2243
- < p > Training a QNN involves optimizing a nonconvex quantum circuit cost
2244
+ < p > Training a QNN involves optimizing a non-convex quantum circuit cost
2244
2245
function. Like classical neural networks, one typically uses
2245
2246
gradient-based methods. However, VQCs have unique features, as listed here.
2246
2247
</ p >
@@ -2259,7 +2260,7 @@ <h2 id="gradient-computation" class="anchor">Gradient Computation </h2>
2259
2260
gradients by two circuit evaluations per parameter (independent of
2260
2261
circuit size). PennyLane automatically applies parameter-shift rule
2261
2262
when you call backward on a QNode . Optimizers: One can use gradient
2262
- descent or more advanced optimizers (Adam, SPSA , etc.). PennyLane
2263
+ descent or more advanced optimizers (Adam, ADAgrad, RMSprop , etc.). PennyLane
2263
2264
provides a qml.GradientDescentOptimizer and others. Gradients flow
2264
2265
through the classical loss into the quantum circuit via the
2265
2266
parameter-shift trick. In our code examples below we will see
@@ -2289,12 +2290,12 @@ <h2 id="barren-plateaus" class="anchor">Barren Plateaus </h2>
2289
2290
</ p >
2290
2291
2291
2292
<!-- !split -->
2292
- < h2 id ="loss-landscape-visualization " class ="anchor "> Loss Landscape Visualization </ h2 >
2293
+ < h2 id ="cost- loss-landscape-visualization " class ="anchor "> Cost/ Loss-landscape visualization </ h2 >
2293
2294
2294
- < p > One can imagine the loss function \( L (\boldsymbol\theta) \) over the
2295
+ < p > One can imagine the cost/ loss function \( C (\boldsymbol\theta) \) over the
2295
2296
parameter space. Unlike convex classical problems, this landscape may
2296
2297
have many local minima and saddle points. Barren plateaus correspond
2297
- to regions where \( \nabla L \approx 0 \) almost everywhere. Even if
2298
+ to regions where \( \nabla C \approx 0 \) almost everywhere. Even if
2298
2299
plateaus are avoided, poor minima can still trap the optimizer . In
2299
2300
practice, careful tuning of learning rates and adding small random
2300
2301
noise can help escape shallow minima.
@@ -2319,8 +2320,7 @@ <h2 id="exercises" class="anchor">Exercises </h2>
2319
2320
<!-- !split -->
2320
2321
< h2 id ="implementing-qnns-with-pennylane " class ="anchor "> Implementing QNNs with PennyLane </ h2 >
2321
2322
2322
- < p > PennyLane is a software library for hybrid quantum-classical
2323
- computation. It provides QNodes, differentiable quantum functions that
2323
+ < p > PennyLane provides QNodes, differentiable quantum functions that
2324
2324
can be integrated with Python ML frameworks. Here we illustrate
2325
2325
building and training a simple variational quantum classifier using
2326
2326
PennyLane.
@@ -2648,8 +2648,8 @@ <h2 id="essential-steps-in-the-code" class="anchor">Essential steps in the code
2648
2648
< p > After embedding, we apply a layer of trainable rotations and
2649
2649
entangling gates (StronglyEntanglingLayers), creating a parameterized
2650
2650
circuit whose outputs depend on adjustable weights . Measuring the
2651
- expectation ⟨Z⟩ of the first qubit yields a value in \( [– 1,1] \), which we
2652
- convert to a class probability via \( (1 – ⟨Z⟩ )/2 \).
2651
+ expectation \( \langle Z\rangle \) of the first qubit yields a value in \( [- 1,1] \), which we
2652
+ convert to a class probability via \( (1–\langle Z\rangle )/2 \).
2653
2653
</ p >
2654
2654
</ div >
2655
2655
</ div >
0 commit comments