Let Quantum Neural Networks Choose Their Own Frequencies
Parameterized quantum circuits as machine learning models are typically well
described by their representation as a partial Fourier series of the input
features, with frequencies uniquely determined by the feature map's generator
Hamiltonians. Ordinarily, these data-encoding generators are chosen in advance,
fixing the space of functions that can be represented. In this work we consider
a generalization of quantum models to include a set of trainable parameters in
the generator, leading to a trainable frequency (TF) quantum model. We
numerically demonstrate how TF models can learn generators with desirable
properties for solving the task at hand, including non-regularly spaced
frequencies in their spectra and flexible spectral richness. Finally, we
showcase the real-world effectiveness of our approach, demonstrating an
improved accuracy in solving the Navier-Stokes equations using a TF model with
only a single parameter added to each encoding operation. Since TF models
encompass conventional fixed frequency models, they may offer a sensible
default choice for variational quantum machine learning.
Ben Jaderberg, Antonio A. Gentile, Youssef Achari Berrada, Elvira Shishenina, Vincent E. Elfving
# Let Quantum Neural Networks Choose Their Own Frequencies

###### Abstract

Parameterized quantum circuits as machine learning models are typically well described by their representation as a partial Fourier series of the input features, with frequencies uniquely determined by the feature map's generator Hamiltonians. Ordinarily, these data-encoding generators are chosen in advance, fixing the space of functions that can be represented. In this work we consider a generalization of quantum models to include a set of trainable parameters in the generator, leading to a trainable frequency (TF) quantum model. We numerically demonstrate how TF models can learn generators with desirable properties for solving the task at hand, including non-regularly spaced frequencies in their spectra and flexible spectral richness. Finally, we showcase the real-world effectiveness of our approach, demonstrating an improved accuracy in solving the Navier-Stokes equations using a TF model with only a single parameter added to each encoding operation. Since TF models encompass conventional fixed frequency models, they may offer a sensible default choice for variational quantum machine learning.

## I Introduction

The field of quantum machine learning (QML) remains a promising application for quantum computers. In the fault-tolerant era, the prospect of quantum advantage is spearheaded by the exponential speedups in solving linear systems of equations [1], learning distributions [2; 3] and topological data analysis [4]. Yet the arrival of large fault-tolerant quantum computers is not anticipated in the next decade, reducing the practical impact of such algorithms today.

One approach to solving relevant problems in machine learning with today's quantum computers is through the use of parameterized quantum circuits (PQCs) [5; 6], which have been applied to a variety of use cases [7; 8; 9; 10; 11; 12; 13]. A PQC consists of quantum feature maps (FMs) \(\hat{U}_{F}(\vec{x})\), which encode an input \(\vec{x}\) into the Hilbert space, and variational ansatze \(\hat{U}_{A}(\vec{\theta}_{A})\) which contain trainable parameters. Previously, it was shown that the measured output of many variational QML models can be mathematically represented as a partial Fourier series in the network inputs [14], leading to a range of new insights [15; 16; 17]. Most strikingly, it follows that the set of frequencies \(\Omega\) appearing in the Fourier series are uniquely determined by the eigenvalues of the generator Hamiltonian of the quantum FM, while the series coefficients are tuned by the variational parameters \(\vec{\theta}_{A}\).

Conventionally, a specific generator is chosen beforehand, such that the model frequencies are fixed throughout training. In theory this is not a problem, since by choosing a generator that produces regularly spaced frequencies, the basis functions of the Fourier series form a orthogonal basis set. This ensures that asymptotically large fixed frequency (FF) quantum models are universal function approximators [14]. Yet in reality, finite-sized quantum computers will only permit models with a finite number of frequencies. Thus, in practice, great importance should be placed on the _choice_ of basis functions, for which the orthogonal convention may not be the best. This raises the additional complexity: what is the optimal choice of basis functions? Indeed for many problems, it is not obvious what this would be without prior knowledge of the solution. Here we address this issue by exploring a natural extension of quantum models in which an additional set of trainable parameters \(\vec{\theta}_{F}\) are included

Figure 1: An overview of the concepts discussed in this paper. Top: we introduce a parameterized quantum circuit in which the generator of the data-encoding block is a function of trainable parameters \(\vec{\theta}_{F}\), alongside the standard trainable variational ansatz. Left: the output of such a model is a Fourier-like sum over different individual modes. Right: in conventional quantum models, tuning the ansatz parameters \(\vec{\theta}_{A}\) allows the coefficients of each mode to be changed. By using a trainable frequency feature map (TFFM), tuning \(\vec{\theta}_{F}\) leads to a quantum model in which the frequencies of each mode can also be trained.
in the FM generator. This simple idea has a significant impact on the effectiveness of quantum models, allowing the generator eigenspectrum to change over the course of training in a direction that minimises the objective loss. This in turn creates a quantum model with trainable frequencies as visualised in Figure 1. In a quantum circuit learning [6] setting, we numerically demonstrate cases where trainable frequency (TF) models can learn a set of basis functions that better solves the task at hand, such as when the solution has a spectral decomposition with non-regularly spaced frequencies.

Furthermore, we show that an improvement is realisable on more advanced learning tasks. We train quantum models with the differentiable quantum circuits (DQC) algorithm [18] to learn the solution to the 2D time-dependent Navier-Stokes differential equations. For the problem of predicting the wake flow of fluid passing a circular cylinder, a TF quantum model achieves lower loss and better predictive accuracy than the equivalent FF model. Overall, our results raise the prospect that TF quantum models could improve performance on other near-term QML problems.

