On the explainability of quantum neural networks based on variational
  quantum circuits
Ridge functions are used to describe and study the lower bound of the
approximation done by the neural networks which can be written as a linear
combination of activation functions. If the activation functions are also ridge
functions, these networks are called explainable neural networks.
  In this paper, we first show that quantum neural networks which are based on
variational quantum circuits can be written as a linear combination of ridge
functions. Consequently, we show that the interpretability and explainability
of such quantum neural networks can be directly considered and studied as an
approximation with the linear combination of ridge functions.
Ammar Daskin
# On the explainability of quantum neural networks based on variational quantum circuits

###### Abstract

Ridge functions are used to describe and study the lower bound of the approximation done by the neural networks which can be written as a linear combination of activation functions. If the activation functions are also ridge functions, these networks are called explainable neural networks.

In this paper, we first show that quantum neural networks which are based on variational quantum circuits can be written as a linear combination of ridge functions. Consequently, we show that the interpretability and explainability of such quantum neural networks can be directly considered and studied as an approximation with the linear combination of ridge functions.

 Quantum neural networks, explainability, interpretability, ridge functions

## I Introduction

Neural networks have applications in almost every field of science ranging from health to banking. The ability to interpret the result of a model and explain the learning behavior may be deemed important especially in critical industries such as medicine and health care[1, 2, 3]. Limitations of the approximation rates of the classical neural networks can be understood better by using linear combination of ridge functions as an approximation to neural networks.

The power and the limitations of quantum neural networks are yet to be fully understood. In this paper, we show that quantum neural networks can be written as a sum of ridge functions. Therefore, the math and methodologies that are used to understand classical neural networks can be used to study quantum ones.

### _Approximation with ridge functions_

For a random variable y, if we have the observations \(y_{1},\ldots,y_{n}\) at points \(x_{1},\ldots,x_{n}\), a standard regression model can be described by \(y_{i}=\hat{y}_{i}+r_{i}\), where \(\hat{y}_{i}\) defines the dependence of \(y_{i}\) on \(x_{i}\) When \(x_{i}\) are univariate real values, the assumption is that the dependence is smooth. This leads the following estimation for the regression model[4]:

\[E(y\mid x)=f(x), \tag{1}\]

where \(f\) is a smoothing function. In linear smoothing, \(\mathbf{\hat{y}}=(\hat{y}_{1},\ldots,\hat{y}_{n})^{T}\) can be written in the form of matrix vector transformation: \(\mathbf{\hat{y}}=S\mathbf{y}\), where \(S\) is the smoother matrix that does not depend on \(\mathbf{y}\). When there are more than one predictors, estimating the regression surface is hard because of the curse of dimensionality (the data sparseness in high dimensions)[5]. The general approach is to use the one-dimensional smoother as the building block in an additive model [4]. Given predictors \(x_{ij}\)s for each \(y_{i}\) outcome, i.e. \(\{y_{i},x_{i1},\ldots,x_{ip}\}\), the additive model can be described as:

\[E(y_{i}|x_{i1},\ldots,x_{ip})=\alpha+\sum_{j=1}^{p}f_{j}(x_{ij})+\epsilon. \tag{2}\]

where \(\epsilon\) is the inherent error, \(\alpha\) is a constant parameter, and \(fj\)s represent unspecified smooth functions. Fitting can be done by using the backfitting algorithm [5, 6] which is in matrix form equivalent to the Gauss-Seidel method in numerical linear algebra[7].

Generalizing this model leads to the projection pursuit model proposed in [5] where the regression surface is predicted by a linear combination of ridge functions as in the following form:

\[f(\mathbf{x})=\sum_{k=1}^{K}f_{k}(\mathbf{w_{k}}\cdot\mathbf{x}). \tag{3}\]

Here, \(\mathbf{w_{k}}\)s represent weight vectors (projection indices) and \(f_{k}\)s are ridge functions [8, 9, 10, 11]: Any multivariate function \(f_{k}:\mathcal{R}^{d}\rightarrow\mathcal{R}\). The vector \(w_{k}\) is called the direction and \(f_{k}\) gives a constant on certain hyper-planes whose normal vectors are parallel to this direction. Ridge functions are used in approximation theory, partial differential equations, and neural networks. For instance, a feed forward neural network can be defined as [8]:

\[\sum_{k}\gamma_{k}\sigma\left(\mathbf{w_{k}}\cdot\mathbf{x}+b_{k}\right), \tag{4}\]

where \(b_{k}\), \(\alpha_{k}\), and \(\mathbf{w_{k}}\) represent parameters that describe the neural network. \(\sigma\) is a univariate function (activation function). The degree of approximation by \(\sigma\) functions can be bounded by the degree of approximation by ridge functions (we refer the reader to Ref.[8] for the properties and other uses of the ridge functions). The lower bound of the approximation of the neural networks can be also studied through the relations of the activation functions with ridge functions (e.g., [12, 13, 14]).

If \(\sigma\) is chosen as a ridge function these networks are recently called explainable neural networks [15]: e.g. an example architecture which has three important structures, a projection layer, sub-network, and a combination layer is described to learn the following:

\[f(\mathbf{x})=\mu+\sum_{k=1}^{K}\gamma_{k}f_{k}(\mathbf{w_{k}}\cdot\mathbf{x}). \tag{5}\]

Here, \(\mu\) and \(\gamma_{k}\)s are shift and scaling parameters, respectively. In comparison to standard neural networks, the learning in
this model can be understood by the "explainable" features: linear projections and uni-variate functions (in other words, the mechanisms used to learn the model can be clearly explained by studying the constitutions that are ridge functions.).

## II Explainability of quantum neural networks

Quantum neural networks[16, 17, 18, 19] are generally based on variational quantum circuits[20] and can be described by

\[\left\langle\mathbf{x}\right|W(\theta)\hat{O}W(\theta)\left|\mathbf{x}\right\rangle, \tag{6}\]

where \(\hat{O}\) represents the measurement operator, \(\left|\mathbf{x}\right\rangle\) is the input vector formatted as a quantum state and \(W(\theta)\) is a unitary matrix generated by the quantum gates with the angle values defined by \(\theta\). Here, by abuse of the notation, we can consider \(\hat{O}\) as a selector set on the parts of \(W(\theta)\left|\mathbf{x}\right\rangle\): e.g., to obtain the measurement output of the first qubit in \(\left|0\right\rangle\) state, in vector forms, we select the first half of the output and combine their squared absolute values. Then, the output quantum state of the quantum circuit applied to \(\left|x\right\rangle\) can be rewritten as:

\[\sum_{i\in\hat{O}}|\left\langle\mathbf{w_{i}}\right|\mathbf{x}\right\rangle|^ {2}=\sum_{i\in\hat{O}}f_{i}(\left\langle\mathbf{w_{i}}\right|\mathbf{x}), \tag{7}\]

where \(\left\langle\mathbf{w_{i}}\right|\) represents a row of the unitary matrix \(W(\theta)\).

In variational quantum circuits, generally any change of the vector element of \(\theta\) may affect multiple rows of \(W(\theta)\). This can affect the studies that try to understand the quantum neural network model. Therefore, to make any \(f_{i}\) independent from each other, we can use the linear combination of unitary matrices[21, 22]. By following Ref.[22], we can write the rows of any matrix \(W(\theta)\) as the first rows of matrices and combine them on a block diagonal matrix:

\[\mathcal{V}=\left(\begin{array}{ccccc}\left(\begin{array}{ccccc}\left\langle \mathbf{w_{1}}\right|\\ \bullet\\ \vdots\\ \bullet\end{array}\right\rangle_{N\times N}&&&\\ &\ddots&&\\ &&&\left(\begin{array}{ccccc}\left\langle\mathbf{w_{N}}\right|\\ \bullet\\ \vdots\\ \bullet\end{array}\right\rangle_{N\times N}&\end{array}\right)_{N^{2}\times N^ {2}} \tag{8}\]

where \(N\) is the dimension of \(W(\theta)\). Using the direct sum, we can write \(\mathcal{V}=\bigoplus_{i}^{N}V_{i}\) with \(V_{i}\) representing the unitary matrix for \(\mathbf{w_{i}}\). Note that any \(N\)-dimensional vector can be formed with \(O(N)\) quantum gates as the leading row of a unitary matrix by using its Schmidt decomposition. Therefore, the construction \(\mathcal{V}\) for a generic \(W(\theta)\) requires at most \(O(N^{2})\) gates (See Ref.[22] for complexity analysis of the circuit.).

The equivalent quantum state to the output of \(W(\theta)\left|\mathbf{x}\right\rangle\) can be generated as a part of the outcome of the following transformation:

\[\left|\psi\right\rangle=\mathcal{V}\begin{pmatrix}\left|\mathbf{x}\right\rangle \\ \vdots\\ \left|\mathbf{x}\right\rangle\end{pmatrix}_{N^{2}\times 1}. \tag{9}\]

In a simplified form let \(\left|\psi_{i}\right\rangle\) represents the \(i\)th element of \(\left|\psi\right\rangle\) with \(0\geq i<N^{2}\), we can define a new selector operator that selects every \(\left|\psi_{i}\right\rangle\), where \(i\mod N=0\). That means we can still use the definition similar to Eq.(7):

\[\sum_{i,i\text{ mod }N=0}^{N^{2}-1}|\left\langle\mathbf{w_{i}}\right|\mathbf{x} \right\rangle|^{2} \tag{10}\]

Note that by writing a quantum operator in this way, we simply make the weight vectors independent from each other. That means the impact of an angle-change in one quantum gate can be limited to affect only one vector. Therefore, this model is at least as powerful as using a single unitary matrix where a change may affect multiple rows. In addition, studying the approximations in this model may be easier since we can easily see how many independent weight vectors are needed and how each weight vector affects the result and training.

### _Explainability of networks that are represented by exponentials_

Ridge functions are also used to approximate the integral forms of functions[23]: One of the most commonly used one is given by the following Fourier form:

\[\Psi_{\mathbf{w_{k}}}:=e^{\mathrm{i}\mathbf{x}\cdot\mathbf{w_{k}}}, \tag{11}\]

Here, the complex plane can be rewritten using the only real valued functions, therefore \(\Psi_{\mathbf{w_{k}}}\) can be considered as a ridge function for each \(\mathbf{w_{k}}\). Therefore, quantum neural networks such as [24] can be also explained as an approximation through the linear combination of ridge functions.

This can be also used to understand quantum circuits that are defined through the Ising type Hamiltonian[25] or machine learning tasks that are solved through the adiabatic quantum computation [26, 27]

## III Discussion and Conclusion

For a given set of weight vectors, in literature there are many works on the conditions to approximate a given function with unknown ridge functions. For instance[28], consider \(C(X)\) is the space of continuous functions on X, then for a given \(\{\mathbf{w_{1}},\mathbf{w_{2}}\}\), for an appropriate choice of some continuous functions \(h_{1}\) and \(h_{2}\), one can write \(g_{1}(h_{1}(x))+g_{2}(h_{2}(x))=C(X)\) if and only if the lengths of \(h_{1}-h_{2}\) paths in \(X\) are bounded by some positive integer. From the Kolmogorov-Arnold representation theorem [29], we know that any multivariate continuous function can be approximated as a sum of univariate functions. By this theorem, it can be also explained how the hidden layers in the classical neural networks help in approximations[29, 30, 31]. However, a continuous function may not be represented exactly by an approximation with ridge functions [10, 29]. Therefore, the approximation rates in quantum neural networks that reduce to Eq.(7) and (10) can be well understood. On the other hand, this indicates that the limitations of the approximations with the ridge functions may also be limitations for these types of quantum neural networks.
In this brief paper, we show that quantum neural networks can be understood as a linear combination of ridge functions, which is used to understand the interpretability and explainability of the classical neural networks. In particular, Eq.(7) and Eq.(10) can be used to describe quantum neural network models. In addition, since it can be written in the form of a linear combination of ridge functions, the approximation errors and upper and lower bounds on the errors of quantum neural networks can be studied through this formulation.

In quantum neural networks which can be reduced to Eq.(7) and (10), the approximation is done by using \(N\) ridge functions. Here, \(N\) is in general exponential in the number of qubits and can be considered a very large number. For general function approximations, using these equations may be helpful to make a decision on the size of \(N\) and the required number of operations and qubits before any application. However, the problems solved by the neural networks are in general not easy to define by functions, therefore it is not easy to decide how many functions (and quantum operations and qubits) are required to make the model more trainable.
