A General Approach to Dropout in Quantum Neural Networks
In classical Machine Learning, "overfitting" is the phenomenon occurring when
a given model learns the training data excessively well, and it thus performs
poorly on unseen data. A commonly employed technique in Machine Learning is the
so called "dropout", which prevents computational units from becoming too
specialized, hence reducing the risk of overfitting. With the advent of Quantum
Neural Networks as learning models, overfitting might soon become an issue,
owing to the increasing depth of quantum circuits as well as multiple embedding
of classical features, which are employed to give the computational
nonlinearity. Here we present a generalized approach to apply the dropout
technique in Quantum Neural Network models, defining and analysing different
quantum dropout strategies to avoid overfitting and achieve a high level of
generalization. Our study allows to envision the power of quantum dropout in
enabling generalization, providing useful guidelines on determining the maximal
dropout probability for a given model, based on overparametrization theory. It
also highlights how quantum dropout does not impact the features of the Quantum
Neural Networks model, such as expressibility and entanglement. All these
conclusions are supported by extensive numerical simulations, and may pave the
way to efficiently employing deep Quantum Machine Learning models based on
state-of-the-art Quantum Neural Networks.
Francesco Scala, Andrea Ceschini, Massimo Panella, Dario Gerace
# A General Approach to Dropout in Quantum Neural Networks

###### Abstract

In classical Machine Learning, "overfitting" is the phenomenon occurring when a given model learns the training data excessively well, and it thus performs poorly on unseen data. A commonly employed technique in Machine Learning is the so called "dropout", which prevents computational units from becoming too specialized, hence reducing the risk of overfitting. With the advent of Quantum Neural Networks as learning models, overfitting might soon become an issue, owing to the increasing depth of quantum circuits as well as multiple embedding of classical features, which are employed to give the computational nonlinearity. Here we present a generalized approach to apply the dropout technique in Quantum Neural Network models, defining and analysing different quantum dropout strategies to avoid overfitting and achieve a high level of generalization. Our study allows to envision the power of quantum dropout in enabling generalization, providing useful guidelines on determining the maximal dropout probability for a given model, based on overparametrization theory. It also highlights how quantum dropout does not impact the features of the Quantum Neural Networks model, such as expressibility and entanglement. All these conclusions are supported by extensive numerical simulations, and may pave the way to efficiently employing deep Quantum Machine Learning models based on state-of-the-art Quantum Neural Networks.

## I Introduction

Machine Learning (ML) has been rapidly emerging in the last few years as a most promising computational model to analyze and extract insights from large and complex datasets, improve decision-making processes, and automate different tasks across a wide range of industrial processes [1; 2]. ML models generally require high flexibility, with lots of trainable parameters in order to learn the underlying function in a supervised fashion. However, being able to learn with low in-sample error is not enough: it is also desirable to have a model that is capable of high _generalization_, meaning that it is able to provide good predictions on previously unseen data [3].

Overfitting is a common issue in ML when dealing with highly expressive models [4; 5]. It is a phenomenon that occurs when a model is trained too well on the training data, and as a result, performs poorly on new, unseen data; if the model's performance on the testing set is significantly worse than on the training set, it probably indicates overfitting. This happens because the model has learnt the noise in the training data, rather than the underlying pattern that is generalizable to new data. When a learning model has a high number of parameters relative to the amount of training data, then it is likely to produce overfitting: the model becomes too complex for the amount of data it has been trained on, resulting in a lack of generalization.

Deep Neural Networks (DNNs) are powerful neural network models that are able to employ a large number of parameters, which allows to well approximate complex functions and achieve high accuracy in training. However, the high complexity of these models can also lead to overfitting the training data. To mitigate overfitting, regularization methods such as the "dropout" are widely employed in the Deep Learning (DL) community. Dropout is a technique that acts by randomly dropping either neurons or connections within a DNN during the training phase, to block the information flow and prevent units from becoming too specialized, thus reducing the risk of overfitting [6].

Recently, an emerging field combining ML with the principles of quantum computing has been emerging, Quantum machine learning (QML). The goal of QML is to leverage the unique properties of quantum systems, such as superposition and entanglement, to improve the performance of ML and DL algorithms. The potential advantages of QML include faster training times [7], improved generalization [8], and the ability to solve problems that are intractable for classical algorithms [9; 10]. Even though prototypes of real quantum computers are available nowadays, these are still of limited size and strongly affected by noise, posing an additional challenge to researchers in the field and giving rise to the so-called Noisy Intermediate Scale Quantum (NISQ) era [11; 12; 13]. Variational Quantum Algorithms (VQA) [14] are a particular QML approach that demonstrated to be very efficient in dealing with such noisy hardware by exploiting the combination of Parametrized Quantum Circuits (PQC), often referred also as Quantum Neural Networks (QNNs) [15; 16; 17; 18], and an optimization process run on a classical computer [19; 20; 21; 22; 23; 24; 25; 26; 27].

The search for high generalization capability also applies to QNN models [28; 29; 8], in which a quantum
model can be trained to analyse classical or quantum data. Since quantum mechanics is intrinsically linear, in order to nonlinearly analyse classical data and enhance the expressive power of QML models, the data re-uploading technique was introduced [30]. Further efforts on the relationship between classical data encoding and generalization performances suggest that overfitting may be caused by the repeated encoding of classical data [28; 29]. Although overfitting may also occur in deep QML models, little has been said about how to practically deal with it, so far. If on the one hand training deep overparametrized quantum models [31; 32; 33; 34] greatly helps to avoid barren plateaus [35; 36; 37; 38; 39; 40], on the other hand, the presence of multiple data re-uploading and redundancy in the parameters may lead to overfitting the data. Some bounds for the scaling of generalization error are given in Ref. [8], but their application to deep QML models has not been explored, yet. Moreover, a recent work [41] reports on the limitations of uniform generalization bounds applied to QML models.