## II Previous works

The idea of including trainable parameters in the feature map generator is present in some previous works. In a study of FM input redundancy, Gil Vidal et al. [19] hypothesise that a variational input encoding strategy may improve the expressiveness of quantum models, followed by limited experiments [20]. Other works also suggest that encoding unitaries with trainable weights can reduce circuit depths of quantum models, as discussed for single-qubit classifiers [21] and quantum convolutional neural networks [22]. Nevertheless, our work is different due to novel contributions demonstrating (a) an analysis of the effect of trainable generators on the Fourier modes of quantum models, (b) evidence of specific spectral features in data for which TF models offer an advantage over FF models and (c) direct comparison between FF and TF models for a practically relevant learning problem.

In the language of quantum kernels [23; 8; 24], several recent works use the term "trainable feature map" to describe the application of unitaries with trainable parameters on data already encoded into the Hilbert space [25; 26]. Such a distinction is due because quantum kernel models often contain no trainable parameters at all. However, the trainable parameters of these feature maps do not apply directly on the generator Hamiltonian. As discussed in section III, this is intrinsically different to our scheme as it does not lead to a model with trainable frequencies. To not confuse the two schemes, here we adopt the wording "trainable _frequency_ feature map" and "trainable _frequency_ models".

## III Method

Practically, quantum computing entails the application of sequential operations (e.g., laser pulses) to a physical system of qubits. Yet to understand how these systems can be theoretically manipulated, it is often useful to work at the higher-level framework of linear algebra, from which insights can be translated back to real hardware. This allows studying strategies encompassing digital, analog, and digital-analog paradigms [27]. In a more abstract formulation, a broad class of FMs can be described mathematically as the tensor product of an arbitrary number of sub-feature-maps, each represented by the time evolution of a generator Hamiltonian applied on an arbitrary subset of the qubits

\[\hat{U}_{F}(\vec{x})=\bigotimes_{m}e^{-\frac{i}{2}\hat{G}_{m}(\gamma_{m}) \phi(\vec{x})}, \tag{1}\]

where for the sub-feature-map \(m\), \(\hat{G}_{m}(\gamma_{m})\) is the generator Hamiltonian that depends on non-trainable parameters \(\gamma_{m}\). Furthermore, \(\phi(\vec{x}):\mathbb{R}^{n}\rightarrow\mathbb{R}^{n}\) is an encoding function that depends on the input features \(\vec{x}\). Practically speaking, \(\gamma_{m}\) is typically related to the index of the tensor product space the sub-feature-map is applied to and can be used to set the number of unique frequencies the model has access to. Furthermore, in some cases \(\hat{U}_{F}(\vec{x})\) can be applied several times across the quantum circuit, interleaved with variational ansatz \(\hat{U}_{A}(\vec{\theta}_{A})\) layers, for example in data re-uploading [21; 28] or serial feature maps [14].

The measured output of a quantum model with a feature map defined in Eq. (1) can be expressed as a Fourier-type sum in the input dimensions

\[f(\vec{x},\vec{\theta}_{A})=\sum_{\vec{\omega}_{j}\in\Omega}\vec{c}_{j}(\vec {\theta}_{A})e^{i\vec{\omega}_{j}\cdot\phi(\vec{x})}, \tag{2}\]

where \(\vec{c}_{j}\) are the coefficients of the multi-dimensional Fourier mode with frequencies \(\vec{\omega}_{j}\). Crucially, the frequency spectrum \(\Omega\) of a model is uniquely determined by the eigenvalues of \(\hat{G}_{m}\)[14]. More specifically, let us define the final state produced by the PQC as \(|\psi_{f}\rangle\). If the model is a quantum kernel, where the output derives from the distance to a reference quantum state \(|\psi\rangle\) (e.g., \(f(\vec{x},\vec{\theta}_{A})=|\langle\psi|\psi_{f}\rangle|^{2}\)), then \(\Omega\) is explicitly the set of eigenvalues of the composite generator \(\hat{G}\) such that \(\hat{U}_{F}(\vec{x})=e^{-\frac{i}{2}\hat{G}\phi(\vec{x})}\). When the generators \(\hat{G}_{m}\) commute, the composite generator is simply \(\hat{G}=\sum_{m}G_{m}\). If the model is a quantum neural network (QNN), where the output is derived from the expectation value of a cost operator \(\hat{C}\) (e.g., \(f(\vec{x},\vec{\theta}_{A})=\langle\psi_{f}|\hat{C}|\psi_{f}\rangle\)), then \(\Omega\) contains the gaps in the eigenspectrum of \(\hat{G}\).

The key insight here is that in such quantum models, a specific feature map generator is chosen in advance. This fixes the frequency spectrum over the course of training, setting predetermined basis functions \(e^{i\vec{\omega}_{j}\cdot\phi(\vec{x})}\) from
which the model can construct a solution. For these FF models, only the coefficients \(\tilde{c}_{j}\) can be tuned by the variational ansatz during training.

In this work, we replace the FM generator with one that includes trainable parameters \(\hat{G}_{m}(\gamma_{m},\tilde{\theta}_{F})\). In doing so, the generator eigenspectrum, and thus the model frequencies, can also be tuned over the course of training. For this reason we refer to such feature maps as trainable frequency feature maps (TFFMs), which in turn create TF quantum models. The output of a TF quantum model will be a Fourier-type sum where the frequencies of each mode depend explicitly on the parameterization of the feature map. For example, for a QNN the output of the model can be written as

