This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Quantum Sparse Coding and Decoding Based on Quantum Network

Xun Ji National Laboratory of Solid State Microstructure, School of Physics, and Collaborative Innovation Center of Advanced Microstructures, Nanjing University, Nanjing 210093, China Institute for Brain Sciences and Kuang Yaming Honors School, Nanjing University, Nanjing 210023, China Hefei National Laboratory, Hefei 230088, China    Qin Liu National Laboratory of Solid State Microstructure, School of Physics, and Collaborative Innovation Center of Advanced Microstructures, Nanjing University, Nanjing 210093, China Institute for Brain Sciences and Kuang Yaming Honors School, Nanjing University, Nanjing 210023, China Hefei National Laboratory, Hefei 230088, China    Shan Huang National Laboratory of Solid State Microstructure, School of Physics, and Collaborative Innovation Center of Advanced Microstructures, Nanjing University, Nanjing 210093, China Institute for Brain Sciences and Kuang Yaming Honors School, Nanjing University, Nanjing 210023, China Hefei National Laboratory, Hefei 230088, China    Andi Chen National Laboratory of Solid State Microstructure, School of Physics, and Collaborative Innovation Center of Advanced Microstructures, Nanjing University, Nanjing 210093, China Institute for Brain Sciences and Kuang Yaming Honors School, Nanjing University, Nanjing 210023, China Hefei National Laboratory, Hefei 230088, China    Shengjun Wu [email protected] National Laboratory of Solid State Microstructure, School of Physics, and Collaborative Innovation Center of Advanced Microstructures, Nanjing University, Nanjing 210093, China Institute for Brain Sciences and Kuang Yaming Honors School, Nanjing University, Nanjing 210023, China Hefei National Laboratory, Hefei 230088, China
Abstract

Sparse coding provides a versatile framework for efficiently capturing and representing crucial data (information) concisely, which plays an essential role in various computer science fields, including data compression, feature extraction, and general signal processing. In this study, we propose a symmetric quantum neural network for realizing sparse coding and decoding algorithms. Our networks consist of multi-layer, two-level unitary transformations that are naturally suited for optical circuits. Each gate is described by two real parameters, corresponding to reflectivity and phase shift. Specifically, the two networks can be efficiently trained together or separately using a quantum natural gradient descent algorithm, either simultaneously or independently. Utilizing the trained model, we achieve sparse coding and decoding of binary and grayscale images in classical problems, as well as that of complex quantum states in quantum problems separately. The results demonstrate an accuracy of 98.77% for image reconstruction and a fidelity of 97.68% for quantum state revivification. Our quantum sparse coding and decoding model offers improved generalization and robustness compared to the classical model, laying the groundwork for widespread practical applications in the emerging quantum era.

Introduction
In the classical field of machine learning and data analysis algorithms, the corresponding machine learning task is accomplished by combining supervised or unsupervised training on data WOS:000355286600030 . In quantum machine learning, various quantum versions of machine learning algorithms have also been proposed and developed immediately, including quantum support vector machines, quantum principal component analysis, quantum neural networks (QNN), and other quantum machine learning algorithms WOS:000410555900032 ; WOS:000341820700013 ; WOS:000500574300022 . Additionally, for rapidly evolving quantum neural network algorithms, classical optimizers are utilized to train multi-layer parameterized quantum gates in order to achieve desired learning tasks WOS:000993620700002 . Therefore, combined with Classical Sparse Coding (CSC) and quantum computation theory, an efficient quantum algorithm based on QNN can be designed to realize quantum sparse coding and decoding WOS:000493128300001 ; WOS:A1995QT40100017 ; WOS:000261782000008 ; bellante2022quantum .

Sparse coding and decoding refers to compressing high-dimensional data sets into their lower-dimensional representations sparsely and reconstructing higher-dimensional data sets from low-dimensional ones WOS:000961147200001 ; WOS:000406868800017 ; WOS:000258641500006 , which plays a crucial role in the fields of image compression, storage and processing WOS:000085444700052 ; WOS:000486237600006 ; WOS:000277884900014 . Sparse coding originates from the fact that the receptive field of the visual stripe cortex produces a sparse response to visual information. To be specific, most neurons of the visual stripe cortex are in a static resting state, while a small number of neurons are in the stimulated state WOS:A1996UQ65700051 . Mathematically, based on data structure analysis, digital image processing, and advanced algebra, CSC algorithms are developed gradually, where an overcomplete dictionary set is trained by various training algorithms, and sparse representation is a linear combination of the overcomplete dictionary set and active neurons in a high-dimensional space originally with redundant information WOS:000277884900014 . More explicitly, the sparse solutions of underdetermined equations are able to compress the data to a certain extent allowing little information loss of restoration. Currently, CSC algorithms have been implemented by hardware friendly, owing to their simple linear matrix operation in classical computer.

In contrast, quantum computing is an emerging frontier with higher information security and faster parallel acceleration. Specifically, quantum algorithms are expected for its potential advantages in quantum transmission, storage and encryption WOS:000343620500001 ; WOS:000431301800015 ; WOS:000454369600010 ; WOS:000514356400004 ; WOS:000209372300002 ; WOS:000340140200011 ; WOS:000646064000002 ; WOS:000888558600009 ; WOS:000685625800001 ; WOS:000935994100004 . Therefore, with the breakthrough of quantum machine learning algorithms and quantum circuits WOS:000410555900033 ; WOS:000390793900027 ; WOS:000476555600001 , more cutting-edge quantum algorithms are gradually moving toward hardware WOS:000940796200001 ; WOS:000711864600001 ; WOS:000367200400001 ; WOS:000340611600001 ; WOS:A1994NV63100015 ; WOS:000830702800001 ; WOS:000604141000011 ; WOS:000471037100002 ; WOS:000491132700075 ; WOS:000467374300005 ; WOS:000466034400001 ; WOS:000457547900068 , which is currently a possible development that challenges Moore’s Law WOS:000888210300020 . Meanwhile, there is no efficient CSC algorithm to handle quantum states. Inspired by CSC algorithms WOS:000486237600006 and quantum circuit models WOS:000390793900027 ; WOS:A1995QT40100017 , we propose a quantum algorithm named Quantum Sparse Coding and Decoding (QSCD), which can sparsely code quantum states from high to low dimensional Hilbert space and then decode them inversely. Specifically, the quantum networks are trained by gradient-based descent method WOS:000444202100003 ; WOS:000246314600001 ; WOS:001001538500030 , and can be realized by universal multi-port design interferometers in optical quantum circuits WOS:000390793900027 ; WOS:000316614600026 ; WOS:000289982600014 . The simulations fully demonstrate that our QSCD algorithm is able to deal with the real and complex quantum states efficiently, which can be applied to further industrial problems as a cutting-edge technology.