The seminal idea of implementing dropout to address the overfitting problem in QNNs is given in Ref. [42], where the presence or absence of a unitary operation is controlled by an ancillary register. More recently, it has been proposed to randomly select and measure one of the qubits and set it aside for a certain number of optimization steps during the training of PQCs [43], which is a sort of dropout technique. Nevertheless, this type of dropout regularization does not seem to solve the overfitting issue. Recently, entangling dropout was proposed to address the problem of overfitting in deep QNNs [44]: some entangling gates (specifically, controlled-NOT ones) are randomly removed during the training phase in order to decrease the expressibility of the QML model. In order to clarify possible misunderstandings on the relationship between the present work with others already present in the literature, let us point out that the terminology 'quantum dropout' has been employed also in the context of Quantum Approximate Optimization Algorithms [45], which consists in a completely different technique. In addition, _classical_ dropout has been used to avoid overfitting in hybrid Quantum Convolutional NNs [46], which is not what we mean as quantum dropout.

In this paper, we present the first extensive theoretical assessment of the dropout technique applied to QNNs (i.e., _quantum dropout_) inspired by the comparison between classical and quantum models, in which the role of artificial neurons is implemented by rotation gates, whereas entangling gates work as inter-neural connections. Taking into account this analogy, rotations are randomly removed, in addition to some entangling gates depending on the chosen dropout method. Additionally, starting from the overparametrization theory, we provide guidelines about how to determine the maximal dropout probability for a given model. Our results indicate that all the proposed quantum dropout strategies are effective in mitigating overfitting, especially when parametrized quantum gates are dropped. Moreover, we examine the use of parameter rescaling for quantum dropout strategies, a potentially useful strategy that has not been addressed in the previous literature. Interestingly, unlike classical dropout, quantum dropout does not benefit from parameter rescaling. As a consequence, we analyse the learning performances without it. Finally, we analyse the behaviour of genuine quantum features related to the QNN when quantum dropout is applied. The main conclusion is that quantum dropout does not reduce expressibility [22] or entanglement [47] when the QNN is overparametrized. These findings have significant implications for the effective implementation of deep QNN models and provide a promising foundation for the development of more efficient strategies for QNNs training.

The paper is structured as follows. Section II provides a comprehensive overview of QNNs, overparametrization and dropout. Section III presents a general introduction to dropout for QNNs and examines the proposed strategies. Section IV delivers and discusses the main results of numerical experiments on quantum dropout, together with an analysis of entanglement, expressibility and parameters scaling with QNNs. Conclusions are drawn in Sec. V. Lastly, the employed Methods are illustrated in Section VI.

## II Technical background

### Quantum Neural Networks

Due to their similarities with classical NNs, PQCs employed within VQAs are often referred to as QNNs [15]. They are composed of a data encoding stage, a parametrized ansatz, and a measurement operation at the end to retrieve the result followed by a classical update of the parameters. Following this scheme, QNNs can learn to perform various tasks, such as regression and classification.

Classical patterns \(\mathbf{x}\in\mathbb{R}^{n}\) are encoded into a \(N\) qubit quantum circuit via a quantum feature map, which corresponds to a unitary matrix \(S(\mathbf{x})\) that maps \(\mathbf{x}\) to a \(2^{N}\)-dimensional Hilbert space. The embedding is then followed by the variational ansatz \(W(\mathbf{\theta})\). The latter is composed of layers of parametrized single-qubit rotation gates and two-qubits entangling gates: rotation gates are employed to manipulate the quantum state by addressing single qubits independently, while layers of entangling gates allow for the creation of multipartite entanglement [48] throughout the whole state vector (see, e.g., Fig. 8 as an example). This can be summarized as

\[W(\mathbf{\theta})S(\mathbf{x})|\mathbf{0}\rangle=W(\mathbf{\theta})|\phi(\mathbf{x})\rangle\,, \tag{1}\]

where \(|\mathbf{0}\rangle=|0\rangle^{\otimes N}\).

Data encoding and ansatz unitaries may be applied repeatedly in a data re-uploading fashion to realise more expressive models [30]. In this regard, given \(L\) data re-uploading layers, the final unitary describing the evolu
tion of the quantum state is formally expressed as

\[U_{L}(\mathbf{x};\mathbf{\theta})=\prod_{l=L}^{1}U_{l}(\mathbf{x};\mathbf{\theta})=\prod_{ l=L}^{1}W(\mathbf{\theta}^{(l)})S(\mathbf{x})\,, \tag{2}\]

where \(\mathbf{\theta}^{(l)}\) refers to the parameters in the \(l\)-th layer of the quantum circuit.

At the end of the quantum circuit, a measurement with respect to an observable is performed to retrieve the outcome of the algorithm:

\[f_{L}(\mathbf{x};\mathbf{\theta})=\langle\mathbf{0}|\,U_{L}^{\dagger}(\mathbf{x};\bm {\theta})\hat{O}U_{L}(\mathbf{x};\mathbf{\theta})|\mathbf{0}\rangle\,, \tag{3}\]