\[f(\tilde{x},\tilde{\theta}_{A},\tilde{\theta}_{F})=\sum_{\tilde{\omega}_{j} \in\Omega}\tilde{c}_{j}(\tilde{\theta}_{A},\hat{C})e^{i\tilde{\omega}_{j}( \tilde{\theta}_{F})\cdot\phi(\tilde{x})}, \tag{3}\]

Moreover, as \(\tilde{\theta}_{F}\) is optimized with respect to minimising a loss function \(\mathcal{L}\), the introduction of trainable frequencies \(\tilde{\omega}_{j}(\tilde{\theta}_{F})\) ideally allows the selection of spectral modes that better fit the specific learning task. For gradient-based optimizers, the derivative of parameters in the generator \(\frac{\partial\mathcal{L}}{\partial\theta_{F}}\) can be calculated as laid out in Appendix A, which for the generators used in our experiments simplifies to the parameter-shift rule (PSR) [17; 29].

We note that the idea here is fundamentally different to simply viewing a combination of feature maps and variational ansatze (e.g., serial feature maps) as a higher level abstraction containing one unitary \(\hat{U}_{F}(\tilde{x},\tilde{\theta})=\hat{U}_{F}(\tilde{x})\hat{U}_{A}( \tilde{\theta})\). The key concept in TF models is that a parameterization is introduced that acts directly on the generator Hamiltonian in the exponent of Eq. (1). This is what allows a trainable eigenvalue distribution, leading to quantum models with trainable frequencies.

Furthermore, in this work the FF models we consider are those in which the model frequencies are regularly spaced (i.e., integers or integer valued multiples of a base frequency), such that the basis functions form an orthogonal set. This has become the conventional choice in the literature [30; 31; 32; 33; 34; 12; 35], owing to the theoretical grounding that such models are universal function approximators in the asymptotic limit [14]. However, it should be made clear that a FF model could mimic any TF model if the non-trainable unitaries in the FM were constructed with values corresponding to the final trained values of \(\tilde{\theta}_{F}\). The crux however, is that having knowledge of such values without going through the training process is highly unlikely, and might only occur where considerable a-priori knowledge of the solution is available.

## IV Proof of principle results

The potential advantage of TF quantum models stem their ability to be trained such that their frequency spectra contain non-uniform gaps, producing non-orthogonal basis functions. We demonstrate this effect by first considering a fixed frequency feature map (FFFM) where for simplicity we restrict \(\hat{G}_{m}\) to single-qubit operators. Overall we choose a generator Hamiltonian \(\hat{G}=\sum_{m=1}^{N}\gamma_{m}\hat{Y}^{m}/2\), where \(N\) is the number of qubits, \(\hat{Y}^{m}\) is the Pauli matrix applied to the tensor product space of qubit \(m\), \(\gamma_{m}=1\), and \(\phi(\tilde{x})=x\) is a 1-D Fourier encoding function. This is the commonly used angle encoding FM [36], which we use to train a QNN to fit data produced by a cosine series

\[y(x)=\frac{1}{|\Omega_{d}|}\sum_{\omega_{d}\Omega_{D}}\cos(\omega_{d}x). \tag{4}\]

Here the data function contains a set of frequencies \(\Omega_{d}\), from which \(n_{d}\) data points are generated equally spaced in the domain \(\mathcal{D}=[-4\pi,4\pi]\). The value of \(n_{d}\) is determined by the Nyqvist sampling rate such that \(n_{d}=[2|\mathcal{D}|\max(\Omega_{d})]\).

Figure 2 demonstrates where FF models succeed and fail. In these experiments, a small QNN with \(N=3\) qubits and \(L=4\) variational ansatz layers is used. More details of the quantum models and training hyperparameters for all experiments can be found in Appendix B.

The FF QNN defined above is first trained on data with frequencies \(\Omega_{d}=\{1,2,3\}\). After training, the prediction of the model is recorded as shown in Figure 2a. Here we see the underlying function can be perfectly learned. To understand why, we note that the set of degenerate eigenvalues of \(\hat{G}\) are \(\lambda=\{-\frac{3}{2},-\frac{1}{2},\frac{1}{2},\frac{3}{2}\}\) and thus the unique gaps are \(\Delta=\{1,2,3\}\). In this case, the natural frequencies of the model \(\Delta\) are equal to the frequencies of the data \(\Omega_{d}\), making learning trivial. Furthermore, we find that similar excellent fits are possible for data containing frequencies that differ from the natural model frequencies by a constant factor (e.g., \(\Omega_{d}=\{1.5,3,4.5\}\)), provided the quantum model is given the trivial classical resource of parameters that can globally scale the input \(x\).

By contrast, Figure 2b illustrates how a FF QNN fails to fit data with frequencies \(\Omega_{d}=\{1,1.2,3\}\). This occurs because no global scaling of the data can enable the fixed generator eigenspectrum to contain gaps with unequal spacing. In such a setting, no additional training would lead to accurate fitting of the data. Furthermore, no practical number of extra ansatz layers would enable the FF model to fit the data (see section VI for further discussion), for which we verify up to \(L=128\).

