Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Quantum Autoencoders With Enhanced Data Encoding

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Quantum autoencoders with enhanced data encoding

Carlos Bravo-Prieto1, 2
1
Departament de Física Quàntica i Astrofísica and Institut de Ciències del Cosmos (ICCUB),
Universitat de Barcelona, Martí i Franquès 1, 08028 Barcelona, Spain.
2
Technology Innovation Institute, Abu Dhabi.
We present the enhanced feature quantum autoencoder, or EF-QAE, a variational quantum al-
gorithm capable of compressing quantum states of different models with higher fidelity. The key
idea of the algorithm is to define a parameterized quantum circuit that depends upon adjustable
parameters and a feature vector that characterizes such a model. We assess the validity of the
method in simulations by compressing ground states of the Ising model and classical handwritten
digits. The results show that EF-QAE improves the performance compared to the standard quan-
arXiv:2010.06599v1 [quant-ph] 13 Oct 2020

tum autoencoder using the same amount of quantum resources, but at the expense of additional
classical optimization. Therefore, EF-QAE makes the task of compressing quantum information
better suited to be implemented in near-term quantum devices.

|0i
 
I. INTRODUCTION 
 

 
|0i

 


 


 

Large-scale fault-tolerant quantum computation is 
 |0i


a rather distant dream, typically estimated to be a ρin  U (θ) U † (θ) ρout
 |0i 

few decades ahead. A reasonable question then is 







whether we can do something useful with the ex-

 


 

 
isting noisy intermediate-scale quantum (NISQ) [1]
computers. The main proposal is to use them as
FIG. 1. Circuit implementation of a quantum autoen-
a part of a hybrid classical-quantum device. The
coder with a 2-qubit latent space. The unitary U (θ)
variational quantum algorithms (VQAs) are a class encodes a 6-qubit input state ρin into a 2-qubit interme-
of algorithms that use such hybrid devices, which diate state, after which the decoder U † (θ) attempts to
manage to reduce the requisites of quantum compu- reconstruct the input, resulting in the output state ρout .
tational resources at the expense of classical compu-
tation.
The general rationale of a VQA is to define a quantum circuit U (θ) that encodes an initial input
parametrized quantum circuit whose architecture is state into an intermediate latent space, after which
dictated by the type and size of the quantum com- the action of the decoder, U † (θ), attempts to recon-
puter that is available. This quantum circuit, in struct the input. A graphical depiction of a QAE is
turn, will depend on a set of classical parameters shown in Fig. 1.
that can be adjusted using a quantum-classical op- Note that the motivation for a quantum autoen-
timization loop by minimizing a cost function. In coder is to be able to recognize patterns beyond the
this manner, we look for a quantum circuit that al- capabilities of a classical autoencoder, given the dif-
lows to perform a particular task, given the avail- ferent properties of quantum mechanics. Moreover,
able quantum resources. Several VQAs have already recall that for NISQ devices, any tool that can re-
been proposed in the context of making NISQ com- duce the amount of quantum resources can be con-
puters practically useful for real applications [2–15]. sidered valuable. For instance, quantum autoen-
Lately, much attention has been paid to data en- coders could be used as a state preparation engine
coding in VQAs [16, 17]. Indeed, it was proven that in the context of other VQAs. That is, we could
data encoded into the model influences the expres- combine, say, a Variational Quantum Eigensolver [2]
sive power of parameterized quantum circuits [18]. with a pretrained QAE, where now the only active
Specifically, this idea has been implemented for clas- parameters are associated with the latent space.
sification of data [19, 20], and very recently, to study In the following, we present the enhanced fea-
energy profiles of quantum Hamiltonians [21]. Here, ture quantum autoencoder (EF-QAE). As we will
we introduce this concept to the Quantum Autoen- see, its key ingredient is to define a parameterized
coder (QAE) [7], a VQA designed to compress the quantum circuit that depends upon adjustable pa-
input quantum information through a smaller latent rameters and a feature vector that characterizes the
space. In this scheme, we look for a parameterized model we aim to compress.
FIG. 2. Schematic representation of the EF-QAE. The input to EF-QAE is a set of initial states ρin , a feature vector
x that characterizes the initial states, and a shallow sequence of quantum gates U . The feature vector x is encoded
together with the variational parameters θ, where the latter are adjusted in a quantum-classical optimization loop
until the local cost C(θ) converges to a value close to 0. When this loop terminates and the optimal parameters θopt
are found, the resulting circuit U (θopt , x) prepares compressed states |φi of a particular model. Moreover, we may
apply U † (θopt , x)|0 . . . 0i ⊗ |φi to recover ρout ≈ ρin .