Refer to caption
Figure 1: The QSCD algorithm for grayscale image reconstruction. In the one iteration, for image data, \scriptsize{1}⃝ the classical information in a binary or grayscale image is converted into a column vector XmX_{m} with Xm[0,1]X_{m}\in[0,1], encoded into amplitude rmn[0,1]r_{mn}\in[0,1] and phase ϕmn[0,2π]\phi_{mn}\in[0,2\pi] of the real quantum state with ϕmn=0\phi_{mn}=0. \scriptsize{2}⃝ The coded quantum state |ψm\left|\psi_{m}\right\rangle is input into the coding and decoding network. \scriptsize{3}⃝ Then according to the measurement of the output real state, the amplitude is inversely decoded into the classical information X^m\hat{X}_{m} with reconstruction image pixel x^mn\hat{x}_{mn}. Similarly, for complex quantum states n=0N1rmneiϕmn|n\sum_{n=0}^{N-1}r_{mn}e^{i\phi_{mn}}|n\rangle in polar coordinates, corresponding to amplitude rmnr_{mn} and phase ϕmn\phi_{mn} in (a), it also can be directly input into the network. During the training process, (b) the probability amplitude |Rmn|2\left|R_{mn}\right|^{2} can be measured, which is shown in the polar coordinate form in the framework. Surely, for the trained quantum network, the sparse coding and decoding of the quantum states can be achieved without immediate measurement.

Results
Preliminary.
In classical information processing, data bits are encoded into binary electrical signals such as the “high” and “low” values of electric potential, facilitating convenient sparse representation and retrieval based on electrical circuits. As for the quantum information processing, the quantum counterpart of bits are two-dimensional quantum states, that is, quantum bits (qubits). Physical realizations of qubits include two-level atoms, two distinct optical modes, etc. Taking the grayscale image reconstruction as an example, our proposal of QSCD is illustrated in Fig. 1. Consider MM grayscale images consisting of NN pixels, and let xmn[0,1]x_{mn}\in[0,1] denote the nnth pixel of the mmth grayscale image. From each grayscale image one then obtains a normalized NN-dimensional row vector {rmn}\left\{r_{mn}\right\}, where, with σm=n(xmn)2\sigma_{m}=\sqrt{\sum_{n}(x_{mn})^{2}},

rmn=xmnσmr_{mn}=\frac{x_{mn}}{\sigma_{m}} (1)

are the normalized pixels which satisfy n=0N1rmn2=1\sum_{n=0}^{N-1}r_{mn}^{2}=1 for all m=1,,Mm=1,\cdots,M. It is worth noting that {rmn}\left\{r_{mn}\right\} alone does not contain the complete information of the original pixels, but when combined with the normalization factor σm\sigma_{m}, all the pixels of the mmth grayscale image can be fully reconstructed.

In quantum sparse coding of grayscale images, we only need to focus on the normalized pixel vector {rmn}\left\{r_{mn}\right\} as it contributes to almost all the cost associated with image transmission and storage. It is convenient to write a general NN-dimensional quantum state in the computational basis as follows

|ψ=n=0N1rneiϕn|n.\displaystyle\left|\psi\right\rangle=\sum_{n=0}^{N-1}r_{n}e^{i\phi_{n}}|n\rangle. (2)

Here, each basis state |n{|0000,|0001,,|1111}|n\rangle\in\{|00\cdots 00\rangle,\ |00\cdots 01\rangle,\ \ldots,\\ \ |11\cdots 11\rangle\} corresponds to the binary representation of an integer n[0,N1]n\in[0,N-1], and the expansion coefficients are normalized, nrn2=1\sum_{n}r_{n}^{2}=1. In this way, classical information can be properly encoded into the expansion coefficients {rneiϕn}\{r_{n}e^{i\phi_{n}}\} of |ψ\ket{\psi} which, further serves as an input of our quantum sparse coding network. In particular, the quantum representation of normalized pixel vectors {ψm}\{\psi_{m}\} now become |ψm=nrmneiϕmn|n\ket{\psi_{m}}=\sum_{n}r_{mn}e^{i\phi_{mn}}|n\rangle, with phase parameters being 0, ϕmn=0\phi_{mn}=0.

We proceed to detail our network architecture. Our sparse coding network aims to transform a collection of NN-dimensional quantum states into lower dimensional ones while preserving, as much as possible, the information encoded in the input states. Considering that distinct classical information must be encoded in orthogonal states to be perfectly distinguishable under quantum measurements, our basic assumption in this work is that a coding network preserves orthogonality. In other words, we focus on quantum networks that implement unitary transformations. Furthermore, our main interest is in two particular types of quantum network structures, called Order type and Cross type. Order type links quantum gates sequentially, while Cross type interconnects them in a cross-pattern. Numerical analyses show Order type excels at lower layers, whereas Cross type is better for deeper networks (see supplementary information I).

General unitary transformations on an NN-dimensional Hilbert space N\mathcal{H}_{N} can be factored into a series of unitaries on 2-dimensional subspaces of N\mathcal{H}_{N} (single-qubit gates), which leave quantum states in the respective (N2)(N-2)-dimensional complementary subspaces invariant. Each specific factoring then determines a specific network structure, and the network parameters are exactly the variables describing individual single-qubit unitary gates. Notably, the network structures based on different ways of factoring unitary transformations may have different advantages and limitations. In the following, our discussions will revolve around the optimal factoring proposed in Cross-type network (see supplementary information I), which is comparatively more efficient for deep networks. Its physical realization based on optical circuits consists of lEl_{E} layers of unitary gates on two neighboring optical modes, involving approximately (N1)lE(N-1)l_{E} unitary gates in total WOS:000390793900027 . More specifically, a unitary gate UnU_{n} on two optical modes {|n,|n+1}\{\ket{n},\ \ket{n+1}\} can be implemented by a phase shifter at one mode (with phase parameter αn[0,2π]\alpha_{n}\in[0,2\pi]) followed by a two-mode Mach-Zehnder interferometer (with parameter θn[0,π/2]\theta_{n}\in[0,\pi/2])

