213213 None,
214214 'a-simple-feedforward-qnn-structure'),
215215 ('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'),
217220 ('Exampe: Variational Classifier',
218221 2,
219222 None,
229232 'training-qnns-and-loss-landscapes'),
230233 ('Gradient Computation', 2, None, 'gradient-computation'),
231234 ('Barren Plateaus', 2, None, 'barren-plateaus'),
232- ('Loss Landscape Visualization ',
235+ ('Cost/ Loss-landscape visualization ',
233236 2,
234237 None,
235- 'loss-landscape-visualization'),
238+ 'cost- loss-landscape-visualization'),
236239 ('Exercises', 2, None, 'exercises'),
237240 ('Implementing QNNs with PennyLane',
238241 2,
365368 <!-- navigation toc: --> < li > < a href ="#qnn-architecture-and-models " style ="font-size: 80%; "> QNN Architecture and Models</ a > </ li >
366369 <!-- navigation toc: --> < li > < a href ="#a-simple-feedforward-qnn-structure " style ="font-size: 80%; "> A simple feedforward QNN structure</ a > </ li >
367370 <!-- 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 >
369372 <!-- navigation toc: --> < li > < a href ="#exampe-variational-classifier " style ="font-size: 80%; "> Exampe: Variational Classifier</ a > </ li >
370373 <!-- navigation toc: --> < li > < a href ="#variational-layer-algebra " style ="font-size: 80%; "> Variational Layer Algebra</ a > </ li >
371374 <!-- navigation toc: --> < li > < a href ="#short-summary " style ="font-size: 80%; "> Short summary</ a > </ li >
372375 <!-- navigation toc: --> < li > < a href ="#training-qnns-and-loss-landscapes " style ="font-size: 80%; "> Training QNNs and Loss Landscapes</ a > </ li >
373376 <!-- navigation toc: --> < li > < a href ="#gradient-computation " style ="font-size: 80%; "> Gradient Computation</ a > </ li >
374377 <!-- 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 >
376379 <!-- navigation toc: --> < li > < a href ="#exercises " style ="font-size: 80%; "> Exercises</ a > </ li >
377380 <!-- navigation toc: --> < li > < a href ="#implementing-qnns-with-pennylane " style ="font-size: 80%; "> Implementing QNNs with PennyLane</ a > </ li >
378381 <!-- 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>
21892192</ p >
21902193
21912194<!-- !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 >
21932196
21942197< p > Given a QNN with output \( f(\mathbf{x};\boldsymbol\theta) \) (a real
21952198number or vector of real values), one must define a loss function to
21962199train on data. Common choices are the mean squared error (MSE) for
21972200regression 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
21992202</ p >
22002203$$
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.
22022205$$
22032206
2204- < p > One then computes gradients \( \nabla{\boldsymbol\theta}L \) and updates
2207+ < p > One then computes gradients \( \nabla{\boldsymbol\theta}C \) and updates
22052208parameters via gradient descent or other optimizers.
22062209</ p >
22072210
@@ -2210,9 +2213,7 @@ <h2 id="exampe-variational-classifier" class="anchor">Exampe: Variational Classi
22102213
22112214< p > A binary classifier can output
22122215\( 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 \).
22162217</ p >
22172218
22182219<!-- !split -->
@@ -2240,7 +2241,7 @@ <h2 id="short-summary" class="anchor">Short summary </h2>
22402241<!-- !split -->
22412242< h2 id ="training-qnns-and-loss-landscapes " class ="anchor "> Training QNNs and Loss Landscapes </ h2 >
22422243
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
22442245function. Like classical neural networks, one typically uses
22452246gradient-based methods. However, VQCs have unique features, as listed here.
22462247</ p >
@@ -2259,7 +2260,7 @@ <h2 id="gradient-computation" class="anchor">Gradient Computation </h2>
22592260gradients by two circuit evaluations per parameter (independent of
22602261circuit size). PennyLane automatically applies parameter-shift rule
22612262when 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
22632264provides a qml.GradientDescentOptimizer and others. Gradients flow
22642265through the classical loss into the quantum circuit via the
22652266parameter-shift trick. In our code examples below we will see
@@ -2289,12 +2290,12 @@ <h2 id="barren-plateaus" class="anchor">Barren Plateaus </h2>
22892290</ p >
22902291
22912292<!-- !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 >
22932294
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
22952296parameter space. Unlike convex classical problems, this landscape may
22962297have 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
22982299plateaus are avoided, poor minima can still trap the optimizer . In
22992300practice, careful tuning of learning rates and adding small random
23002301noise can help escape shallow minima.
@@ -2319,8 +2320,7 @@ <h2 id="exercises" class="anchor">Exercises </h2>
23192320<!-- !split -->
23202321< h2 id ="implementing-qnns-with-pennylane " class ="anchor "> Implementing QNNs with PennyLane </ h2 >
23212322
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
23242324can be integrated with Python ML frameworks. Here we illustrate
23252325building and training a simple variational quantum classifier using
23262326PennyLane.
@@ -2648,8 +2648,8 @@ <h2 id="essential-steps-in-the-code" class="anchor">Essential steps in the code
26482648< p > After embedding, we apply a layer of trainable rotations and
26492649entangling gates (StronglyEntanglingLayers), creating a parameterized
26502650circuit 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 \).
26532653</ p >
26542654</ div >
26552655</ div >
0 commit comments