II. EF-QAE ALGORITHM tal amount of non-zero measurement outcomes on


the nt trash qubits, which will be minimized. To
A. Overview design the cost function to be local, different out-
comes may be penalized by their Hamming distance
Here, we present the enhanced feature quantum to the |0i⊗nt state, which is just the number of sym-
autoencoder (EF-QAE). A schematic diagram of the bols that are different in the binary representation.
EF-QAE can be seen in Fig. 2. The algorithm can Thus, the local cost function C to be minimized sim-
be initialized with a set of initial states ρin ply is
i , a fea-
n
ture vector x, and a shallow sequence of quantum X 1Xt

gates U . In this scheme, we define a unitary U (θ, x) C≡ dH Mk,j ≡ (1 − hZk i) , (1)


2
acting on the initial state ρin
i , where x is a feature
k,j k=1
vector that characterizes the set of input states. For where dH denotes the Hamming distance and Mk,j
instance, as we will see in Sec. III, x may be the are the results of the j-th measurement on the k
transverse field λ of the 1D Ising spin chain. Once trash qubit in the computational basis. Equiva-
the trial state is prepared, measurements are per- lently, it can also be defined in terms of local Z Pauli
formed to evaluate the cost function C(θ). This re- operators. We may now apply classical optimization
sult is then fed into the classical optimizer, where techniques to find the optimal parameters that pro-
the parameters θ are adjusted in a quantum-classical vide exact output coincidence to the |0i⊗nt state on
loop until the cost function converges to a value close the trash qubits. Finally, notice that this cost func-
to 0. When the loop terminates, U (θopt , x) prepares tion delivers direct information on how the compres-
compressed states |φi of a particular model. sion of the trash qubits is performed, and has a zero
value if and only if the compression is completed.

B. Cost function
C. Ansatz
The quantum information of the input state
through the smaller latent space must be stored. To implement the EF-QAE model on a quan-
Therefore, it is important to quantify how well the tum computer, we must define the form of the
information is preserved in the compressed state |φi. parametrized unitary U (θ, x), decomposing it into
This is general is quantified by a cost function that a quantum circuit suitable for optimization. Recall
one has to minimize. In Ref. [7], this cost function is that a quantum autoencoder may be thought of as a
not constructed from local operators, and therefore disentangling unitary. The complexity of the circuit
it may lead to trainability issues even for shallow thus limits this property. Given the limited avail-
depth quantum circuits [22, 23]. able quantum resources in practice, due to the co-
Here, however, we use a cost function designed herence times and gate errors, we will look for a cir-
from local operators [23]. A figure of merit for cuit structure that maximally exploits entanglement
the wrong answer when training is simply the to- while maintaining a shallow depth.

2
Ry • • • Ry • • • Ry

100
QAE







 Ry • • • Ry • • • Ry EF-QAE


Ry • Ry • EF-QAE*

 

|ψi

Cost function

Ry • Ry •
 


|φi



Ry • Ry •

 

 


 

 
Ry • Ry •
10−1
FIG. 3. Variational quantum ansatz employed for the
EF-QAE model. As indicated by the dashed box, each
layer is composed of CZ gates acting on the trash qubits
preceded by Ry qubit rotations, Ry (θj ) = e−iθj Y /2 . A 0 5000 10000 15000 20000 25000 30000 35000 40000
cascade of CZ gates is then applied between the trash Optimization steps
qubits and the qubits containing the final compressed
state. After implementing the layered ansatz, a final
layer of Ry qubit gates is applied to the trash qubits. FIG. 4. Cost function value as a function of the num-
Note that the sequence of entangling gates can be applied ber of optimization steps. Here, we consider the stan-
mostly in parallel. dard QAE, EF-QAE, and EF-QAE*. The EF-QAE* is
the EF-QAE initialized with the optimal parameters of
QAE. The EF-QAE achieves twice the compression of
the QAE using the same quantum resources, at the ex-
A primitive strategy to construct a variational cir- pense of additional classical optimization.
cuit in a more general case may consist of building
a circuit of arbitrary 2- and 1-qubit gates character-
ized by some parameters. However, this is a naive for the simulation of the quantum circuits. Here,
approach. The action of the EF-QAE on the original we benchmark both the EF-QAE and the standard
state is QAE in the case of a paradigmatic quantum spin
chain with 6 qubits, the transverse field Ising model.
U |ψi = |0i ⊗ . . . ⊗ |0i ⊗ |φi . (2) The 1D Ising model is described by the following
Hamiltonian
Thus, it is clear that the entangling gates should X X
mostly act between each of the trash qubits, and HIsing = σjz σj+1
z
+λ σjx , (4)
between the trash qubits and the qubits containing j j
the final compressed state. Subsequently, we may
where λ is the transverse field. In the thermody-
avoid using entangling gates between the qubits that
namic limit, the system has a quantum phase tran-
are not trash while maximizing the entangling gates
sition exactly at λ = 1.
on the ones of interest. This could be done using a
The EF-QAE and QAE are optimized over a train-
similar structure to that depicted in Fig. 3. Notice
ing set of ground states of the Ising model. Specif-
that most of the sequence of entangling gates can be
ically, we have considered N=20 equispaced ground
applied in parallel at the same step.
states in between λ = 0.5 and λ = 1.0, with initial
We now encode the feature vector x into each of
random parameters. For the cost function, we com-
the single Ry qubit rotations by using a linear func-
puted Eq. 1 for each training state and then averaged
tion as
them as
  P