Conversely, a QNN containing a TFFM with simple parameterization \(\hat{G}_{\theta}=\sum_{m=1}^{N}\theta_{m}\hat{Y}^{m}/2\) does significantly better in fitting the data. This is precisely possible because training of the generator parameters converges on the values \(\tilde{\theta}_{F}=\{0.89,1.05,1.04\}\), leading to an eigenvalue spectrum which contains gaps \(\Delta_{\theta}=\{...,0.95,1.050,1.200,3.000,...\}\) as shown in Figure 2c. In this experiment and all others using TF models, the TFFM parameters are initialised as the unit vector \(\tilde{\theta}_{F}=\mathds{1}\).
A further advantage of TF models is their flexible spectral richness. For FF models using the previously defined \(\hat{G}\), one can pick values \(\gamma_{m}=1\), \(\gamma_{m}=m\) or \(\gamma_{m}=2^{(m-1)}\) to produce generators where the number of unique spectral gaps \(|\Omega|\) scales respectively as \(\mathcal{O}(N),\mathcal{O}(N^{2})\) and \(\mathcal{O}(2^{N})\) respectively. Typically, a practitioner may need to try all of these so-called simple, tower [18] and exponential [13] FMs, yet a TFFM can be trained to effectively represent any of these. To test this, we again sample from Eq. (4) to construct 7 data sets that contain between 1 and 7 frequencies equally spaced in the range \(\omega_{d}\in[1,3]\).

Figure 3 shows the mean squared error (MSE) achieved by each QNN across these data sets. In the best case, the TF and FF models perform equally well, since each fixed generator produces a specific number of frequencies it is well suited for. However, we find that a TF model outperforms FF models in the average and worst-case scenarios. Despite the data having orthogonal basis functions, the FF models have either too few frequencies (e.g., simple FM for data with \(|\Omega_{d}|>3\)) or too many (e.g., exponential FM for data with \(|\Omega_{d}|<7\)) to perform well across all data sets. Thus, we find that even when the optimal basis functions are orthogonal, TF models can be useful when there is no knowledge of the ideal number of spectral modes of the solution.

## V Application to fluid dynamics

In this section we demonstrate the impact of TF models on solving problems of practical interest. Specifically, we focus on the DQC algorithm [18], in which a quantum model is trained to find a solution to a partial differential equation (PDE). The PDE to be solved is the incompressible 2D time-dependent Navier-Stokes equations (NSE), defined as

\[\frac{\partial u}{\partial t}+u\frac{\partial u}{\partial x}+v \frac{\partial u}{\partial y}-\frac{1}{Re}\left(\frac{\partial^{2}u}{\partial x ^{2}}+\frac{\partial^{2}u}{\partial y^{2}}\right)+\frac{\partial p}{\partial x }=0, \tag{5}\] \[\frac{\partial v}{\partial t}+u\frac{\partial v}{\partial x}+v \frac{\partial v}{\partial y}-\frac{1}{Re}\left(\frac{\partial^{2}v}{\partial x ^{2}}+\frac{\partial^{2}v}{\partial y^{2}}\right)+\frac{\partial p}{\partial y }=0, \tag{6}\]

where \(u\) and \(v\) are the velocity components in the \(x\) and \(y\) directions respectively, \(p\) is the pressure and \(Re\) is the Reynolds number, which represents the ratio of inertial forces to viscous forces in the fluid.

The goal of this experiment is to train a quantum model to solve the downstream wake flow of fluid moving past a circular cylinder. This is one of the canonical systems of study in physics-informed neural networks (PINNs), the classical analogue of DQC, due to the vortex shedding patterns and other complex dynamics exhibited even in the laminar regime [37; 38; 39]. A high-resolution data set for \(Re=100\) is obtained from [37] for the region \(x=1\) to \(x=8\) downstream from a cylinder at \(x=0\), solved using the NekTar high-order polynomial finite element method (FEM) [40; 41].

Figure 3: Prediction MSE of simple, tower and exponential FFFMs compared to a TFFM when training on multiple data sets with equally spaced frequencies \(\tilde{\omega_{d}}\in[1,3]\). For each box, the triangle and orange line denote the mean and median respectively.

Figure 2: Fitting cosine series of different frequencies using fixed frequency (FF) and trainable frequency (TF) QNNs. (a) Prediction after training on data with \(\Omega_{d}=\{1,2,3\}\) (b) Prediction after training on data with \(\Omega_{d}=\{1,1.2,3\}\). (c) Spectra of trained models in (b) as obtained using a discrete Fourier transform. The blue dashed lines indicate frequencies of the data.
The quantum model is trained through minimising the loss \(\mathcal{L}=\mathcal{L}_{\text{PDE}}+\mathcal{L}_{\text{data}}\). To obtain \(\mathcal{L}_{\text{PDE}}\), the LHS of equations (5) and (6) are evaluated for each collocation point and the MSEs with respect to \(0\) are computed, the sum of which gives \(\mathcal{L}_{\text{PDE}}\). Meanwhile, \(\mathcal{L}_{\text{data}}\) is computed as the MSE to a small subset of training data. In this case, only \(1\%\) of the reference solution is given as a form of data-driven boundary conditions, whilst the remainder of the flow must be predicted through learning a solution that directly solves the NSE.

Given the increased problem complexity compared to section IV, here we employ a more advanced quantum architecture. The overall model consists of two QNNs, the output of which represent the stream function \(\psi\) and pressure \(p\) respectively. The introduction of \(\psi\), from which the velocities can be obtained via the relations

\[u =\frac{\partial\psi}{\partial y} v =-\frac{\partial\psi}{\partial x},\]