where \(\hat{O}\) is the measured operator. In this work, we measure in the Pauli-Z basis one or more qubits depending on the task. When employed in VQAs, from \(f_{L}(\mathbf{x};\mathbf{\theta})\) a classical optimizer estimates the cost function to update the parameters.

The data re-uploading strategy affects the ability of QNNs to approximate functions. In fact, as shown in Ref. [16], a quantum model \(f_{L}(\mathbf{x};\mathbf{\theta})\) can be expressed as a partial Fourier series in the data, and by repeating the data encoding stage quantum models can access a wider range of frequency spectra growing as \(L\). On the other hand, if QNN depth increases too much, this procedure will be prone to overfitting of the training data due to their enhanced expressiveness [33]. The issue of overfitting is discussed in Sec. II.2, where we also discuss its link to overparametrization [32].

### Overparametrization and overfitting

In classical ML, a model is said to be overparametrized when the number of trainable parameters, \(M\), exceeds the number of training samples. This is often the case for deep learning models, where the number of trainable parameters is usually way larger than the size of the training dataset. Differently, in QML such a term has taken slightly different meanings depending on the context in which it has been employed [31; 32; 33; 34]. In this work, we apply the definitions provided in Refs. [31; 32]: a QNN is said to be overparametrized when the _average parameter dimension_ (over the whole training set) saturates its maximum achievable value, \(D_{max}=2^{\mathrm{N}+1}-2\). This implies that the QNN is fully capable of representing every possible quantum state on \(N\) qubits. As a consequence, adding more trainable parameters will only increase the _redundancy_. In App. B we provide the definitions of the mentioned quantities and we verify that we are working

Figure 1: Illustration of the similarities between classical and quantum NNs. Quantum rotational gates take the role of artificial neurons, and entangling gates work as connections between them. Neurons process the incoming information (from a previous layer of neurons/quantum circuit) and then send it to all the neurons of the next layers throughout their connections; for the QNN, this is just a schematic representation; in fact, if the state is entangled, a rotation on one qubit will affect also others. In the classical NN, when one neuron is dropped, it is removed together with all its connections, whereas the canonical quantum dropout leaves some entangling gates unaltered, to avoid a strong impact on the quantum learning process.
in the overparametrized regime, indeed.

In order to strengthen the presence of overfitting, we also employ QNNs with multiple data encoding, both in parallel on different qubits and with the data re-uploading technique [28; 29; 8], respectively.

### Dropout

Dropout, which was first proposed in Ref. [6], is a widespread technique to prevent overfitting in classical DL models. It consists in temporarily removing neurons from the network, along with all their incoming and outgoing connections, during the training phase. Each unit is dropped randomly and independently, usually according to a fixed probability \(p\). Dropout is repeated at each iteration and corresponds to sampling a thinned network from the original one. Thus, training a \(n\)-units neural network with dropout can be seen as training a collection of \(2^{n}\) thinned networks with extensive weight sharing, where each thinned network gets trained very rarely, namely with probability equal to \(1/2^{n}\).

At test time, one employs the original neural network with scaled weights with respect to the ones obtained from the training. If a unit is dropped with probability \(p\) during training, the final weight of that unit is multiplied by \(1-p\) at test time. This amounts to averaging the behaviour of \(2^{n}\) thinned neural networks when using the original one.

In addition to the characterization of dropout as an ensemble technique, one can also try to catch its functioning by analysing what happens during training. When applying dropout the information flow is hindered, hence each hidden neuron is forced to learn to work with a randomly chosen group of other units. This should make each unit more robust and help it develop useful features on its own without relying on the surrounding units to correct its mistakes (co-adapting) and, on the other hand, it should also avoid the hyperspecialization of the units. However, the hidden units within a layer will still learn to do different things from each other.

## III Quantum dropout

### General approach

Since overfitting usually appears when a model is overparametrized, we present the quantum dropout technique in the context of overparametrized QNNs. By comparing classical and quantum NNs, one can associate quantum single-qubit rotation gates to neurons and entangling gates to connections between neurons, see Fig 1. In this view, quantum dropout consists in randomly removing parametrized unitaries in an overparametrized QNN during the training phase. More precisely, herein dropping a gate means that we substitute it with an identity gate. We argue that it is crucial to drop parametrized gates (or groups of gates including some parametrized ones) in order to fully benefit from dropout, since it prevents the QNN from becoming too reliant on specific parameters, thereby reducing the risk of overfitting. By randomly removing these parametrized unitaries, the QNN is forced to rely on a wider range of parameters and learn more robust features.

The general scheme of quantum dropout at each training step, inspired by [44], can be roughly summarized as follows:

1. Randomly select QNN layers according to the layer dropout ratio (\(p_{L}\)), i.e., the probability of choosing a layer to which the dropout is applied.
2. Remove (groups of) gates in the selected layers based on a probability defined as the gate dropout ratio (\(p_{G}\)). This probability determines the likelihood of a quantum gate of being dropped.
3. Compute the gradient of the cost function for the dropout circuit and update the parameters accordingly.
4. Iterate the above procedure until the termination criterion is met.

Usually, in classical ML one applies dropout only to certain selected layers with probability \(p\). The selection of the layers is often related to the particular design of the NN under usage, since it is very common to build part of the model with specific purposes. Conversely, in a quantum setting we have a QNN composed of identical repeated layers and this is why we randomly sample the layers where to apply quantum dropout.