Un|n=eiαn(cosθn|n+sinθn|n+1),\displaystyle U_{n}\ket{n}=e^{i\alpha_{n}}(\cos\theta_{n}|n\rangle+\sin\theta_{n}|n+1\rangle),
Un|n+1=sinθn|n+cosθn|n+1.\displaystyle U_{n}\ket{n+1}=-\sin\theta_{n}|n\rangle+\cos\theta_{n}|n+1\rangle. (3)

Each layer of our coding network consists of N/2N/2 parallel single-qubit unitary gates on the optical modes {|2(k1),|2k1}(k=1,2,,N/2)\{\ket{2(k-1)},\ket{2k-1}\}\ (k=1,2,\cdots,N/2), followed by another N/21N/2-1 parallel single-qubit unitary gates on the modes {|2k1),|2k}(k=1,2,,N/21)\{\ket{2k-1)},\ket{2k}\}\ (k=1,2,\cdots,N/2-1) (see Fig. 1 for an example and supplementary information I for more details). Then, the ll-th layer of our coding network implements the transformation

UE(l)=\displaystyle U_{E}^{(l)}= U0U2UN2U1U3UN3\displaystyle U_{0}U_{2}\cdots U_{N-2}U_{1}U_{3}\cdots U_{N-3}
=\displaystyle= k=1N1Uk(θkl,αkl),\displaystyle\prod_{k=1}^{N-1}U_{k}\left(\theta_{k}^{l},\alpha_{k}^{l}\right), (4)

The overall coding network then essentially implements lEl_{E} unitary transformations consecutively

TE=UE(lE)UE(lE1)UE(1):=l=1lEUE(l),\displaystyle T_{E}=U_{E}^{(l_{E})}U_{E}^{(l_{E}-1)}\cdots U_{E}^{(1)}:=\prod_{l=1}^{l_{E}}U_{E}^{(l)}, (5)

which is described by 2lE×(N1)2l_{E}\times(N-1) real parameters WOS:000390793900027 . In supplementary I, we also discuss another network structure and compare it with the above one numerically.

As for the decoding network, a direct choice is simply the mirror inversion of the coding network, which performs the inverse transformation to recover the initial states from the output of the coding network. However, if some input state (2) is not transformed into the output space completely, say a dd-dimensional Hilbert space d\mathcal{H}_{d} spanned by the last dd optical modes, then the actual outputs are described by the (unnormalized) states

|χm=P0TE|ψm=P0TEn=0N1rmneiϕmn|n,\displaystyle\ket{\chi_{m}}=P_{0}T_{E}|\psi_{m}\rangle=P_{0}T_{E}\sum_{n=0}^{N-1}r_{mn}e^{i\phi_{mn}}|n\rangle, (6)

with P0=n=0d1|nn|P_{0}=\sum_{n=0}^{d-1}|n\rangle\langle n| the projector onto d\mathcal{H}_{d}. This projector is critical for realizing sparse coding. It retains prominent features of the initial set of states while discarding unimportant information. In accordance, input photons of the decoding network are prepared into the normalized states {χm|χm12|χm}\{\braket{\chi_{m}}{\chi_{m}}^{-\frac{1}{2}}\ket{\chi_{m}}\} which, after some decoding transformation TDT_{D}, become

|Ψm=1χm|χmTD|χm=n=0N1Rmneiφmn|n.\begin{split}\left|\Psi_{m}\right\rangle=&\frac{1}{\sqrt{\braket{\chi_{m}}{\chi_{m}}}}T_{D}\ket{\chi_{m}}=\sum_{n=0}^{N-1}R_{mn}e^{i\varphi_{mn}}|n\rangle.\end{split} (7)

In the above, {Rmn}\{R_{mn}\} are real parameters, and Rmn2R_{mn}^{2} is the probability of detecting a photon at the nnth output mode when prepared in the mmth initial state.

We introduce the overall loss function LL for reconstructing the initial states {|ψm}\{\ket{\psi_{m}}\} from outputs of the decoding network as follows

L=m=1Mn=0N1(JJ),\displaystyle L=\sum_{m=1}^{M}\sum_{n=0}^{N-1}\left(JJ^{*}\right), (8)

where J=RmneiφmnrmneiϕmnJ=R_{mn}e^{i\varphi_{mn}}-r_{mn}e^{i\phi_{mn}}. With this loss function, we can update the parameters in our network during the training process to minimize potential errors. In the ideal case L=0L=0, the information encoded in the initial states can be fully extracted without error. If the classical information is encoded only in the real coefficients {rmn}\{r_{mn}\} of the initial states {|ψm}\{\ket{\psi_{m}}\} (2) and the decoding network implements the inverse transformation, a simpler and more convenient loss function is

Linv=1χm|χm=ψm|TE1P1TE|ψm,\displaystyle L_{inv}=1-\braket{\chi_{m}}{\chi_{m}}=\braket{\psi_{m}}{T_{E}^{-1}P_{1}T_{E}}{\psi_{m}}, (9)

with P1=n=dN1|nn|P_{1}=\sum_{n=d}^{N-1}|n\rangle\langle n| denoting the projection onto the subspace of N\mathcal{H}_{N} that is complementary to the output space d\mathcal{H}_{d}. Note that P0P_{0} and P1P_{1} sum up to the identity operator on N\mathcal{H}_{N} and quantum states are normalized ψm|TE1P0TE|ψm+ψm|TE1P1TE|ψm=1\braket{\psi_{m}}{T_{E}^{-1}P_{0}T_{E}}{\psi_{m}}+\braket{\psi_{m}}{T_{E}^{-1}P_{1}T_{E}}{\psi_{m}}=1, thus LinvL_{inv} is exactly the probability that output photons are not detected at the last dd modes. Linv=0L_{inv}=0 necessarily means that the encoding network successfully transforms all the initial states into the output space d\mathcal{H}_{d}, |χm=TE|ψm\ket{\chi_{m}}=T_{E}\ket{\psi_{m}}, and the decoding network would perfectly recover those initial states.