ensures that the mass continuity equation is automatically satisfied, which would otherwise require a third term in the loss function. The architecture of each QNN, consisting of \(N=6\) qubits, is shown in Figure 4. First, a single ansatz layer \(\hat{U}_{A}(\vec{\theta}_{A})\) is applied, followed by a TFFM which encodes each dimension \((x,y,t)\) in parallel blocks. Each dimension of the TF encoding once again uses the simple parameterization \(\hat{G}_{\theta}=\sum_{m=1}^{N}\theta_{m}\hat{Y}^{m}\!/2\), whilst the FF model uses the same generator without trainable parameters \(\hat{G}=\sum_{m=1}^{N}\hat{Y}^{m}\!/2\). After the FM, a sequence of \(L=8\) ansatz layers are then applied. Subsequently a data-reuploading feature map is applied, which is a copy of the TFFM block including sharing the parameters. Finally, the QNN architecture ends with a single ansatz layer. Overall, each QNN has a circuit depth of \(52\) and \(180\) trainable ansatz parameters.

Figure 5 gives a visualization of the results of this experiment, where the pressure field at a specific time is compared. Here the quantum models are trained for 5,000 iterations; more details can be found in Appendix B. The left panel shows the reference solution for the pressure \(p\) at time \(t=3.5\). Here, the \(10\times 5\) grid of cells with red borders correspond to the points that are given to the quantum models at each time step to construct \(\mathcal{L}_{\text{data}}\), overall \(1\%\) of the total \(100\times 50\) grid. The middle panel illustrates the prediction of the TF QNN. Whilst the model does not achieve perfect agreement with the reference solution, it captures import qualitative features including the formation of a large negative-pressure bubble on the left and an additional two separated bubbles on the right. By contrast, the FF QNN solution only correctly predicts the global background, unable to resolve the distinct different regions of pressure that form as fluid passes to the right. This demonstrates just how impactful TFFMs can be on the expressiveness of quantum models, even with limited width and depth. Further still, we show in Appendix C how deeper TF models can match the FEM solution whilst FF models cannot.

To quantify this benefit, the mean absolute error relative to the median (MAERM) \(\frac{1}{M}\sum_{i=1}^{M}\left|\frac{\hat{y}_{i}-\hat{y}_{i}}{\hat{y}}\right|\) is calculated for each time step and observable, where the sum spans the \(M\) spatial grid points. The results, presented in Table 1, numerically demonstrate the improved performance of the TF model across all observables and time steps. Particularly notable is the large improved accuracy for the vertical velocity \(v\).

Finally, it is worth considering how the inclusion of additional trainable parameters into a quantum model affects the cost of training. For a gradient-based optimizer such as Adam, each training iteration requires the calculation of \(\partial L/\partial\theta_{i}\) for all trainable parameters \(\theta_{i}\) in the

Figure 4: Circuit diagram of the trainable frequency (TF) QNN architecture used in experiments solving the Navier-Stokes equations. The trainable frequency feature map (TFFM, dashed box) contains the generator parameters \(\theta_{F}\) that allow training of the underlying model frequencies. The TFFM is followed by \(L=8\) ansatz layers, a data-reuploading and then a final ansatz layer before the qubits are measured. Here, we study both digital and digital-analog versions of such layered abstraction.
circuit. If one were to calculate these gradients on real quantum hardware, the PSR would need to be used. For the quantum architecture used in this section, all parameterized unitaries decompose into single-qubit Pauli rotations, such that only two circuit evaluations are required to compute the gradient of each parameter in \(\tilde{\theta}_{A}\) and \(\tilde{\theta}_{F}\). Thus, it is easy to calculate that a factor of \(C_{f}=\frac{|\tilde{\theta}_{F}|+|\tilde{\theta}_{A}|}{|\tilde{\theta}_{A}|}\) more circuit evaluations are required to train the TF model. For the models used in this section, the cost factor is \(C_{f}=\frac{12+180}{180}=1.07\). This represents only a 7% increase in the number of quantum circuits evaluated, a modest cost for the improvement in performance observed.

## VI Discussion

In this work we explore an extension of variational QML models to include trainable parameters in the data-encoding Hamiltonian, compatible with a wide range of models including those based on digital and digital-analog paradigms. As introduced in section III, when viewed through the lens of a Fourier representation, the effect of such parameters is fundamentally different to those in the variational ansatz, as they enable the frequencies of the quantum model to be trained. Furthermore, in section IV we showed how this leads to quantum models with specific spectral properties inaccessible to the conventional approach of only tuning the coefficients of fixed orthogonal basis functions. Finally, in section V we demonstrated the benefit of TF models for practical learning problems, leading to a learnt solution of the Navier-Stokes equations closer to the ground truth than FF models.

We note that, in theory, a FF model could also achieve parity with TF models if it had independent control of the coefficients of each basis function. Given data with a minimum frequency gap \(\Delta_{d,\min}\) and spanning a range \(r_{d}=|\Omega_{d,\max}-\Omega_{d,\min}|\), a quantum model with \(\frac{r_{d}}{\Delta_{d,\min}}\) fixed frequencies could span all modes of the data. In this case, such a model could even represent data with non-regularly spaced frequencies (e.g., \(\Omega_{d}=\{1,1.2,3\}\) by setting the coefficients \(\tilde{c}_{j}=0\) for \(\tilde{\omega}_{j}=\{1.1,1.3,1.4,...,2.9\}\)). However, such a model would be exponentially costly to train, since independent control of the coefficients of the model frequencies would generally require \(\mathcal{O}(2^{N})\) ansatz parameters. It is for this reason that we present TF models as having a practical advantage, within the context of scalable approaches to quantum machine learning.