Given the layer dropout rate \(p_{L}\) and the gate dropout rate \(p_{G}\), the probability \(p\) that a (group of) gate(s) is dropped in a layer can be calculated with the conditioned probability law:

\[p=p(A\cap B)=p(A|B)p(B)=p_{G}p_{L} \tag{4}\]

where \(A\) is the selection of a specific (group of) gate(s) and \(B\) is the selection of a specific layer.

Before applying quantum dropout, one must always consider how many parameters are needed to preserve the full capabilities of the QNN under usage, in order to choose appropriate values of \(p\). If the probability of dropout is set too high, the QNN will leave the overparametrization regime, and this will have direct consequences on its expressibility and entanglement produced. In this work, as a rule of thumb for checking the maximal allowed number of dropped parameters we employ the following inequality:

\[M_{max}^{drop}\leq M-D_{max} \tag{5}\]

where \(M\) is the total number of parameters, \(D_{max}\) is the maximal parameter dimension (setting the minimum number of parameters required to fully explore the
Hilbert space as explained in Sec. II.2). One can then obtain \(p_{max}^{drop}=M_{max}^{drop}/M\). The reader can find more details in Appendix B; we show the effects of dropout on genuine quantum feature in Sec. IV.4 and in Appendices D and E.

### Proposed strategies

The quantum dropout scheme described above can be applied in different fashions depending on the dropped unitary operations. We hereby present at first the quantum dropout approach that embodies the more intuitive and practical essence of dropout, then we define alternative quantum dropout techniques. All these are summarized in Tab. 1.

Following the classical concept of dropout, a certain neuron (single-qubit rotation) is selected according to the drop probability \(p\) and it is removed together with all its connections (entangling gates). Hence, we define the _canonical quantum dropout_ where all the previous entangling gates, having the single-rotated qubit as a target, and all the next ones, having it as a control, are dropped. To exactly reproduce the classical dropout in a quantum circuit, one should remove all the entangling gates connecting the rotated qubit with the other qubits. However, this is not practical in a quantum setting, since it would deeply change the entire quantum state. For this reason, we preferred to define the canonical dropout rather than an exact quantum counterpart of classical dropout. Besides, quantum dropout with PQC as QNNs will always be intrinsically different from its classical counterpart, because we are acting multiple times on the same qubits, evolving the quantum state. This implies a temporal connection that is never removed by the dropout, even if we were to drop all the entangling gates liked to a single rotation.

Exploiting this fact, one can think of a purely quantum _partial dropout_, which has no classical analogue. More in detail, one may want to remove only the entangling gates previous (_canonical-backward_) or subsequent (_canonical-forward_) to the selected rotation gate.1

Footnote 1: Since these two are conceptually equivalent, in this study we will only work with canonical-forward.

It is also possible to only drop single-qubit rotations or entangling gates: we call these approaches _rotation dropout_ and _entangling dropout_, respectively. The latter approach was previously defined in [44] and is included in our quantum dropout framework as a special case. In fact, it can be considered as an improper dropout since it fits more the definition of a randomized quantum version of the pruning technique [49] (applied only during training), which consists in removing connections in a NN according to their level of importance. In addition, the employment of CNOTs as entangling gates would result in having equally-weighted connections, whereas controlled rotation would allow for different weighting of the connections. For this reason, in this work, we employ two different QNN models: the first one, proposed in [44], has CNOTs as entangling gates and is utilised for regression, while for classification we choose a QNN with parametrized entangling gates. More details about the QNN structures can be found in Appendix A.

Ultimately, one can remove both the rotation and the entangling gates independently after having selected the layer (_independent dropout_). In this last case, we will have two separate drop gate ratios, i.e. one for the rotation (\(p_{R}\)) and one for the entangling (\(p_{E}\)) gates; the dropout probability applied to each type of gate will be \(p=p_{L}p_{G}\), where \(p_{G}=p_{R}\) for the rotation gates and \(p_{G}=p_{E}\) for the entangling gates.

## IV Results

In this Section, we apply quantum dropout in all its different flavours to avoid overfitting in both regression and classification tasks. We performed three different experiments to evaluate the goodness of the proposed quantum dropout methods in a noiseless simulation setting. The first two experiments concerned regression tasks, while the third was about a binary classification problem. Interestingly, unlike classical dropout, quantum dropout does not benefit from parameter rescaling and, consequently, we analyse the learning performances without it. In fact, in Sec. IV.5 we show evidence that scaling the parameters at best gives the same performance of not rescaling at all.

More in detail, we address the regression on a dataset

