Quantum Autoencoders With Enhanced Data Encoding
Quantum Autoencoders With Enhanced Data Encoding
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 .
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.
4
100 QAE
EF-QAE
EF-QAE*
Cost function
10−1
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
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