Looking forward, an interesting open question remains around the performance of other parameterizations of

Figure 5: Pressure field at \(t=3.5\) of the wake flow of fluid passing a circular cylinder at x=0. Left: reference solution obtained by finite-element method (FEM) in [37]. Cells with red borders indicate the training data accessible to the quantum models, see main text. Middle: prediction of trainable frequency (TF) QNN using generators \(\hat{G}_{\theta}\). Right: prediction of fixed frequency (FF) QNN using generators \(\hat{G}\). The quantum circuits are based on a sliced Digital-Analog approach (sDAQC [27]) suitable for platforms such as neutral atom quantum computers.

\begin{table}
\begin{tabular}{|c|c|c|c|c|c|} \hline  & \multicolumn{2}{c|}{u} & \multicolumn{2}{c|}{v} & \multicolumn{2}{c|}{p} \\ \hline  & FF & **TF** & FF & **TF** & FF & **TF** \\ \hline Min & \(16.8\pm 0.3\) & \(\mathbf{12.8\pm 1.9}\) & \(90.3\pm 2.6\) & \(\mathbf{27.4\pm 3.3}\) & \(62.9\pm 1.9\) & \(\mathbf{51.0\pm 6.0}\) \\ \hline Max & \(18.3\pm 0.4\) & \(\mathbf{14.2\pm 3.0}\) & \(122.0\pm 2.4\) & \(\mathbf{34.3\pm 4.6}\) & \(78.3\pm 1.8\) & \(\mathbf{62.8\pm 10.3}\) \\ \hline Mean & \(17.5\pm 0.3\) & \(\mathbf{13.2\pm 2.0}\) & \(103.2\pm 1.4\) & \(\mathbf{30.4\pm 2.7}\) & \(73.2\pm 1.9\) & \(\mathbf{57.0\pm 3.7}\) \\ \hline \end{tabular}
\end{table}
Table 1: MAERM error predicting \(u\), \(v\) and \(p\) averaged over 10 runs. The minimum, maximum and mean are with respect to the 11 time points between \(t=0\) to \(t=5.5\).
the generator. A notable instance of this would be \(\hat{G}=\sum_{m=1}^{N}\text{NN}(\theta_{F})\hat{Y}^{m}/2\), where the parameterization is set by a classical neural network. Interestingly, this has already been implemented in a different context in so-called hybrid quantum-classical networks [42; 43; 44; 45], including studies of DQC [46]. The use of hybrid networks is typically motivated as relieving the computational burden off today's small-scale quantum models. Our work offers the insight that such architectures are actually using a classical neural network to set the frequencies of the quantum model.

Compellingly, for many different parameterizations of TFFMs, a generator with regularly spaced eigenvalues is accessible within the parameter space. This is particularly true for the parameterizations studied in this work, which can be trivially realised as an orthogonal model when \(\widetilde{\theta}_{F}=\mathds{1}\). This implies that, at worst, many classes of with TF models can fall back to the behaviour of standard FF models. We find this, along with our results, a strong reason to explore in the future whether TF models could be an effective choice as a new default for variational quantum models.

## Appendix A Computing derivatives of trainable parameters in the generator

Training a variational quantum circuit often involves performing gradient-based optimization against the trainable parameters of the ansatz. In this section we make clear how in the case of TF models, the trainable parameters in the generator can also be optimised in the same way. For gradient-based optimization, one needs to compute \(\frac{\partial\mathcal{L}}{\partial\theta}\), for a suitably defined loss function \(\mathcal{L}\) which captures the adherence of the solution \(f(x)\) to the conditions set by the training problem.

Let us first define the state produced by a TF quantum model as

\[|f_{\theta_{F},\tilde{\theta}_{A}}(x)\rangle=\hat{U}_{A}(\vec{\theta}_{A}) \hat{U}_{F}(x,\vec{\theta}_{F})|0\rangle. \tag{10}\]

The output of the quantum models used in the main text, given as the expectation value of a cost operator \(\hat{C}\)

\[f(x,\vec{\theta}_{F},\vec{\theta}_{A})=\langle f_{\theta_{F},\tilde{\theta}_ {A}}(x)|\hat{C}|f_{\theta_{F},\tilde{\theta}_{A}}(x)\rangle, \tag{11}\]

can then act as a surrogate for the target function \(f\).

For a supervised learning (SVL) loss contribution we can define

\[\mathcal{L}_{SVL}=\frac{1}{M}\sum_{i}^{M}L(f(x_{i},\vec{\theta}_{F},\vec{ \theta}_{A}),y_{i}), \tag{12}\]

where \(L\) is a suitable distance function. In a DQC setting, with each (partial, differential) equation embedded in a functional \(F[\partial_{X}f(x),f(x),x]\) to be estimated on a set of \(M\) collocation points \(\{x_{i}\}\), one can define a physics-informed loss function as

\[\mathcal{L}_{DQC}=\frac{1}{M}\sum_{i}^{M}L(F[\partial_{X}f(x_{i}),f(x_{i}),x_ {i}],0). \tag{13}\]