We remark here that if the initial states span a space with a dimension larger than the dimension dd of the output space, the loss function LinvL_{inv} would never approach 0 in the training process. Consequently, there is also no reason to believe that a decoding network implementing the inverse transformation TD=TE1T_{D}=T_{E}^{-1} is optimal for minimizing LinvL_{inv} or, equivalently, maximizing the fidelity between the initial states and final states. This is in fact a much more general situation. To mitigate error, we may properly train the decoding network to exploit, besides the features of individual input states, also the structure of the input set. Moreover, properly extending the depths of our coding and decoding networks is expected to further enhance the overall fidelity.

In conclusion, we fashion the decoding network of the QSCD algorithm either by inverting the coding network or through parameter training of the decoding network. In the case of the decoding network with parameter training, the QSCD algorithm can be smoothly implemented in experiments, ensuring that parameter values remain within their designated range. Additionally, our approach to updating network parameters allows for concurrent updating of both the sparse coding network and the decoding network, solely through measuring the output states of the decoding network, eliminating the need for intermediate state measurements.

Image Reconstruction. For sparse coding and decoding of classical image information, the QSCD can be realized more efficiently. As shown in Fig. 2, firstly, the D1×D2D_{1}\times D_{2}-dimensional binary or grayscale image is converted into a column vector XmX_{m} with N×1N\times 1 dimension (ND1D2>N/2,N=2q,q+)\left(N\geq D_{1}D_{2}>N/2,N=2^{q},q\in\mathbb{N}^{+}\right). Further, XmX_{m} is encoded to a NN-dimensional real quantum state (j[D1D2,N1],xmn0)\left(\forall j\in\left[D_{1}D_{2},N-1\right],x_{mn}\equiv 0\right), so MM pictures are encoded to be the N×MN\times M-dimensional matrix XX. With n=0N1(rmn)2=1\sum_{n=0}^{N-1}\left(r_{mn}\right)^{2}=1 and setting all ϕmn=0\phi_{mn}=0, the encoded quantum state can be represented as |ψm=n=0N1rmn|n\left|\psi_{m}\right\rangle=\sum_{n=0}^{N-1}r_{mn}|n\rangle (see supplementary information IV and V). The probability amplitude is equal to the normalized value of the image grayscale value corresponding to Eq. (1). The code rmnr_{mn} can be obtained to facilitate the preparation of quantum states.

To see the performance of our network numerically, next we apply it to the 5×55\times 5 binary images of the 26 English capital letters as shown in Fig. 2a. Each binary image requires 5 qubits to be faithfully represented (D1D2=25,N=25)\left(D_{1}D_{2}=25,N=2^{5}\right). We choose a coding network with depth lE=20l_{E}=20 and a decoding network with depth lD=25l_{D}=25, the number of sparse coding channels is d=4d=4. Thus, the coding network and decoding network involve 480480 and 600600 rotation parameters θkl\theta_{k}^{l}, respectively (see supplementary information II). Further, we set the learning rate to be η=0.01\eta=0.01 and update the network parameters through 150 iterations. In each iteration, the output states of the decoding network are described by Eq. (7), with which we are able to compute the respective loss function according to Eq. (8). After each iteration, we then utilize the Quantum Natural Gradient Descent (QNGD) algorithm (see supplementary information III) to update the network parameters to reduce loss. The evolution of the real quantum states can be implemented by optical circuits to train and adjust the quantum gate parameters (see Methods). On the basis of the decrease of the loss function (Fig. 2c.), the reconstruction loss gradually tends to 0, and the gradient renewal of θ\theta gradually approaches 0 (Fig. 2d), with the parameters θ\theta gradually leveling off in the ranges of [0,π2]\left[0,\frac{\pi}{2}\right]. Eventually, the quantum network training is completed. The measurement results of output quantum states are converted to classical data x^mn\hat{x}_{mn} (Fig. 2b):

x^mn=σmRmn,\displaystyle\hat{x}_{mn}=\sigma_{m}R_{mn}, (10)

where σm=(nxmn2)1/2\sigma_{m}=(\sum_{n}x_{mn}^{2})^{1/2} is normalization factor of the respective pixel vector XmX_{m} as defined in Eq. (1). The implementations mean that the classical information can be sparsely encoded and decoded through the QSCD algorithm, where the data flow is Xmrmn|ψmTDP1TE|ψmRmnX^mX_{m}\rightarrow r_{mn}\rightarrow\left|\psi_{m}\right\rangle\rightarrow T_{D}P_{1}T_{E}\left|\psi_{m}\right\rangle\rightarrow R_{mn}\rightarrow\widehat{X}_{m}. Undoubtedly, it also makes sense to achieve sparse coding and decoding of high-frequency or low-frequency signals, which provides effective ideas for pattern recognition.

Refer to caption
Figure 2: Image reconstruction based on QSCD algorithm. 𝐚\mathbf{a} The input image with binary value in {0,1}\{0,1\}. 𝐛\mathbf{b} The output image with grayscale value in the range of [0,1][0,1]. During actually measuring the output quantum state in each iteration, the output of each iteration is always a real number in the range of [0,1][0,1] owing to the floating parameters. Therefore, the reconstruction results of binary images are gray images, which illustrates the training adaptability of the network. 𝐜\mathbf{c} The update gradients of θ\theta in 300 training iterations. At about the 100th training iteration, the quantum gate parameters tend to be stable with the gradients almost 0. 𝐝\mathbf{d} The distribution of optimal θ\theta. This distribution conforms to a normal distribution. 𝐞\mathbf{e} The loss of training network with N×MN\times M-dimensional matrix XX. The minimum MSE loss LL is 0.00873. 𝐟\mathbf{f} The training process of the sample letter ”Y” (X25)\left(X_{25}\right). The probability amplitude R25R_{25} eventually tends to be in the range of [1,1][-1,1]. 𝐠\mathbf{g} The similarity of overall samples (”A”-”Z”) between input images and output images in each iteration. After 300 training iterations that run for 895.234s895.234\mathrm{\leavevmode\nobreak\ s} (CPU runs), the final similarity between input and output images is 98.77%98.77\%.
Refer to caption
Figure 3: Sparse coding and decoding for complex quantum states. 𝐚\mathbf{a} The input and output quantum states. The amplitude and phase of the input and output quantum states are presented by measurement in polar coordinates. 𝐛\mathbf{b} The amplitude error EampE_{amp} and phase error EphaE_{pha} in training iterations. The minimum amplitude error minEamp=1.01×104\min E_{amp}=1.01\times 10^{-4}, The minimum phase error minEpha=0.0143\min E_{pha}=0.0143. 𝐜\mathbf{c} The complex error in polar coordinates. The minimum complex error is minEcomplex=(0.99+i)104\min E_{{complex}}=(0.99+i)10^{-4}. 𝐝\mathbf{d} The amplitude and phase error of 50 quantum state samples. The amplitude and phase error of 50 quantum state samples are given by calculation. 𝐞\mathbf{e} ALL of θ\theta and α\alpha and their gradients in the decoding network. 𝐟\mathbf{f} The distribution of optimal θ\theta and α\alpha. 𝐠\mathbf{g} The fidelity of training samples. The fidelity of the final quantum states is 97.68%97.68\%.