Ry(i,j) (θ, x) = Ry θ(i) x(j) + θ(i+1) , (3) C
CN = N . (5)
N
where i, j simply indicates a component of the vec- Nonetheless, notice that for other models, sophisti-
tor, and θ are the parameters adjusted in the opti- cated cost functions could be more convenient to im-
mization loop. plement. We have considered the variational quan-
tum circuit in Fig. 3 with 3 layers, and therefore, the
resulting compressed state contains 4 qubits. Note
III. 1D ISING SPIN CHAIN that the feature vector x for the EF-QAE is simply
a scalar that takes the value of the transverse field
The EF-QAE can be verified on simulations. We λ. Lastly, the classical technique employed in the
utilized the open-source Python API Qibo [24, 25] optimization loop is the BFGS method.

3
FIG. 5. Visualization of the input space, trash space, and output space for the EF-QAE and QAE, considering two
different test ground states of the 1D Ising model corresponding to (a) λ = 0.60 and (b) λ = 0.75. The size of the
registers appears within parenthesis (number of qubits). The spaces are characterized as the density matrices of the
input, trash and output states. Integer labels denote the binary representation of the computational basis states.

In Fig. 4, we show the cost function value as a IV. HANDWRITTEN DIGITS


function of the number of optimization steps. The
EF-QAE* is simply the EF-QAE initialized with
In this section, we benchmark EF-QAE and QAE
the optimal parameters of QAE. This way, the EF-
models in the case of 8 × 8 handwritten digit com-
QAE* will always improve the QAE performance.
pression with 6 qubits using 4 layers. The data com-
As can be seen, the EF-QAE achieves twice the com-
prising each digit consists of a matrix with values
pression of the QAE using the same quantum re-
from 0 to 16 corresponding to a gray map. Each
sources. Notice, however, that the EF-QAE contains
value of this matrix is encoded in the amplitude of
twice as many variational parameters, and therefore,
a 6-qubit state, further restricted to normalization.
the increase in performance is at the expense of ad-
ditional classical optimization. The EF-QAE and QAE are optimized over a
training set of handwritten digits obtained from the
Python package Scikit Learn [26]. Specifically, we
have considered N=20 handwritten digits, 10 of each
To quantify these expectations, we assess both corresponding to 0 or 1. The simulation details are
EF-QAE and QAE with the optimal parameters equivalent to those in Sec. III. Here, the feature vec-
against two test ground states of the Ising model, tor for the EF-QAE corresponds to x = (1, 2). That
specifically, with λ = 0.60 and λ = 0.75. The re- is, we simply input a value of x = 1 (x = 2) if the
sults are shown in Fig. 5. Here, we show a density handwritten digit corresponds to 0 (1). The ratio-
matrix visualization of the input, trash, and output nale behind choosing x = (1, 2) is that no obvious
state. The EF-QAE achieves better compression to feature distinguishes both digits. Nonetheless, more
the |00i trash state, and therefore, higher fidelity convenient strategies could be used in future work.
on the output state. As we change the values of the For instance, one may allow the feature vector x to
transverse field, we note that the compression differs. be a free variational parameter.
Both cases considered, however, the performance of In Fig. 6, we show the cost function value as a
the EF-QAE is preferable. function of the number of optimization steps. Re-

4
100 QAE
EF-QAE
EF-QAE*
Cost function

10−1

0 5000 10000 15000 20000 25000


Optimization steps

FIG. 6. Cost function value as a function of the num-