When optimising the loss against a certain variational parameter \(\theta\), if \(\theta\in\vec{\theta}_{A}\) is an ansatz parameter then \(\frac{\partial\mathcal{L}}{\partial\theta}\) can be computed as standard with the PSR and generalised parameter-shift rules (GPSR) [17; 18]. If instead \(\theta\in\vec{\theta}_{F}\), we can account for the inclusion of the feature \(x\) using the linearity of differentiation

\[\frac{\partial\mathcal{L}_{SVL}}{\partial\theta} =\frac{1}{M}\sum_{i}^{M}\frac{dL}{df}\frac{\partial f(x_{i})}{ \partial\theta}, \tag{14}\] \[\frac{\partial\mathcal{L}_{DQC}}{\partial\theta} =\frac{1}{M}\sum_{i}^{M}\frac{\partial L}{\partial\theta}\left(F \left[\partial_{X}f(x_{i}),f(x_{i}),x_{i}\right],0\right). \tag{15}\]

Note that in Eq. 15 we leave the right-hand side (RHS) as its implicit form, as it depends not only upon the actual choice of the distance \(L\), as in Eq. 14, but also upon the terms involved in the functional \(F\). In order to give further guidance on the explicit treatment of this latter case, we can split the discussion according to the various terms involved in the functional \(F\), under the likely assumption that the problem variable(s) \(X\) are independent from the variational parameter \(\theta\):

* Terms that depend solely on \(x_{i}\) have null \(\frac{\partial\cdot}{\partial\theta}\) and can be neglected.
* Terms containing the function \(f\) itself can be addressed via the chain rule already elicited in Eq. 14.
* Finally, terms depending on \(\partial_{X}f(x_{i})\) can be similarly decomposed as \[\frac{d^{2}L}{dfdX}\frac{\partial^{2}f(x_{i})}{\partial\theta\partial X}= \frac{dL}{d(\partial_{X}f)}\frac{\partial}{\partial X}\frac{\partial f(x_{i} )}{\partial\theta}\] (16) where the latter descends from the independence highlighted above, and the first term on the RHS can be simply attained from the (known) analytical form of \(L\) and \(F\).

Thus, following the chain rule, in all cases we obtain a dependency upon the term \(\partial f(x_{i})/\partial\theta\).

In terms of computing \(\partial f(x_{i})/\partial\theta\), we again omit the case where \(\theta\in\vec{\theta}_{A}\) as it is known from the literature [17; 6]. For the specific case of \(\theta\in\vec{\theta}_{F}\) instead, let us first combine the unitary ansatz and the cost operator as \(\hat{U}_{A}^{\dagger}(\vec{\theta}_{A})\hat{C}\hat{U}_{A}(\vec{\theta}_{A}) \equiv\hat{C}_{A}(\vec{\theta}_{A})\) for brevity. Rewriting Eq. 11, using the generic FM provided in Eq. 1 with a trainable generator \(\hat{G}_{m}(\vec{\gamma},\vec{\theta}_{F})\) and isolating the only term dependent on the \(\theta_{\hat{m}}\) of interest, we get

\[\hat{U}_{F}(\vec{x},\vec{\gamma},\vec{\theta}_{F})=e^{-i\hat{C}_{ 1}(\vec{\gamma},\theta_{1})\phi_{1}(\vec{x})}\otimes...\] \[\otimes e^{-i\hat{G}_{m}(\vec{\gamma},\theta_{m})\phi_{m}(\vec{x} )}\otimes...\otimes e^{-i\hat{G}_{M}(\vec{\gamma},\theta_{M})\phi_{M}(\vec{x})} \tag{17}\] \[\equiv\hat{U}_{FLR}\otimes e^{-i\hat{G}_{m}(\vec{\gamma},\theta_{ m})\phi_{m}(\vec{x})}\otimes\hat{U}_{FR}. \tag{18}\]
Further simplifying the notation using \(\hat{U}_{FR}|0\rangle\equiv|f_{FR}\rangle\) and \(\hat{U}_{FL}^{\dagger}\hat{C}_{A}\hat{U}_{FL}\equiv\hat{C}_{AF}\) produces

\[f(x,\theta_{F},\theta_{A})=\] \[\langle f_{FR}|e^{i\hat{G}_{\hat{m}}(\tilde{\gamma},\theta_{\hat{m} })\phi_{\hat{m}}(\tilde{x})}\hat{C}_{AF}e^{-i\hat{G}_{\hat{m}}(\tilde{\gamma}, \theta_{\hat{m}})\phi_{\hat{m}}(\tilde{x})}|f_{FR}\rangle. \tag{10}\]

With the model expressed in terms of the dependency on the single FM parameter \(\theta_{\hat{m}}\), we can now address computing \(\partial f/\partial\theta_{\hat{m}}\):

\[\frac{\partial f}{\partial\theta_{\hat{m}}}=\langle f_{FR}|e^{i \hat{G}_{\hat{m}}\phi_{\hat{m}}}\bigg{[}\phi_{\hat{m}}\frac{\partial\hat{G}_{ \hat{m}}}{\partial\theta_{\hat{m}}},\hat{C}_{AF}\bigg{]}e^{-i\hat{G}_{\hat{m} }\phi_{\hat{m}}}|f_{FR}\rangle, \tag{11}\]

where for simplicity we have omitted the parameter dependencies of \(\phi_{\hat{m}}(\tilde{x})\) and the \(\hat{G}_{\hat{m}}(\tilde{\gamma},\theta_{\hat{m}})\) generator, and we have introduced the commutator notation \([\cdot,\cdot]\).