Sparse Coding and Decoding for Complex Quantum States. For solving quantum problems, sparse coding and decoding of quantum states play a significant role in quantum cryptography. we achieve the simulation of sparse coding and decoding for complex quantum states in this section. Firstly, we generate 50 3-qubit quantum states in 8-dimensional Hilbert space ( q=3,N=8,M=50q=3,N=8,M=50 ) as samples, and then they are input into the TET_{E} and TDT_{D} (or TE1T_{E}^{-1} ) to train parameters. Set network parameters: lE=10,lD=12,η=0.01,d=4l_{E}=10,l_{D}=12,\eta=0.01,d=4 and Ite=500Ite=500. By measuring the output states of the decoding network in each training iteration, the loss is calculated, so as to update the quantum gate parameters in Eq. (7). Obviously, we need to train both the phase shift αkl\alpha_{k}^{l} and reflectivity cosθkl\cos\theta_{k}^{l} (see supplementary information II, Fig. 3a). Therefore, the quantum network needs to be trained with 140140 parameters (θkl,αkl)\left(\theta_{k}^{l},\alpha_{k}^{l}\right) of the coding network and 168168 parameters (θ^kl,α^kl)\left(\hat{\theta}_{k}^{l},\hat{\alpha}_{k}^{l}\right) of the decoding network. In the quantum sparse coding network TET_{E}, only 4 output optical circuits are connected to the decoding network TDT_{D}. The amplitude error EampE_{\rm amp} and phase error EphaE_{\rm pha} are defined as Eamp=E_{\rm amp}= m=1Mn=0N1(Rmnrmn)2,Epha=m=1Mn=0N1(φmnϕmn)2\sum_{m=1}^{M}\sum_{n=0}^{N-1}\left(R_{mn}-r_{mn}\right)^{2},E_{\rm pha}=\sum_{m=1}^{M}\sum_{n=0}^{N-1}\left(\varphi_{mn}-\phi_{mn}\right)^{2}. As shown in Fig. 3b, Fig. 3c and Fig. 3d, the RmnR_{mn} and φmn\varphi_{mn} of the output quantum states are measured, and the error between output and input quantum states is obtained. Obviously, the initial phase error is significantly larger than the amplitude error (Fig. 3b), because for each quantum state in a quantum circuit, the probability amplitude RmnR_{mn} is much less than 1 (even most of which is in the range of [0.1,0.2])[0.1,0.2]). Furthermore, RmnR_{mn} and φmn\varphi_{mn} error of the final states will gradually range to 0 during continuous training. Finally, after 500 training iterations, the output states are similar to the input states in amplitude and phase. Another more intuitive error in polar coordinates in Fig. 3c, represents the complex error (Ecomplex=EampeiEpha)\left(E_{{\rm complex}}=E_{\rm amp}e^{iE_{\rm pha}}\right), which gradually tends to 0 with the slope around 0 in Fig. 3c.After training, the optimal results are obtained, in which input states and output states are similar in Fig. 3a. Therefore, the error of the ultimate reconstruction will be calculated, and then EampE_{\rm amp} and EphaE_{\rm pha} of the overall samples are extremely close to 0 in Fig. 3d. For the QSCD algorithm, only RmnR_{mn} and φmn\varphi_{mn} of the output quantum states are measured. Therefore, sparse coding and decoding of quantum states are able to be implemented in integrated optical circuits, simutaneously the elimination of the intermediate measurement can greatly reduce the system error. Using QSCD to achieve sparse coding and decoding of quantum states guarantees the transmission efficiency of quantum information.

Discussion
Generally, the QSCD algorithm can be implemented in physical hardware efficiently. It can achieve sparse coding and decoding by encoding classical image data (derived from the pixels of binary and grayscale images) into the amplitude of real quantum states. Furthermore, complex quantum states can also be sparsely coded and decoded by the QSCD algorithm through quantum unitary transformation and adaptive quantum natural gradient descent algorithm.

The superiority of the QSCD algorithm over traditional QNN based on Hamiltonian evolution is embodied in its lower computation complexity, better hardware-friendly performance, and ability to deal with higher dimensional information. The current optical quantum computing devices are more suitable for sparse quantum unitary transformation in our QSCD network, which increases the experimental efficiency and is expected to solve more quantum problems such as calculating eigenstates. Moreover, the differences between QSCD and CSC root in their computation frameworks, where the QSCD is constructed by multiple sparse matrices with the same dimensions, and the CSC is composed of one matrix full of weight parameters. In more detail, the two real parameters are updated together in each sparse matrix in the QSCD algorithm, nevertheless, the full weights are adjusted in a dictionary set in the CSC algorithm.

Methods
Quantum Gate Design.
In this paper, the QSCD algorithm is realized through quantum optical circuits. Specifically, a universal multi-port interferometer can be programmed to achieve any linear transformation between two channels by implementing a quantum gate U(k,k+1)U_{(k,k+1)} in port kk and k+1k+1, abbreviated to UkU_{k}. These interferometers typically consist of a regular grid of beam splitters and phase shifters and are manufactured directly with an integrated photon architecture and off-the-shelf scalability. At present, the standard design of universal multiport interferometers is based on the decomposing from any N×NN\times N unitary matrix to a linear combination of two-dimensional beam-splitting transform sequence WOS:000390793900027 . Compared with the traditional design, the main advantage of this design is only half the optical depth and more anti-optical loss (see supplementary information I).