ber of optimization steps. Here, we consider the stan-
dard QAE, EF-QAE, and EF-QAE*. The EF-QAE* is
the EF-QAE initialized with the optimal parameters of
QAE. The EF-QAE achieves three times the compres-
sion of the QAE using the same quantum resources, at
the expense of additional classical optimization.

call that EF-QAE* is simply the EF-QAE initialized


with the optimal parameters of QAE. The behavior
is similar to the one observed in the case of the Ising
model, where the EF-QAE achieves three times the FIG. 7. Images of 0 and 1 handwritten test digits en-
coded into a 6-qubit state (8 × 8 pixels). Images shown
compression of the QAE using the same quantum
correspond to the input state, and the output states of
resources. the EF-QAE and QAE models. As can be seen, the fi-
Once again, to gain insight into the compression delity of the EF-QAE output state is improved compared
process, we assess both EF-QAE and QAE with the to QAE.
optimal parameters against two handwritten test
digits corresponding to 0 and 1. The results are
shown in Fig. 7. Here, we plot the output digit of
and classical handwritten digits encoded into quan-
the EF-QAE and QAE. Once more, since EF-QAE
tum states. We compared the results with the stan-
achieves better compression to the |00i trash state,
dard QAE. The results show that EF-QAE achieves
we obtain higher fidelity on the output state. Re-
better compression of the initial state, and there-
markably, in both cases, the performance of the EF-
fore, the final output state is recovered with higher
QAE is improved with respect to the QAE.
fidelity. Moreover, the learning task of EF-QAE can
be initialized with the optimal QAE parameters. In
this manner, EF-QAE will always improve the QAE
V. DISCUSSION performance. Nonetheless, the encoding strategy of
the feature vector is amenable to be improved, for
We have presented a variational quantum algo- instance, using a non-linear encoding or allowing the
rithm called EF-QAE capable of compressing quan- feature vector to be a free variational parameter.
tum data of a parameterized model. In contrast to On the counterpart, EF-QAE needs additional
standard QAE, EF-QAE achieves this compression classical optimization compared to QAE. However,
with higher fidelity. Its key idea is to define a pa- in contrast, we increase the compression perfor-
rameterized quantum circuit that depends upon ad- mance using the same amount of limited quantum
justable parameters and a feature vector that char- resources. In this sense, EF-QAE is a step toward
acterizes such a model. what could be done on NISQ computers, shortening
We have validated the EF-QAE in simulations by the distance between current quantum devices and
compressing ground states of the 1D Ising spin chain, practical applications.

5
CODE AVAILABILITY This work is supported by the projects PGC2018-
095862-B-C22 and Quantum CAT 001-P-001644.
The code is available in Github [27].

ACKNOWLEDGEMENTS

The author would like to thank Diego García-


Martín and José I. Latorre for fruitful discussions.

[1] J. Preskill, Quantum 2, 79 (2018). [18] M. Schuld, R. Sweke, and J. J. Meyer,