\begin{table}
\begin{tabular}{l c c l} \hline \hline Name & Gates to drop & \(p_{G}\) & Rule \\ \hline Canonical & \(R_{G}\), \(E_{G}\) & \(p_{R}\) & Drop a single \(R_{G}\), all previous \(E_{G}\)s with target on \(R_{G}\), all next \(E_{G}\)s with control on \(R_{G}\). \\ Canonical-forward & \(R_{G}\), \(E_{G}\) & \(p_{R}\) & Drop a single \(R_{G}\), all next \(E_{G}\)s with control on \(R_{G}\). \\ Rotation & \(R_{G}\) & \(p_{R}\) & Drop a single \(R_{G}\). \\ Entangling & \(E_{G}\) & \(p_{E}\) & Drop a single \(E_{G}\). \\ Independent & \(R_{G}\), \(E_{G}\) & \(p_{R}\), \(p_{E}\) & Drop a single \(R_{G}\) and a single \(E_{G}\). \\ \hline \hline \end{tabular}
\end{table}
Table 1: Quantum dropout strategies. Rotation and entangling gates are represented as \(R_{G}\) and \(E_{G}\), respectively. \(p_{G}\) is employed together with \(p_{L}\) to obtain the dropping probability \(p=p_{G}p_{L}\).
generated by a sinusoidal function, which is a common and straightforward benchmark for neural models and then we test the performances of the dropout on another synthetic dataset generated by the modulus function (reported in Appendix C). Since our general approach includes as a subcase the entangling dropout [44], a performance evaluation of general quantum dropout on the same datasets was appropriate. Finally, in the third experiment, we tackle a more challenging problem related to the binary classification of the Moon dataset retrieved on the scikit-learn library, which has a non-trivial geometric arrangement of data points. We want to investigate the behaviour of different dropout strategies in a non-linear classification setting to demonstrate the robustness of our proposed methodologies experimentally. Afterwards, we discuss the relationship between quantum dropout and features of the QNN circuit like expressibility and entanglement [22; 27].

### Regression of sinusoidal function

In this experiment, we tackle in detail the sin regression problem. The analytical expression of the function under exam is the following:

\[y=\sin(\pi x)+\epsilon\,, \tag{6}\]

where \(x\in[-1,1]\) and \(\epsilon\) is an additive white Gaussian noise with amplitude equal to \(0.4\), zero mean and a standard deviation of \(0.5\). An extensive analysis of the results is illustrated in Fig. 3; for each dropout model, the best configuration of \(p_{L}\), \(p_{R}\) and \(p_{E}\) is reported, where \(p_{L}\) refers to the layer dropout rate, \(p_{R}\) to the rotation dropout rate and \(p_{E}\) to the entangling dropout rate. The Mean Squared Error (MSE) obtained by the model without dropout is almost \(0\) in the training set but it is remarkably high in the test set, which is a clear indicator of overfitting. On the contrary, all quantum dropout techniques do not exhibit signs of overfitting in their bests configurations: the errors on the training set and test set are comparable to each other and way lower than the test error of the overfitting model without dropout, highlighting the effectiveness of these techniques. Independent dropout on average (over \(10\) different runs) achieves the best MSE of \(0.032\) on the test set, followed by canonical-forward and rotation dropout, and is \(71.4\%\) lower than the one achieved by the model without dropout. It is not surprising that independent obtains the best performances, since the three hyperparameters (\(p_{L}\), \(p_{R}\), \(p_{E}\)) search is more exhaustive (and costly) with respect to the other methods leading to a higher-quality dropout. The test error obtained by entangling dropout is \(25.3\%\) higher than the one of independent, although it is still comparable. However, the standard deviation of entangling dropout in the test set is large and suggests that this approach may be less robust to random initializations. This may be related to the fact that these gates are not parametrized, in fact also canonical dropout has a considerable standard deviation. For the regression QNN eq. (5) allows to determine that about \(60\%\) of the parameters can be removed while still having an over-parametrized model. Considering the optimal drop ratios in Fig. 3, the best dropout probabilities are within the range of \(5\%\) to \(8\%\). Such a result indicates that small dropout ratios are enough for quantum circuits to avoid overfitting while maintaining the ability to effectively learn from the data.

Taking as a reference the independent dropout, namely the best-performing approach among the ones proposed, a further analysis of the results is reported in Fig. 2. Fig. 2a shows how independent dropout actually mitigates overfitting and makes the prediction of the underlying sin function way smoother than the one performed by the overfitting QNN, which in contrast is highly affected by noise. The benefits of applying dropout are also demonstrated by the convergence of the train and test losses in Fig. 2b: the ones of the model with dropout almost converge to the same MSE value after \(1000\) epochs, whereas the train and test losses of the model without dropout exhibit clear signs of overfitting and have very distinct average MSE values of \(1.32\cdot 10^{-5}\) and \(1.11\cdot 10^{-1}\) respectively, which differs by four orders of magnitude. Moreover, the test loss of the model without dropout has also a higher standard deviation compared to the other cases, meaning that it is more sensitive to changes in the input data and may indicate instability in the model.

### Regression of the modulus function

Here, we briefly discuss the module regression problem while relegating a more detailed analysis with the relative plots in Appendix C. The function under study is:

\[y=|x|-\frac{1}{2}+\epsilon\,, \tag{7}\]

where \(x\in\mathbb{R}\) and \(\epsilon\) is still an additive white Gaussian noise with amplitude equal to \(0.3\), zero mean and a standard deviation of \(0.5\). Using quantum dropout helps to achieve better generalization also for this kind of function. In this case, a pronounced standard deviation in the generalization performances is obtained, and this can be attributed to the Gibbs phenomenon [50]. The model without dropout overfits with almost \(0\) training MSE and high test error. Conversely, all quantum dropout techniques demonstrate low and comparable errors, both on the training and test sets, indicating their effectiveness in preventing overfitting compared to the model without dropout. The Independent dropout model still gets the best performance in terms of test error. The standard deviation of all quantum dropout models is lower than the standard deviation of the overfitted model after \(10\) runs, indicating that the quantum dropout models have better generalization performance. As in the sin function experiment, also here the gate drop ratios are very low, typically between \(6\%\) and \(16\%\).
### Classification