𝐈𝐧𝐩𝐮𝐭:X,lE,lD to get [M,N]size(X)\displaystyle{\bf Input:}\ {X,l_{E},l_{D}\text{ to get }[M,N]\leftarrow\operatorname{size}(X)}
𝐎𝐮𝐭𝐩𝐮𝐭:(θklE,αklE),(θklD,αklD),gE,gD,L,X^i\displaystyle{\bf Output:}\ {\left(\theta_{k}^{l_{E}},\alpha_{k}^{l_{E}}\right),\left(\theta_{k}^{l_{D}},\alpha_{k}^{l_{D}}\right),g_{E},g_{D},L,\widehat{X}_{i}}
𝐈𝐧𝐢𝐭𝐢𝐚𝐥𝐢𝐳𝐞(θ,α)(π/3,2π/3),Ite=150,η=0.01,d=4\displaystyle{\bf Initialize}\ (\theta,\alpha)\leftarrow(\pi/3,2\pi/3),\text{Ite}=150,\eta=0.01,d=4
form=1:M\displaystyle\textbf{for}\ {m=1:M}
|ψmXm\displaystyle\left|\psi_{m}\right\rangle\leftarrow X_{m}
end
[(θklE,αklE),(θklD,αklD),gE,gD,L]\displaystyle\left[\Big{(}\theta_{k}^{l_{E}},\alpha_{k}^{l_{E}}\Big{)},\left(\theta_{k}^{l_{D}},\alpha_{k}^{l_{D}}\right),g_{E},g_{D},L\right]
=trainQSCD(lE,lD,|ψ,(θ,α),Ite,η,d)\displaystyle=\operatorname{trainQSCD}\left(l_{E},l_{D},|\psi\rangle,(\theta,\alpha),{Ite},\eta,d\right)
Form=1:M\displaystyle\textbf{For}\ {m=1:M}
|Ψ^m=TD(θklD,αklD)P1TE(θklE,αklE)|ψm\displaystyle\left|\hat{\Psi}_{m}\right\rangle=T_{D}\left(\theta_{k}^{l_{D}},\alpha_{k}^{l_{D}}\right)P_{1}T_{E}\left(\theta_{k}^{l_{E}},\alpha_{k}^{l_{E}}\right)\left|\psi_{m}\right\rangle
X^m|Ψ^m\displaystyle\widehat{X}_{m}\leftarrow\left|\hat{\Psi}_{m}\right\rangle
𝐞𝐧𝐝\displaystyle{\bf end}
Algorithm 1 Calculate the Quantum Sparse Coding and Decoding with respect to the XX.
𝐈𝐧𝐩𝐮𝐭:lE,lD,|ψ,(θ,α),Ite,η,d to get [M,N]\displaystyle{\bf Input:}\ l_{E},l_{D},|\psi\rangle,\left(\theta,\alpha\right),Ite,\eta,d\text{ to get }[M,N]
𝐎𝐮𝐭𝐩𝐮𝐭:(θklE,αklE),(θklD,αklD),gE,gD,L\displaystyle{\bf Output:}\ \left(\theta_{k}^{l_{E}},\alpha_{k}^{l_{E}}\right),\left(\theta_{k}^{l_{D}},\alpha_{k}^{l_{D}}\right),g_{E},g_{D},L
𝐈𝐧𝐢𝐭𝐢𝐚𝐥𝐢𝐳𝐞Δ=108\displaystyle{\bf Initialize}\ \varDelta=10^{-8}
|Ψ^=TD(θ,α)P1TE(θ,α)|ψ\displaystyle\left|\hat{\Psi}\right\rangle=T_{D}\left(\theta,\alpha\right)P_{1}T_{E}\left(\theta,\alpha\right)|\psi\rangle
Update:(θklE,αklE)\displaystyle\textbf{Update:}\ \left(\theta_{k}^{l_{E}},\alpha_{k}^{l_{E}}\right)
fori=1:Ite\displaystyle\textbf{for}\ {i=1:Ite}
L=(Rmnrmn)2\displaystyle L=\left(R_{mn}-r_{mn}\right)^{2}
forl=1:lE\displaystyle\textbf{for}\ {l=1:l_{E}}
fork=1:N\displaystyle\textbf{for}\ {k=1:N}
θkl=[TDP1TE(θkl+Δ,αkl)TDP1TE(θkl,αkl)]/Δ\displaystyle\partial\theta_{k}^{l}=\left[T_{D}P_{1}T_{E}\left(\theta_{k}^{l}+\varDelta,\alpha_{k}^{l}\right)-T_{D}P_{1}T_{E}\left(\theta_{k}^{l},\alpha_{k}^{l}\right)\right]/\varDelta
αkl=[TDP1TE(θkl,αkl+Δ)TDP1TE(θkl,αkl)]/Δ\displaystyle\partial\alpha_{k}^{l}=\left[T_{D}P_{1}T_{E}\left(\theta_{k}^{l},\alpha_{k}^{l}+\varDelta\right)-T_{D}P_{1}T_{E}\left(\theta_{k}^{l},\alpha_{k}^{l}\right)\right]/\varDelta
gE(θkl)=sum(L(θkl))/(M×N)\displaystyle g_{E}\left(\theta_{k}^{l}\right)=sum\left(L\cdot\partial\left(\theta_{k}^{l}\right)\right)/\left(M\times N\right)
gE(αkl)=sum(L(αkl))/(M×N)\displaystyle g_{E}\left(\alpha_{k}^{l}\right)=sum\left(L\cdot\partial\left(\alpha_{k}^{l}\right)\right)/\left(M\times N\right)
θkl=θklηgE(θkl),αkl=αklηgE(αkl)\displaystyle\theta_{k}^{l}=\theta_{k}^{l}-\eta g_{E}\left(\theta_{k}^{l}\right),\alpha_{k}^{l}=\alpha_{k}^{l}-\eta g_{E}\left(\alpha_{k}^{l}\right)
𝐞𝐧𝐝\displaystyle{\bf end}
𝐞𝐧𝐝\displaystyle{\bf end}
same way to calculategDto update(θklD,αklD)\displaystyle\textbf{same way to calculate}\ g_{D}\ \textbf{to update}\ \left(\theta_{k}^{l_{D}},\alpha_{k}^{l_{D}}\right)\
Algorithm 2 Calculate the loss function and the gradients to update (θ,α)(\theta,\alpha), trainQSCD.
𝐈𝐧𝐩𝐮𝐭:(θ,α),[M,N]\displaystyle{\bf Input:}\ \left(\theta,\alpha\right),[M,N]\hskip 284.52756pt
𝐎𝐮𝐭𝐩𝐮𝐭:TE,TD\displaystyle{\bf Output:}\ T_{E},T_{D}
𝐈𝐧𝐢𝐭𝐢𝐚𝐥𝐢𝐳𝐞Uk,UE,TE,UE,TE\displaystyle{\bf Initialize}\ U_{k},U_{E},T_{E},U_{E},T_{E}
forl=1:M\displaystyle\textbf{for}\ {l=1:M}
θθl,ααl\displaystyle\theta\leftarrow\theta^{l},\alpha\leftarrow\alpha^{l}
fork=1:N1\displaystyle\textbf{for}\ {k=1:N-1}
UE(l)=UE(l)Uk(θkl,αkl)\displaystyle U_{E}^{\left(l\right)}=U_{E}^{\left(l\right)}U_{k}(\theta_{k}^{l},\alpha_{k}^{l})
𝐞𝐧𝐝\displaystyle{\bf end}
TE=TEUE(l)\displaystyle T_{E}=T_{E}U_{E}^{\left(l\right)}
Reset:UE\displaystyle\textbf{Reset:}\ U_{E}
𝐞𝐧𝐝\displaystyle{\bf end}
same way to constructUD,TD\displaystyle\textbf{same way to construct}\ U_{D},T_{D}\
Algorithm 3 Construct the quantum network TET_{E} and TDT_{D}.