Observing Eq. 11, we are thus left with obtaining the partial derivative \(\partial\hat{G}_{\hat{m}}/\partial\theta_{\hat{m}}\), and to this extent we distinguish three cases. (i) If \(\hat{G}_{\hat{m}}(\tilde{\gamma},\theta_{\hat{m}})=\gamma\theta_{\hat{m}} \hat{\sigma}^{\alpha}\), i.e. a single Pauli operator for a chosen \(\alpha\) axis, then we can obtain the target derivative using the standard PSR. (ii) When a similar dependency on the (non) trainable parameters holds, but we generalise beyond involutory and idempotent primitives, i.e. \(\hat{G}_{\hat{m}}(\tilde{\gamma},\theta_{\hat{m}})=\gamma\theta_{\hat{m}}\hat {G}_{\hat{m}}\), we can instead rely on a single application of the GPSR to obtain \(\partial\hat{G}_{\hat{m}}/\partial\theta_{\hat{m}}\). (iii) Finally, in the most generic case considered in this work, the spectral gaps of \(\hat{G}_{\hat{m}}\) might depend non-trivially upon \(\theta_{\hat{m}}\). In this last case, one should recompute such gaps for each new trained \(\theta_{\hat{m}}\), in order to apply GPSR. Note, however, that one could always decompose \(\hat{G}_{\hat{m}}(\tilde{\gamma},\theta_{\hat{m}})=\sum_{i}^{N}\hat{P}_{i}( \tilde{\gamma},\theta_{\hat{m}})\), i.e. a sum of Pauli strings \(\hat{P}\). With this decomposition approach, ignoring any structure in \(\hat{G}_{\hat{m}}\), at most \(2I\) circuit evaluations would suffice to retrieve \(\partial\hat{G}_{\hat{m}}/\partial\theta_{\hat{m}}\)[47].

## Appendix B Quantum models and training hyperparameters

For all quantum models used in this work, the variational ansatz is a variant of the hardware-efficient ansatz (HEA) [48], with entangling unitaries connecting the qubits in a ring topology, where we study both digital and sDAQC [27] versions of the HEA. Furthermore, after all FMs and ansatz layers are applied, a final state \(\ket{\psi}\) is produced. The output (e.g., the predicted value of \(y(x)\) or \(\psi(x,y,t)\) or \(p(x,y,t)\)) of all models is obtained via the expectation value \(\bra{\psi}\hat{C}\ket{\psi}\), where the cost operator \(\hat{C}=\sum_{m=1}^{N}\hat{Z}^{m}\) is an equally-weighted total magnetization across the \(N\) qubits. This combination of constant depth ansatz and 1-local observables is known to avoid cost function induced barren plateaus [49].

All models in this work were trained using the Adam optimizer.

In Figure 2a the model was trained with hyperparameters: qubits \(N=4\), ansatz layers \(L=4\), CX entangling gates, training iterations \(N_{i}=2\),000, batch size \(b_{s}=1\), learning rate \(\text{lr}=10^{-3}\).

In Figure 2b, both models were trained with: \(N=4\), \(L=4\), CX entangling unitaries, \(N_{i}=6\),000, \(b_{s}=2\), \(\text{lr}=10^{-3}\).

In Figure 3 all models were trained with: \(N=4\), \(L=8\), CX entangling unitaries, \(N_{i}=4\),000, \(b_{s}=2\), \(\text{lr}=10^{-3}\).

In Figure 5 and Table 1, all models were trained per QNN with: \(N=6\), \(L=10\) (divided as shown in Figure 4), sDAQC version of the HEA where entangling operations are fixed-duration Hamiltonian evolution of the form \(\exp(i\hat{n}_{k}\hat{n}_{l}\pi)\) between neighbouring pairs of qubits \((k,l)\), \(N_{i}=5\),000, \(b_{s}=600\), \(\text{lr}=10^{-2}\).

In Appendix C, Figure 6 and Table 2, all models were trained per QNN with: \(N=4\), \(L=64\), CX entangling unitaries, \(N_{i}=5\),000, \(b_{s}=600\), \(\text{lr}=10^{-2}\).

## Appendix C Navier-Stokes results in the over-parameterized regime

In this section we repeat the experiments in section V using an over-parameterized model, such that the number of trainable parameters is larger than the dimension of the Hilbert space [50]. Furthermore, here we use a serial TFFM in which each dimension \((x,y,t)\) is encoded serially in separate blocks, separated by an ansatz layer which acts to change the encoding basis to avoid loss of information. This is theoretically preferential to the parallel encoding strategy since it produces a quantum model with more unique frequencies. The TFFM uses the simple parameterization \(\hat{G}_{\theta}=\sum_{m=1}^{N}\theta_{m}\hat{Y}^{m}/2\) for each dimension, whilst the FF model uses the same generator without trainable parameters \(\hat{G}=\sum_{m=1}^{N}\hat{Y}^{m}/2\). After the FM, the model has \(L=64\) ansatz layers bisected by a data-reuploading FM. In total, each QNN has 804 trainable ansatz parameters.

Figure 6 presents a visualization of the experiment's results, evaluating the pressure field at a specific time. In this deeper regime, the TF QNN achieves excellent agreement with the reference solution, successfully capturing more features such as the presence of two interconnected negative-pressure bubbles on the left. In contrast, despite its increased depth, the FF QNN solution is only approximately accurate and fails to correctly identify the separation between the pressure bubbles in the middle and right. The numerical performance of the models is given in Table 2.