We now address a more difficult problem, i.e., the binary classification task of the Moons dataset with the addition of a further Gaussian noise with amplitude equal to 1, zero mean and a standard deviation of 0.2. In order to show that quantum dropout actually works for different QNN models, we hereby make use of a different QNN architecture with respect to the one employed for the regression, described in detail in Appendix A. The main difference lies in the kind of entangling gates employed, which are parametrized and consequently, all the dropout strategies removing entangling gates will directly have an impact on trainable parameters. In addition, this architecture is composed of 20 layers where only one variational sublayer per each data-reuploading is present. This last artifice helps achieve a high level of overfitting with a non-trivial dataset.

Following the same steps done in the previous sections, we report in Fig. 5 a comparison of the generalisation capabilities of the model trained with all the dropout strategies in their optimal configuration (best \(p_{L}\), \(p_{R}\), \(p_{E}\) are displayed) with respect to the standard training procedure. In addition, we show the different performances, expressed as Categorical Cross Entropy (CCE) and Accuracy, between the QNN with the best quantum dropout technique and the one without dropout in Fig. 4.

Similarly to the regression case, Fig. 5 reveals that dropout succeeds in removing overfitting in all the employed fashions with comparable performances. Moreover, in this case, we notice good convergence for all the strategies, witnessed by small standard deviation values with respect to the mean value of the loss function (this holds also for accuracy, as a consequence). It has to be noticed that the canonical-forward technique does coincide with the canonical one since the QNN employed in this problem has only one variational sublayer per each layer (see Appendix A) and this is why in Fig. 5 we only show canonical dropout performance. Interestingly, the optimal drop probabilities here are smaller than in regression problems, ranging from 1% to 6%. Independent dropout again achieves the best performance, diminishing the test loss of about 32.5%, whereas the entangling dropout is slightly worse than the others being the only one reducing the test CCE less than 30%. The hierarchies

Figure 3: **Regression** Bar chart comparing the final average performances of all the dropout strategies on the sin dataset with their respective optimal hyperparameters. The standard deviation is taken over 10 different runs.

Figure 2: **Regression** The plots illustrate the performances of an overparametrized model employed in a regression task of the sin function. **(a)** The model without dropout overfits the noisy data by predicting exactly each of them, whereas with dropout the approximate function is smoother. **(b)** The trend of the loss function when training without dropout shows an increasing prediction error typical of an overfitting model, while with dropout the prediction error does not increase. The standard deviation over 10 different runs is shown as a shadow.
are the same also for what concerns the standard deviation: independent dropout has the tiniest one, whereas entangling presents the largest standard deviation. We stress that if on the one hand independent dropout is able to achieve the best performances, on the other hand, it requires a much more intense parameter search with respect to the other strategies.

From Figs. 3(a)-b one can really understand the effectiveness of quantum dropout in removing overfitting: both the test loss and Accuracy smoothly follow the trend of their respective training counterpart with low standard deviation. Conversely, in the case without dropout the test loss and Accuracy depart from the training ones after 1000 epochs with high standard deviation. Here we report these trends only for the overall best technique, but all the other dropout configurations (in terms of \(p_{L}\) and \(p_{G}\)) displayed in Fig. 5 show completely analogous behaviours.

### Entanglement and expressibility

The expressibility and entangling capability [22; 27] of a QNN do depend on the structure of the chosen ansatz and, in particular, this is strongly related to the kind and number of rotations and entangling gates of which it is composed. The here proposed quantum dropout techniques randomly remove some gates in the circuit during the training process of overparametrized QNNs. In the following, differently from what conjectured in [44], we show that expressibility and entangling capability are not affected by dropout even for high values of dropout ratio (see Figs. 6) for the overparametrized QNN proposed in their work and employed in the regression tasks here. This ensures that expressibility and entanglement are not lowered also in the regime with small dropout rates, i.e. removing few gates, in which one usually operates. Expressibility measures the circuit's ability to produce states that are well representative of the Hilbert space and to quantify it we follow the guidelines drawn in [22]. The entangling capability, instead, is quantified as the mean concentric entanglement [47] produced, which is a measure of multipartite entanglement directly computed on a quantum computer. In addition, for the sake of completeness, we report in the appendix a similar analysis for the other QNN used in the classification

Figure 4: **Classification** The plots illustrate the performances of the second QNN employed in a classification task of the Moons dataset. **(a)** Standard training shows an increasing prediction error, expressed as CCE, typical of an overfitting model, while with dropout the prediction error keeps decreasing. **(b)** A similar behaviour can be found in the accuracy of the predictions. The standard deviation over 10 different runs is shown as a shadow.

Figure 5: **Classification** Bar chart comparing the final average performances of all the dropout strategies on the Moons dataset with their respective optimal hyperparameters. The standard deviation is taken over 10 different runs.
problem confirming the same findings also for another QNN architecture.