QSCD Algorithm. According to the theory of the QSCD algorithm, the main program can be summarized as Algorithm. 1. The main simulation programs are parameter training and quantum gate construction, which are simulated with Matlab programming language. As shown in Algorithm. 1, for classical image data, there are data-to-state coding function and training function (trainQSCD). Given parameter initialization, the rr and ϕ\phi of quantum states are input to train (θ,α)(\theta,\alpha) of quantum network by Algorithm. 2. After that, the program is presented in Algorithm. 3. is called, then the output result is obtained by implementing the coding and decoding process TDP1TET_{D}P_{1}T_{E}. Finally, the program returns reconstruction results and procedure parameters.

Quantum Natural Gradient Descent Algorithm. The trainQSCD\operatorname{trainQSCD} pseudocode calculates the gradient of the (θ,α)(\theta,\alpha), which is denoted as the gradient gEg_{E} for network TET_{E} and gDg_{D} for network TET_{E}. In the process, the quantum natural gradient of quantum gate parameters (θ,α)(\theta,\alpha) is calculated by the QNGD algorithm WOS:000940796200001 . Afterward, based on the update of parameter gradients, the renewal of parameters will be acted upon in the next training iteration. It is noticed that the parameters (θ,α)(\theta,\alpha) are updated at the same time, but the adjustment of the reflectivity θ\theta will not affect the adjustment of the phase α\alpha (see supplementary information II).

Quantum Network Construction. Constructed with multi-layer rotation gate UkU_{k}, the network TET_{E} and TDT_{D} can also be combined into a quantum network of any depth separately in Algorithm. 3. The quantum network construction gives out the form of the unitary transformation, which can be in Order type and Cross type (see supplementary information I). In the network TDT_{D}, the transformation UDU_{D} needs to be connected in reverse order of UEU_{E} in sparse coding network TET_{E}.

CODE AVAILABILITY
Some of the simulation code can be found in https://github.com/Jixun97/QSCD.git. The complete code used for simulations is available from the corresponding authors upon reasonable request.

ACKNOWLEDGMENTS
This work is supported by the National Natural Science Foundation of China (No. 12175104), the National Key Research and Development Program of China (No. 2023YFC2205802), and the Innovation Program for Quantum Science and Technology (No. 2021ZD0301701).

AUTHOR CONTRIBUTIONS
X.J. and Q.L. and S.H. contributed equally. S.W. directed and supervised the project. S.W., X.J., and Q.L. proposed the QSCD algorithm and designed the implementations. X.J. performed the numerical simulation and analyzed the data with the assistance of Q.L., S.H., and A.C.. Q.L. and X.J. provided theoretical support under the guidance of S.W.. A.C. and Q.L. provided data support. X.J., Q.L., and S.H. wrote and revised the manuscript with feedback from all authors.

ADDITIONAL INFORMATION
Supplementary information:
Supplementary Information to: Quantum Sparse Coding and Decoding Based on Quantum Network.
Supplementary training demo video: A gray image training process is based on the QSCD algorithm.
Competing interests: The authors declare no competing interests.