[2] A. Peruzzo, J. McClean, P. Shadbolt, M.-H. Yung, arXiv:2008.08605 (2020).
X.-Q. Zhou, P. J. Love, A. Aspuru-Guzik, and J. L. [19] V. Havlíček, A. D. Córcoles, K. Temme, A. W. Har-
O’Brien, Nature Communications 5, 4213 (2014). row, A. Kandala, J. M. Chow, and J. M. Gambetta,
[3] C. Kokail, C. Maier, R. van Bijnen, T. Brydges, Nature 567, 209 (2019).
M. K. Joshi, P. Jurcevic, C. A. Muschik, P. Silvi, [20] A. Pérez-Salinas, A. Cervera-Lierta, E. Gil-Fuster,
R. Blatt, C. F. Roos, and P. Zoller, Nature 569, and J. I. Latorre, Quantum 4, 226 (2020).
355 (2019). [21] A. Cervera-Lierta, J. S. Kottmann, and A. Aspuru-
[4] O. Higgott, D. Wang, and S. Brierley, Quantum 3, Guzik, arXiv:2009.13545 (2020).
156 (2019). [22] J. R. McClean, S. Boixo, V. N. Smelyanskiy, R. Bab-
[5] T. Jones, S. Endo, S. McArdle, X. Yuan, and S. C. bush, and H. Neven, Nature Communications 9,
Benjamin, Physical Review A 99, 062304 (2019). 4812 (2018).
[6] Y. Li and S. C. Benjamin, Physical Review X 7, [23] M. Cerezo, A. Sone, T. Volkoff, L. Cincio, and P. J.
021050 (2017). Coles, arXiv:2001.00550 (2020).
[7] J. Romero, J. P. Olson, and A. Aspuru-Guzik, [24] S. Efthymiou, S. Ramos-Calderer, C. Bravo-Prieto,
Quantum Science and Technology 2, 045001 (2017). A. Pérez-Salinas, D. García-Martín, A. Garcia-Saez,
[8] S. Khatri, R. LaRose, A. Poremba, L. Cincio, A. T. J. I. Latorre, and S. Carrazza, “Quantum-TII/qibo
Sornborger, and P. J. Coles, Quantum 3, 140 on Github,” Zenodo, DOI:10.5281/zenodo.3997194
(2019). (2020).
[9] R. LaRose, A. Tikku, É. O’Neel-Judy, L. Cincio, [25] S. Efthymiou, S. Ramos-Calderer, C. Bravo-Prieto,
and P. J. Coles, npj Quantum Information 5, 1 A. Pérez-Salinas, D. García-Martín, A. Garcia-Saez,
(2018). J. I. Latorre, and S. Carrazza, arXiv:2009.01845
[10] C. Bravo-Prieto, D. García-Martín, and J. I. La- (2020).
torre, Physical Review A 101, 062310 (2020). [26] F. Pedregosa, G. Varoquaux, A. Gramfort,
[11] C. Bravo-Prieto, R. LaRose, M. Cerezo, Y. Subasi, V. Michel, B. Thirion, O. Grisel, M. Blondel,
L. Cincio, and P. J. Coles, arXiv:1909.05820 (2019). P. Prettenhofer, R. Weiss, V. Dubourg, J. Van-
[12] C. Cirstoiu, Z. Holmes, J. Iosue, L. Cincio, P. J. derplas, A. Passos, D. Cournapeau, M. Brucher,
Coles, and A. Sornborger, npj Quantum Informa- M. Perrot, and E. Duchesnay, Journal of Machine
tion 6, 1 (2020). Learning Research 12, 2825 (2011).
[13] J. Carolan, M. Mohseni, J. Olson, M. Prabhu, [27] https://github.com/Quantum-TII/qibo/tree/
C. Chen, D. Bunandar, Y. Niu, N. Harris, F. Wong, master/examples/EF_QAE.
M. Hochberg, S. Lloyd, and D. Englund, Nature [28] K. Sharma, S. Khatri, M. Cerezo, and P. Coles,
Physics 95, 1 (2020). New Journal of Physics 22, 043006 (2020).
[14] S. McArdle, T. Jones, S. Endo, Y. Li, S. C. Ben-
jamin, and X. Yuan, npj Quantum Information 5,
1 (2019).
[15] S. Endo, J. Sun, Y. Li, S. C. Benjamin, and
X. Yuan, Physical Review Letters 125, 010501 Appendix A: Resilience to noise
(2020).
[16] S. Lloyd, M. Schuld, A. Ijaz, J. Izaac, and N. Kil-
It has been shown recently that specific VQAs can
loran, arXiv:2001.03622 (2020).
[17] R. LaRose and B. Coyle, Physical Review A 102, exhibit noise resilience [28]. That is, the optimal
032420 (2020). parameters are unaffected by certain noise models.
Here we prove that the local cost function C is re-
silient to global depolarizing noise. Let us rewrite C

6
from Eq. 1 as From this expression, we see that
n
t
1X nt
!
C= (1 − ζ (k) ) , (A1) X
2 arg min C̃ = arg max ζ (k) . (A3)
k=1 θ θ
k=1

where ζ (k) = h0|U † (Zk ⊗ 11k )U |0i. From now on, we


It is clear as well that
refer to C̃ and ζ̃ as the noisy versions of these quanti-
ties. Recall that global depolarizing noise transforms nt
!
the state according to ρ → qρ+(1−q)11/d. If we con- arg min C = arg max
X
ζ (k)
. (A4)
sider a circuit that has depth D, then the final state θ θ
k=1
is q D ρ + (1 − q D )11/d. Notice as well that ζ̃ (k) is esti-
mated simply by executing the circuit in Fig. 3 and
Hence we arrive at
measuring in the computational basis. The maxi-
mally mixed state has zero expectation value, since
we measure Pauli Z operators. Therefore, we ob- arg min C̃ = arg min C . (A5)
θ θ
tain that ζ̃ (k) = q D ζ (k) , where D is the depth of the
circuit used to estimate ζ (k) . This implies
This proves our statement of global depolarizing
1
nt
X noise resilience, since it shows that the optimal pa-
C̃ = (1 − q D ζ (k) ) . (A2) rameters are unaffected.
2
k=1

You might also like