The QNN model we are working with has elevated expressibility (see Appendix D) and in addition is highly overparametrized (see Appendix B). In this regard, applying quantum dropout around the optimal operating regime is very unlikely to reduce the expressibility directly. In fact, the drop ratios in all the possible dropout strategies presented in Fig. 3 are not very high, implying that only a few gates are dropped in each epoch of the training phase. On the opposite, to decrease the expressibility one should affect the parameter dimension \(D\) (defined in Sec. II.2), making the QNN underparametrized, but using eq. (5) with \(M=150\), more than \(M-D_{max}=88\) rotation gates should be removed, recalling that \(D_{max}=2^{N+1}-2\) is the maximal parameter dimension and accounts for the minimal number of parameters required to explore the whole Hilbert space. This would correspond to about \(60\%\) of the parameters of the model with \(10\) layers. From Fig. 6a, one can capture that a \(50\%\) dropout does not have an impact on the expressibility of the model, with exception made for the cases with less than \(5\) layers; above this threshold the model is overparametrized and the expressibility has the same value as the model without dropout.

In [44] it is argued that quantum dropout outperforms \(L_{1}\) and \(L_{2}\) regularization due to its ability to limit the expressibility of the model. They also suggest that regularization allows full model expressibility, consequently necessitating a higher number of training epochs to reach an optimal solution. Here we show that these assertions are false. To start with, our findings indicate that quantum dropout does not curtail the model's expressibility, as indicated in Fig. 6a. On the contrary, it introduces a form of structured randomness into the quantum model, effectively helping it avoid overfitting without limiting its ability to represent complex functions. Secondly, \(L_{1}\) and \(L_{2}\) regularization methods work by adding a penalty term to the loss function, which encourages the model to keep its parameters small, as highlighted in [44] Sec. 3.4. Therefore, adopting this approach during the training of a QNN may be very restrictive as it does not allow the full exploration of the Hilbert space [38]: by coercing parameter values to zero, regularization may limit the expressibility of the quantum model, which is exactly the opposite of what the authors in [44] suggested.

The regression QNN architecture with \(10\) layers produces an average level of multipartite entanglement which is slightly above the Genuine Multipartite Entanglement (GME) threshold (the same holds for the classification QNN as reported in Appendix E), see Fig. 6b. Even in the case of entanglement applying dropout with a probability of about \(50\%\) does not reduce its average level at the depth utilised for the learning task. The final average value of entanglement reached with \(10\) layers is the one expected for random states (Haar states) and this witnesses again that the QNN has high expressibility and that quantum dropout does not hinder expressibility. For both expressibility and entanglement, we estimated average and standard deviation from \(15000\) states. See Appendices D and E for further details on these calculations.

So, a natural question will be: why does the quantum dropout work if it does not modify the QNN features on average? To understand this we have to interpret the quantum dropout as sampling a different sub-architecture from the original QNN at each training step, leading to training a whole ensemble at the same time. Just like classical dropout, this prevents hidden units (rotations in the QNN) from relying too much on their neighbourhoods. However, the rotations belonging to the same layer (or sub-layer) still have different roles in changing the state. Consequently, quantum dropout does not work well with excessively high drop ratios because, in that case, we will have very different models producing different results at each epoch and this will definitely not help the optimization process.

### Parameters scaling

To completely match classical and quantum dropout, one should scale the weights in the layers where dropout was applied by a quantity \(s=1-p\), i.e. the probability of the computational units being active during training [6]. This ensures that the expected output of a computational unit during inference is the same as its expected output during training, i.e., it guarantees that the average output is the same for both training and inference. In classical NNs, the scaling helps in maintaining the statistical properties of the network and ensures that the network produces consistent and reliable results during inference.

We now show that for deep QNNs the scaling factor \(s\) is not the same as in the classical case. Interestingly, our experiments have shown that by _not rescaling_ the parameters one achieves (on average) better results compared to the ones obtained by scaling with the classical linear scaling factor. To illustrate this finding, we have included a comparison of test errors obtained with and without rescaled parameters in our experiments, as shown in Fig. 7a, c, e. We find either negligible differences or no discernible change in the error rate across all quantum dropout strategies; the only exception is canonical-forward in the module regression task, which nevertheless shows a very little but not statistically significant improvement with classical rescaling.

This general behaviour may be related to the fact that any change on one qubit could affect all the others, since we are working with qubits that in principle share multipartite entanglement, as explained above. Further details on the entanglement of the employed ansatz can be found in Appendix E. In addition, in a QNN we consider as neurons the rotations but, in practice, the units of computations are only the \(N\) qubits on which we act multiple times and this is a strong difference from classical NNs. Taking these two facts into account, one intu
itive explanation could be that if we scale a parameter, the scaling factor is propagated across the whole structure to some extent multiplicatively. In this picture, to obtain the same effect of the classical scaling one might apply a scaling factor which is the \(k\)-root of the classical one, where \(k\) is some real number possibly dependent on the concentrable entanglement [47] in the QNN, which is directly related to the number of qubits N. Since \(p\leq 1\), if \(k>>1\implies 1/k\approx 0\) leads to:

\[s=(1-p)^{1/k}\approx 1\,, \tag{8}\]

corresponding to not scaling the parameters. We extended our analysis by exploring the use of a \(k\)-root attenuating factor for rescaling, as shown in Fig. (b)b, d, f. These results confirm our previous finding that rescaling does not provide any significant advantage in terms of generalization, because the general trend for all the quantum dropout strategies is to enhance the performance as \(k\) grows, i.e. \(s\) tends to 1. The canonical-forward strategy in the regression tasks is the only exception to this trend: we observed a slight yet not significant improvement in performance at \(k=2\) for the sin dataset and at \(k=1\) for the module dataset.

In order to fully comprehend the mechanism behind quantum dropout and to unlock its potential as in the classical case, future works should dive deeper into the relationship between parameters scaling and entanglement within the QNN model.