References

  • (1) LeCun, Y., Bengio, Y. & Hinton, G. Deep learning. Nature 521, 436–444 (2015).
  • (2) Biamonte, J. et al. Quantum machine learning. Nature 549, 195–202 (2017).
  • (3) Lloyd, S., Mohseni, M. & Rebentrost, P. Quantum principal component analysis. Nat. Phys. 10, 631–633 (2014).
  • (4) Cong, I., Choi, S. & Lukin, M. D. Quantum convolutional neural networks. Nat. Phys. 15, 1273–1278 (2019).
  • (5) Zhou, M.-G. et al. Quantum neural network for quantum neural computing. Research 6, 0134 (2023).
  • (6) Lu, H. et al. Experimental quantum network coding. npj Quantum Inf. 5, 89 (2019).
  • (7) Schumacher, B. Quantum coding. Phys. Rev. A 51, 2738–2747 (1995).
  • (8) Dennis, E., Kitaev, A., Landahl, A. & Preskill, J. Topological quantum memory. J. Math. Phys. 43, 4452–4505 (2002).
  • (9) Bellante, A. & Zanero, S. Quantum matching pursuit: A quantum algorithm for sparse representations. Phys. Rev. A 105, 022414 (2022).
  • (10) Robotka, H. et al. Sparse ensemble neural code for a complete vocal repertoire. Cell Rep. 42, 112034 (2023).
  • (11) Sheridan, P. M. et al. Sparse coding with memristor networks. Nat. Nanotechnol. 12, 784–789 (2017).
  • (12) Rozell, C. J., Johnson, D. H., Baraniuk, R. G. & Olshausen, B. A. Sparse coding via thresholding and local competition in neural circuits. Neural Comput. 20, 2526–2563 (2008).
  • (13) Vinje, W. & Gallant, J. Sparse coding and decorrelation in primary visual cortex during natural vision. Science 287, 1273–1276 (2000).
  • (14) Ji, X., Hu, X., Zhou, Y., Dong, Z. & Duan, S. Adaptive sparse coding based on memristive neural network with applications. Cogn. Neurodyn. 13, 475–488 (2019).
  • (15) Wright, J. et al. Sparse representation for computer vision and pattern recognition. Proc. Inst. Electr. Eng. 98, 1031–1044 (2010).
  • (16) Olshausen, B. & Field, D. Emergence of simple-cell receptive field properties by learning a sparse code for natural images. Nature 381, 607–609 (1996).
  • (17) Cao, H., Cao, F. & Wang, D. Quantum artificial neural networks with applications. Inf. Sci. 290, 1–6 (2015).
  • (18) Torlai, G. et al. Neural-network quantum state tomography. Nat. Phys. 14, 447–450 (2018).
  • (19) Gao, X., Zhang, Z. Y. & Duan, L. M. A quantum machine learning algorithm based on generative models. Sci. Adv. 4, eaat9004 (2018).
  • (20) Beer, K. et al. Training deep quantum neural networks. Nat. Commun. 11, 808 (2020).
  • (21) Miller, D. A. B. Self-configuring universal linear optical component. Photonics Res. 1, 1–15 (2013).
  • (22) Spagnolo, N. et al. Experimental validation of photonic boson sampling. Nat. Photonics 8, 615–620 (2014).
  • (23) Schuld, M., Sweke, R. & Meyer, J. J. Effect of data encoding on the expressive power of variational quantum-machine-learning models. Phys. Rev. A 103, 032430 (2021).
  • (24) Abbas, A. et al. The power of quantum neural networks. Nat. Comput. Sci. 1, 403–409 (2021).
  • (25) Liu, J. et al. Hybrid quantum-classical convolutional neural networks. Sci. China Phys. Mech. 64, 290311 (2021).
  • (26) Zhou, L., Lin, J., Jing, Y. & Yuan, Z. Twin-field quantum key distribution without optical frequency dissemination. Nat. Commun. 14, 928 (2023).
  • (27) Harrow, A. W. & Montanaro, A. Quantum computational supremacy. Nature 549, 203–209 (2017).
  • (28) Clements, W. R., Humphreys, P. C., Metcalf, B. J., Kolthammer, W. S. & Walmsley, I. A. Optimal design for universal multiport interferometers. Optica 3, 1460–1465 (2016).
  • (29) Steinbrecher, G. R., Olson, J. P., Englund, D. & Carolan, J. Quantum optical neural networks. npj Quantum Inf. 5, 60 (2019).
  • (30) Pan, X. et al. Experimental quantum end-to-end learning on a superconducting processor. npj Quantum Inf. 9, 18 (2023).
  • (31) Meitei, O. R. et al. Gate-free state preparation for fast variational quantum eigensolver simulations. npj Quantum Inf. 7, 155 (2021).
  • (32) Graydon, O. Birth of the programmable optical chip. Nat. Photonics 10, 1 (2016).
  • (33) Peruzzo, A. et al. A variational eigenvalue solver on a photonic quantum processor. Nat. Commun. 5, 4213 (2014).
  • (34) Reck, M., Zeilinger, A., Bernstein, H. J. & Bertani, P. Experimental realization of any discrete unitary operator. Phys. Rev. Lett. 73, 58 (1994).
  • (35) Rudolph, M. S. et al. Generation of high-resolution handwritten digits with an ion-trap quantum computer. Phys. Rev. X 12, 031010 (2022).
  • (36) Du, Y., Hsieh, M.-H., Liu, T. & Tao, D. Expressive power of parametrized quantum circuits. Phys. Rev. Res. 2, 033125 (2020).
  • (37) Benedetti, M. et al. A generative modeling approach for benchmarking and training shallow quantum circuits. npj Quantum Inf. 5, 45 (2019).
  • (38) Zhu, D. et al. Training of quantum circuits on a hybrid quantum computer. Sci. Adv. 5, eaaw9918 (2019).
  • (39) Zeng, J., Wu, Y., Liu, J.-G., Wang, L. & Hu, J. Learning and inference on generative adversarial quantum circuits. Phys. Rev. A 99, 052306 (2019).
  • (40) Tacchino, F., Macchiavello, C., Gerace, D. & Bajoni, D. An artificial neuron implemented on an actual quantum processor. npj Quantum Inf. 5, 26 (2019).
  • (41) Hu, L. et al. Quantum generative adversarial learning in a superconducting quantum circuit. Sci. Adv. 5, eaav2761 (2019).
  • (42) Cerezo, M., Verdon, G., Huang, H.-Y., Cincio, L. & Coles, P. J. Challenges and opportunities in quantum machine learning. Nat. Comput. Sci. 2, 567–576 (2022).
  • (43) Mitarai, K., Negoro, M., Kitagawa, M. & Fujii, K. Quantum circuit learning. Phys. Rev. A 98, 032309 (2018).
  • (44) Shafee, F. Neural networks with quantum gated nodes. Eng. Appl. Artif. Intell. 20, 429–437 (2007).
  • (45) Concha, D., Pereira, L., Zambrano, L. & Delgado, A. Training a quantum measurement device to discriminate unknown non-orthogonal quantum states. Sci. Rep. 13, 7460 (2023).
  • (46) Metcalf, B. J. et al. Multiphoton quantum interference in a multiport integrated photonic device. Nat. Commun. 4, 1356 (2013).
  • (47) Peruzzo, A., Laing, A., Politi, A., Rudolph, T. & O’Brien, J. L. Multimode quantum interference of photons in multiport integrated devices. Nat. Commun. 2, 224 (2011).