## V Conclusions

Starting from the comparison between classical and quantum NNs, we have proposed a general approach to exploit the dropout technique to avoid overfitting in learning with QNNs. In this framework, depending on the dropped unitary operations, we define and apply different quantum dropout strategies. Our results generalize and include special cases that are already present in the literature, such as entangling dropout [44]. In particular, our results highlight the importance of dropping parametrized operations, leading to improved generalization performance with respect to the case without dropout as well as to entangling dropout. In addition, aware of the importance of having an overparametrized QNN, we also provide guidelines on how to determine the maximally allowed dropout probability.

In addition, we investigate for the first time the detailed behaviour of genuine QNN features upon quantum dropout application. Our analysis reveals that these techniques seem to better mitigate overfitting with moderate dropout probabilities, differently from the classical case where typical probability values are in the order 50-80%. In this working regime, quantum dropout does not reduce expressibility nor entanglement, as the QNN is still highly overparametrized. These findings are in contrast with conjectures previously made in the literature about the effectiveness of entangling dropout [44].

Last but not least, we show that quantum dropout does not require parameter rescaling, differently from the classical dropout technique applied to NNs. Interestingly, the performance is often actually worse when the variational parameters are rescaled.

Figure 6: **(a)** Expressibility (in log scale) of QNN w.r.t. the employed layers. After a few layers, the expressibility is approximately the same for all dropout strategies. **(b)** Degree of concentrable entanglement (CE) produced on average by the QNN w.r.t. the employed layers. The CE soon reaches a plateau, witnessing the presence of a non-trivial amount of GME in the QNN. Even in the case of high drop probability (\(\sim 50\%\)), the mean entanglement produced by the QNN with 10 layers is the same for different dropout strategies.
Figure 7: **Parameters scaling** Barchart comparing the best final performances of the QNNs without and with trained parameters scaling on the **(a)** sin dataset, on the **(c)** module dataset and on the **(e)** moon dataset. Standard deviation over 10 runs. **(b)**, **(d)** Average MSE and **(f)** average CCE trend when scaling the trained parameters with \(s=(1-p)^{1/k}\) as a function of \(k\).
In conclusion, our findings witness that, once the QNN model is fixed, slight random modifications in the structure during the training procedure allow generalization when making inferences with the QNN original model. This work may pave the way for the efficient employment of Deep Quantum Machine Learning Models, thanks to a robust training methodology that encourages generalization.

Future works may investigate the theoretical generalization of quantum dropout more in detail, as well as its effectiveness by running experiments on real quantum hardware. Also, the scaling of performances with an increasing number of qubits and the relationship between parameters rescaling and entanglement produced by the QNN are worth being further investigated.

## VI Methods

To assess the effectiveness of our approach, we conduct two regression tasks and one binary classification task. In every regression experiment, the corresponding dataset (with 20 data samples) was divided into 75% train samples and 25% test samples, whereas for classification we have 50 data samples split into 40% train and 60% test in order to emphasize the overfitting phenomenon. In a data preprocessing phase, raw data were scaled in the range \([-1,1]\) to best suit the input and output of the QNNs; the scaler was fitted using training data only.

To ensure a good and fast convergence, the models were trained with the Adam optimization algorithm [51] and a thorough grid search was conducted to tune the training hyperparameters. For the regression tasks, we observed that different hyperparameters led to similar results and did not impact substantially the outcomes of the experiments. As a consequence, and in order to make a fair comparison among all the QNN models, the hyperparameters remained the same for these experiments. The learning rate was set to 0.01, the number of training epochs was set to 1000 and the QNN was made up of 10 layers for regression. On the other hand, for the classification problem, the number of epochs was set to 5000, whereas the number of QNN layers was increased to 20 due to both the learning task and the different structure of the single layer, as already mentioned in Sec. IV.3.

The drop rates space was extensively analysed in the case of sin dataset through a grid search with \(p_{L}\in[0.1,0.2,\ldots,0.7]\) and \(p_{G}\in[0.1,0.2,\ldots,0.9]\). This choice of hyperparameters was dictated by eq.5 for the regression QNN, for which one can safely drop up to 60% of the parameters (see Appendix B). For the other two datasets, we conducted a more limited and coarse-grained analysis, since we noticed that close drop probabilities led to similar performance and dropping many gates hindered the trainability.

The MSE was selected as the loss function to train the networks and the error metric to evaluate the performances of the models in the regression tasks, as it is more sensitive to larger errors and a standard error metric in supervised learning. CCE was used as loss function for the classification task instead, while Accuracy score was employed as the main error metric to assess the goodness of the classification. In order to prove the robustness of our approach against random parameters initializations, we performed 10 runs of the algorithms for every test case.

The QNN models were implemented in Python 3.8 with PennyLane [52], a framework that supports local simulations of quantum circuits and integration with NN optimization tools. To improve simulation times, we employed the JAX [53] linear algebra framework as the simulation backend. JAX is a software library for high-performance ML research which guarantees a fast and efficient way to execute quantum circuits through automatic differentiation and Just-in-time (JIT) circuit compilation. Due to the difficulty in simulating deep quantum circuits with a high degree of entanglement on local devices, JIT compilation has been particularly beneficial for the simulation of our experiments. A machine equipped with an AMD Ryzen 7" 5800X 8-Core CPU at 3.80 GHz and with 64 GB of RAM was used for the experiments.
