# Automatic design of quantum feature maps

Sergio Altares-López 1, Angela Ribeiro 1, Juan José García-Ripoll 2 1 Centre
for Automation and Robotics - CAR (CSIC-UPM), Ctra. Campo Real km. 0,200,
28500 Arganda, Spain.  2 Instituto de Física Fundamental IFF-CSIC, Calle
Serrano 113b, 28006 Madrid, Spain<EMAIL_ADDRESS>
###### Abstract

We propose a new technique for the automatic generation of optimal ad-hoc
ansätze for classification by using quantum support vector machine (QSVM).
This efficient method is based on NSGA-II multiobjective genetic algorithms
which allow both maximize the accuracy and minimize the ansatz size. It is
demonstrated the validity of the technique by a practical example with a non-
linear dataset, interpreting the resulting circuit and its outputs. We also
show other application fields of the technique that reinforce the validity of
the method, and a comparison with classical classifiers in order to understand
the advantages of using quantum machine learning.

quantum machine learning, genetic algorithms, artificial intelligence, quantum
computing, optimization, automatic quantum classifier generation

##  1 Introduction

Quantum machine learning is an emerging field of research that bridges the
progress in quantum computing hardware and algorithms with ideas and problems
coming from artificial intelligence. The field is suffering steady and fast
progress but already features a large corpus of algorithms and applications
[1, 2]. On the one hand, we find applications, such as clustering [3], quantum
anomaly detection [4], dimensionality reduction [5, 6, 7] or support vector
machines [8], which build on the HHL algorithm for matrix inversions or
related matrix-vector operations. On the other hand, we place algorithms that
are ready for near-term intermediate-scale quantum (NISQ) devices, and which
are typically based on parameterized quantum circuits [9] that implement
autoencoders [10], support vector machines and quantum classifiers [11, 12],
or generative adversarial networks [13, 14], among other applications.

Due to their simplicity and immediate experimental access, this second
framework has gained considerable interest. However, a key problem of
parameterized circuit is their design, both from the point of view of the
structure of the circuit as well as their parameterization. The structure and
design condition the expressive power of the circuit [15, 16], and its
capacity to explore the Hilbert space and encode probability distributions
more efficiently than other generative models. However, too expressive
circuits can be subject to local minima and barren plateaus [17] that prevent
reaching the optimal parameterizations. Partial solutions to these challenges
include adaptive initialization strategies [18], pruning of circuits [19],
simultaneous optimization of parameters and rotation generators [20], or the
implementation of global optimization strategies such as genetic algorithms
[21, 22, 23] that optimize gates or structure.

In this work, we focus on the problem of supervised learning using quantum
feature maps [11, 12] that are optimized with a genetic algorithm. As compared
to earlier variational works [23], we provide a comprehensive solution that
automatically designs both the structure and the parameterization of the
feature map circuit. Our algorithm uses an NSGA-II genetic algorithm with a
multiobjective Pareto front that optimizes the accuracy and generalization
power of the map, while minimizing the circuit size. We test this method
against both synthetic and realistic benchmarks, finding remarkable accuracy
for all problems. Moreover, the Pareto strategy and our weighting of gates
seems to produce quantum feature maps that are largely uncorrelated. This
hints at the possibility of constructing hybrid quantum-inspired strategies
for machine learning based on these ideas.

The structure of this work is as follows. In section 2 we review the method of
quantum feature maps and quantum kernels for supervised learning with support
vector machines. We introduce a new function (6) that seems to exhibit good
separation properties and will be used in simulations. With this knowledge,
section 3 introduces the algorithm for genetically designed quantum kernels.
After a brief review of genetic algorithms in section 3.1, we introduce an
encoding of quantum feature maps as binary strings of genes. The genetic map
from section 3.2.1 is a small example with only 5 bits, but exemplifies how to
encode structure, types of gates, dependence on the input parameters and
numerical parameterization of the circuit. This contrasts with other works
[23] where structure and parameters were optimized separately, with different
methods. In section 3.2.2 we describe the fitness function, which is designed
for a multiobjective optimization of the accuracy, the capacity for
generalization and the simplicity of the quantum feature map. We also describe
how a Pareto search and elitist genetic operations can be designed to help in
this optimization. Section 4 presents the results of applying our algorithm to
synthetic and realistic benchmarks, in sections 4.1 and 4.3, respectively. In
these examples we also see how the optimization converges to low-entanglement
feature maps, while still having good accuracy and generalization. Based on
this, in section 4.2 we discuss how such circuits could be amenable for
interpretation. Finally, section 5 summarizes the main conclusions and
possible avenues for future exploration.

##  2 Quantum Kernel Method

In this work we will focus on the supervised training of binary classifiers.
Given a training dataset $\\{(\mathbf{x}_{i},y_{i})\\}_{i=1}^{L}$ with
normalized feature vectors $\mathbf{x}_{i}\in\mathbb{R}^{d}$ and binary
classes $y_{i}\in\\{+1,-1\\},$ we can design a model $f(\mathbf{x})$ that
predicts the class of any other point, either in this set or in unseen data.
The support vector machine (SVM) is one of the earliest binary classification
techniques. Developed for linearly separable data, this method constructs a
hyperplane with normal $\mathbf{w}$ and displacement $b$ such that the two
classes $y=+1$ and $y=-1$ lay on opposite sides of the hyperplane. The
classifier has a simple form, given by a sign function

$f(\mathbf{x})=\mathrm{sign}\left(\mathbf{w}^{T}\cdot\mathbf{x}+b\right).$ (1)

The hyperplane is constructed using support vectors from the training set

$\mathbf{w}=\sum_{i}\beta_{i}y_{i}\mathbf{x}_{i}\,,$ (2)

in a way that maximizes the margin between those vectors and the hyperplane.

There are various techniques that turn SVM into a universal classifier,
working data that is not linearly separable. One is to construct additional
features or variables out the original vectors, enlarging the dimension of the
classification space
$\tilde{\mathbf{x}}_{i}:=\bm{\Phi}(\mathbf{x}_{i})\in\mathbf{R}^{r},$ with
$r\gg d.$ By raising the dimensionality, the so called feature map can
transform the problem into a linearly separable one. Interestingly, the
classifier can be inferred from a kernel function that encodes the scalar
product between the new features

$K(\mathbf{x},\mathbf{x}^{\prime})=\bm{\Phi}(\mathbf{x})^{T}\bm{\Phi}(\mathbf{x}^{\prime}).$
(3)

This can be seen from the expression of the hyperplane $\mathbf{w}$ in terms
of the new features, and how this all fits into the final classifier

$\displaystyle f(x)$ $\displaystyle=$
$\displaystyle\left(\sum_{i}\beta_{i}y_{i}\bm{\Phi}(\mathbf{x}_{i})\right)^{T}\bm{\Phi}(\mathbf{x})+b=\sum_{i}\beta_{i}y_{i}\bm{\Phi}(\mathbf{x}_{i})^{T}\bm{\Phi}(\mathbf{x})+b$
$\displaystyle=$
$\displaystyle\sum_{i}\beta_{i}y_{i}K(\mathbf{x}_{i},\mathbf{x})+b.$

Moreover, by Mercer’s theorem [24], we do not need to know the form of the
feature map—which may even be an infinite-dimensional function—, but just a
kernel function $K(\mathbf{x},\mathbf{x}^{\prime})$ that has the right
positivity properties to encode a scalar product.

When developing quantum classifiers for classical data, the usual approach is
to engineer a feature map from classical to quantum features
$\ket{\Phi(\mathbf{x})}$ [11, 12]. This map can be trivial—e.g. encoding data
into quantum register states or quantum amplitudes—, but more generally it is
a parameterized unitary transformation, built from quantum gates that are
depend on the input features
$\ket{\Phi(\mathbf{x})}:=\mathcal{U}(\mathbf{x};\bm{\theta})\ket{0}^{n},$ and
on some additional controls $\bm{\theta}.$ The feature map can be combined
with further classification circuits or measurements, to create the so called
quantum neural networks. However, as argued in Refs. [11, 12, 25], we could
simply use those circuits to evaluate a kernel

$K(\mathbf{x},\mathbf{x}^{\prime})=\left|\braket{\Phi(\mathbf{x})}{\Phi(\mathbf{x}^{\prime})}\right|^{2}=\left|\braket{0^{n}}{\mathcal{U}(\mathbf{x};\bm{\theta})^{\dagger}\mathcal{U}(\mathbf{x}^{\prime};\bm{\theta})}{0^{n}}\right|^{2},$
(5)

and derive the corresponding SVM classifier $f(\mathbf{x};\bm{\theta}).$

In this work we use a different type of quantum kernel

$K(\mathbf{x},\mathbf{x}^{\prime})=\mathrm{Re}\braket{\Phi(\mathbf{x})}{\Phi(\mathbf{x}^{\prime})}=\mathrm{Re}\braket{0^{n}}{\mathcal{U}(\mathbf{x};\bm{\theta})^{\dagger}\mathcal{U}(\mathbf{x}^{\prime};\bm{\theta})}{0^{n}}.$
(6)

By not squaring the scalar product between vectors, the function resembles
more the original motivation for $K(\mathbf{x},\mathbf{x}^{\prime}).$
Moreover, as we have confirmed numerically, this kernel allows for sharper
separations and more easy convergence of the optimizer. However, while this
choice is neutral from a classical simulation point of view, it is more
complicated to evaluate in a quantum computer. Unlike Ref. [12], to estimate
$K(\mathbf{x},\mathbf{x}^{\prime})$ we would need to use an ancillary qubit,
prepared in a quantum superposition, and controlling the $\mathcal{U}$
operation, to estimate the scalar product as the result of an interference
process.

This quantum kernel method is usually combined with some kind of iterative
update of the parameters $\bm{\theta},$ to maximize a cost function that
includes the accuracy of the model and some other regularizations. Depending
on the expressive power of the underlying feature map, this approach can lead
to barren plateaus and other obstacles that prevent a good training. For that
reason, in this work we explore a global optimization method that trains both
the parameters $\bm{\theta}$ _as well as the structure_ of the quantum circuit
$\mathcal{U},$ by using evolutionary artificial intelligence techniques, also
known as genetic algorithms.

##  3 Genetically Designed Quantum Kernels

Figure 1: Technique scheme. a). The initial population is initialized. b). We
can see the decoding process based on five bits per quantum gate and angle.
c). This individual is used in the fitness function as feature map for QSVM in
order to calculate accuracy and number of gates. d). The genetic algorithm
process continue with phases already seen until early stopping condition so
that the most optimized ansatz for this dataset is provided.

###  3.1 Overview of Genetic Algorithms

Genetic algorithms are meta-heuristic optimization techniques based on the
theory of evolution. The algorithms perform a guided search in a space of
solutions, evolving a population of individuals with encoded the feature maps,
through the application of genetic operations. In each algorithm iteration or
generation, the resulting offspring is selected in order to improve one or
more objetives. As a result of evolutionary pressure, the collective is more
likely to select the best suited individuals from a very large configuration
space, in a efficient way.

A very important ingredient in the genetic algorithm is the fitness function.
This function depends on some metric that we wish to maximize (or minimize),
as well as other regularizations. However, as we show in this work, it is
possible for a genetic algorithm to achieve more than one goal, performing a
multiobjective optimization process. In this case, the individuals in each
generation that maximize (or minimize) the fitness function are called the
Pareto front. More precisely, a solution $x$ is called dominated by another
solution $y$ only if $y$ is equal or better than $x$ solution with respect to
all the objectives of the function. The Pareto front is the set of non-
dominated solutions which satisfy all objectives defined in the fitness
function, and which is progressively improved by the evolution algorithm.

A key ingredient for the success and utility of a genetic algorithm is the
choice of genetic operations that evolve the population of individuals, as
seen in figure 1d. The selection operator chooses a subset of the existing
population to create a new generation using the crossover and mutation
operators. The mutation operator randomly alters the information of selected
individuals to explore places far from the solution space. The crossover is an
stochastic operation that allows even more drastic explorations, by allowing
two individuals to exchange their genetic information. Note that, while the
probability of selection is proportional to the fitness of the individuals,
the mutation and crossover probabilities are fixed values that have been tuned
for performance.

Finally, the genetic algorithm typically involves some stopping early
conditions, statements which determine whether the evolution process has
achieved its goal. Some possible strategies are checking the convergence or
saturation of the fitness objetive, a minimum accuracy threshold that keeps
the process going for further steps or defining a maximum number of
generations.

###  3.2 Genetic quantum feature map

We will now describe a multiobjective genetic algorithm that automatically
designs and optimizes quantum classifiers based on quantum feature maps and
support vector machines. The algorithm explores a configuration space of
parameterized quantum circuits that potentially represent feature maps. It
looks for those circuits that, once trained in a QSVM method, maximize the
accuracy with which they generalize to the validation data set, while
minimizing the complexity of the circuit, which is measured in terms of
circuit depth and difficulty of operations.

The complete algorithm is summarized in figure 1. The process starts with an
initial population of individuals, represented by bit strings of size $M\times
N\times 5$. The evaluation function decodes each individual, creating an
associated quantum circuit (see section 3.2.1). This circuit, together with
the training dataset, is used to implement a quantum kernel SVM algorithm,
computing the fitness function (see section 3.2.2). The best individuals have
more probability to be elected and subjected to the different genetic
operations, such as mutation, crossover and selection, creating a new
generation of individuals or quantum circuits. The whole process is repeated
until we meet the convergence criteria.

####  3.2.1 Encoding

The first step for engineering our algorithm is to design a map from the
genetic information to the quantum circuit that we wish to characterize. In
our model, the genes will be binary strings that encode local, entangling and
parameterized quantum gates. To create a minimalistic encoding that
exemplifies all types of gates, we use five bits per gene
$s_{0}s_{1}s_{2}s_{3}s_{4},$ as shown in figure 1b. We aim to create a quantum
circuit acting on $M$ qubits with a maximum of $N$ layers and use $M\times
N\times 5$ bits in total. For simplicity, the order of actuation of the genes
is sequential. Thus the $i$-th gene operates on the $j$-th qubit of the
quantum register and possibly depends on the $k$-th a variable from the input
data $\mathbf{x}\in\mathbb{R}^{d}$, with $j=i\mbox{ mod }M$ and $k=i\mbox{ mod
}d.$

The mapping from bits to gates is also very straightforward. The first three
bits $s_{0}s_{1}s_{2}$ determine whether the gate is fixed—a Hadamard or a
CNOT gate—, or whether it is a local rotation parameterized by a value in the
input data,
$R_{\alpha}(\theta_{i}x_{k})=\exp(-i\theta_{i}x_{k}\sigma^{\alpha}_{k}).$ When
the gate is parameterized, the first bits $s_{0}s_{1}s_{2}$ select the
rotation axis, the last two bits select a proportionality parameter
$\theta_{i}=\frac{\pi}{4}2^{-2^{s_{3}}-4^{s_{4}}}.$ When the gate is a CNOT,
it acts on consequitive qubits, $j$ and $j+1\mbox{ mod }M.$ All other
combinations of bits not reflected in figure 1b are taken to be just identity
operations.

This gates selection has been chosen in such a way that all the elements found
in variational circuits used as feature maps are represented, being local
parameterized, non-parameterized and entanglement gates.

####  3.2.2 Fitness Function

Our fitness function is designed to maximize the accuracy and minimize the
complexity of the variational circuit. To measure the latter, we introduce a
size metric, labeled SM, which assigns different costs to the number of local
gates $N_{\mathrm{local}}$ and the number of entangling gates
$N_{\mathrm{CNOT}}$, weighted as follows

$\mathrm{SizeMetric(SM)}=\frac{N_{\mathrm{local}}+2N_{\mathrm{CNOT}}}{N_{\mathrm{qubits}}}.$
(7)

The second ingredient in the fitness function is the accuracy of the encoded
circuit. To compute this metric, we divide the data into a training set and a
test set. We use the quantum circuit and the training set to compute the
classifier $f(\mathbf{x})$ in the quantum kernel SVM. We then estimate the
accuracy of the model $f(\mathbf{x})$ over the test set, as the fraction of
points that are properly classified.

We aim to maximize both quantities in a multiobjective optimization process,
creating a Pareto front that carefully balances the relative importance of
both figures of merit. A high weight in accuracy can produce a collapse into
one individual loosing the necessary genetic diversity to be able to minimize
the quantum circuit size along the evolution. On the other hand, a very small
number of gates can hinder the power of the quantum kernel to separate the
features. In order to achieve a proper balance, we engineer a fitness function
that increases the relevance of the SM as the accuracy approaches its limiting
value 1, using the following multiobjective fitness function

$\mathrm{WeightsControl(W_{C})}=\mathrm{SM}+\mathrm{SM}*\mathrm{accuracy}^{2}.$
(8)

####  3.2.3 Genetic Operators

In the genetic algorithm we use selection, mutation and crossover operators.
The selection operator is a multiobjetive Non-Sorted Genetic Algorithm II
(NSGA-II). This algorithm decides which individuals survive to the next
generation based on Pareto-dominance and density-based metrics [26]. This
algorithm has a strong tendency to keep individuals with higher fitness,
because it selects the individuals after ordering the population by dominance.
However, it also uses the non-dominated individuals’ rank and density-distance
to add diversity in each generation.

Figure 2: Genetic operators. (a) Genetic algorithm $\mu+\lambda$ strategy. The
initial population $\mu$, after applying the genetic operators, produces an
offspring of $\lambda$ size. This offspring competes with the parents and from
this competition a number of individuals equal to the size of the individual
population $\mu$ is selected. This process is repeated throughout the
generations of evolution. (b) Mutation. A bit flip mutation affects a fraction
of the genes , giving rise to a different individual. (c) Crossover. Randomly
selected genes (marked in green) are exchanged between two individuals,
keeping the rest of the genes chain constant.

Since our feature maps are coded in binary format, we can use a bit flip
mutation operator (c.f. figure 2b). The value $p_{\mathrm{mut}}$ indicates the
probability of an individual to be mutated. Once an individual is selected for
mutation, each gene can be flipped with a probability $p_{\mathrm{ind}}.$ As
for the crossover operator, we implement a binary swap of contiguous bit
substrings (see figure 2c). The value $p_{\mathrm{cross}}$ determines
probability that a crossover takes place, while the beginning and end of the
swapped bits are randomly chosen along the complete strings.

We increase the elitism of the algorithm with a Mu Plus Lambda ($\mu+\lambda$)
algorithm. This strategy modifies how we create the next generation of
individuals, establishing a competition between the current population (size
$\mu$) and the offspring ($\lambda$) that is obtained by genetic operators, as
sketched in figure 2a. This competition ensures genetic diversity while it
also preserves the best individuals that have been obtained through the
evolutionary algorithm [27].

All hyperparameters previously mentioned —crossover and mutation probabilities
and population sizes—were optimized and tested, to achieve a good compromise
between convergence speed and optimal classification. After several tests, the
optimal hyperparameters were found to be 30% probability of crossover and 70%
mutation, with a 20% probability of bits being mutated. This is an interesting
balance that allows exploring drastic changes in the population through
crossover, while maintaining a high rate of small changes through mutation.
While this may seem very aggressive, the random component is kept in check by
the high elitism of the competition between children and parents in the Mu
Plus Lambda strategy.

##  4 Results and Discussion

###  4.1 Toy model

a) b) Variables Value Generations 5000 Population ($\mu$) 100 Offspring
($\lambda$) 15 Qubits 6 Max. Layers 6 Crossover Prob. 0.3 Mutation Prob. 0.7
Mutation Prob. Ind. 0.2
c) d)

Figure 3: (a) Dataset composed by 150 points with a non-linear pattern and a
binary target. (b) Hyperparameters used to optimize the QSVM circuit with our
genetic algorithm. (c) Structure of circuits created in the first generations
of the genetic algorithm. (d) Final circuit with 1.0 accuracy.

In order to proof this new method, we use the Moons synthetic non-linear
dataset with two classes, shown in figure 3a, and generated using Scikit [28].
The 150 datapoints are scaled between [-1,+1] as a preprocessing step, and
randomly split into a training (70%) and test (30%) sets. These sets are used
to train quantum circuits with up to 6 qubits and 6 layers, which are
progressively optimized by the genetic algorithm. As illustrated in figure 3b,
we optimize the circuits over 5000 generations, using a population of 100
individuals.

The initial circuits make use of all available qubits and all layers, as shown
in figure 3c. Already in these circuits we observe the penalty associated to
CNOT gates decreasing the number of entangling unitaries, as compared to other
ansätze in the literature. More interestingly, the Pareto front combined with
the elitist strategies is capable of further realizing that no entanglement at
all is required to fit this model. Thus, after 5000 generations, the algorithm
produces the simple uncorrelated circuit from figure 3d, which fits the test
set with perfect accuracy.

a) b)

Figure 4: (a) Validation dataset, together with the predictions and decision
boundary from the generated model. (b) Confusion matrix produced by the
application of the QSVM model onto the validation dataset.

The fact that the generated model has perfect accuracy is useless, if it
cannot generalize to other data from the same distribution. We validate the
utility of the model using additional datapoints, a validation set, with 500
points generated by the same synthetic algorithm. The same scaling
preprocessing step [-1,+1] that is applied to the training data is also
applied to these validation datapoints. Figure 4a shows both the validation
dataset used and the predictions made by the quantum support vectorial,
defined by the decision boundary. Figure 4b also illustrates the confusion
matrix of this validation process, considering both real and predicted labels,
and identifying the incorrectly classified data. The confusion matrix allows
us to conclude that the QSVM extrapolates to unseen data with same
distribution, because 473 out of 500 data in the dataset have been correctly
classified. In other words, a 94.6% of correct classified data or 0.946
accuracy.

###  4.2 Interpretability

Figure 5:  (a) Data points and prediction boundaries from the full quantum
kernel SVM. (b), (c) and (d) are the decision boundaries provided by the
circuits on the first, second and third qubit, respectively.

As we see above and will see in later examples, the strong penalty on
entangling gates makes the genetic algorithm prefer circuits that have smaller
clusters of uncorrelated qubits. Ideally, only the gates that are essential
for the modelization are included. The result is a circuit that can be
decomposed as a tensor product of separate unitaries, and a quantum kernel
that is a scalar product of separate kernels, as in
$K(\mathbf{x},\mathbf{x}^{\prime})=\prod_{i=1}^{m}K_{i}(\mathbf{x},\mathbf{x}^{\prime}).$
We suggest to study the classification induced by each kernel $K_{i}$
separately and by their combination, as a strategy to provide interpretations
of the rules that the evolutionary strategy has produced.

An example of this study is performed in figure 5 for our synthetic model.
Figure 5a illustrates the boundaries of the complete kernel, which has
accuracy 1.0, while later figures 5b-d show the boundaries induced by each
separate kernel. As we can see, both qubits one and two, provide linear
hyperplanes, being qubit three the one that provides a degree of non-linearity
achieved by applying three rotations. Finally, the combination of these qubits
forms the desired non-linear pattern. Interestingly, the single-qubit
boundaries have a lower classification accuracy, of 0.57, 0.68 and 0.53,
respectively, but their nonlinear combination in the final kernel gives the
right predictions.

###  4.3 Other Use cases

Table 1: Results from applying the genetic engineering of QSVM to other model problems in supervised machine learning. For the most difficult model we also provide the accuracy of other classical methods for supervised machine learning: a k-NN, a linear support vector machine, and an SVM with a polynomial kernel with degree 2 (poly). | Parkinson [29] | IoT irrigation [30] | Drug classification [31]
---|---|---|---
Circuit | Fig. 6a | Fig. 6c | Fig. 6b
Accuracy | 1.0 | 1.0 | 1.0
Generations | 5000 | 1000 | 500
# attributes | 22 | 2 | 5
# classes | 2 | 2 | 5
Max qubits | 15 | 5 | 5
Max depth | 8 | 5 | 5
Mutation probability ($p_{\mathrm{mut}}$) | 0.7 | 0.7 | 0.7
Mutation ind. prob. ($p_{\mathrm{ind}}$) | 0.2 | 0.2 | 0.2
Crossover prob. ($p_{\mathrm{cross}}$) | 0.3 | 0.3 | 0.3
k-NN accuracy | 0.82 | 1.0 | 0.70
SVM (linear) accuracy | 0.89 | 1.0 | 0.87
SVM (poly - 2) accuracy | 0.89 | 1.0 | 0.65

a)
b)
c)

Figure 6: Circuits generated for the supervised learning problems in Table 1.
(a) Parkinson problem [29], (b) drug classification [31] and (c) IoT
irrigation [30].

We have applied the method to other problems that are standard benchmarks for
classical supervised learning techniques. Table 1 lists three problems, with
the characteristics of the datasets, the hyperparameters of the genetic
algorithm and the resulting accuracy. As seen in our experiments, the
technique performs well for datasets with a high number of features as well as
for datasets with more than two classes. The comparison with non-quantum
classification methods also shows and advantage of the QSVM technique,
specially in the highly complex multiclass classification of drugs.

Figure 6 illustrates the structure and parameterization of the quantum feature
maps that optimally classify these benchmarks. Interestingly, two of the
circuits are uncorrelated and have no CNOT gates, while the third one, for
multiclass drug classification, has just one entangler gate. This is relevant
for several reasons. First, it illustrates the power of individual qubits a
quantum classifiers, a realization already introduced in Ref. [32]. Second,
the structures we have obtained, having little or no correlation, admit an
efficient classical simulation which constitutes in itself a type of quantum-
inspired machine-learning technique.

##  5 Summary and Outlook

In this work we have explored the global optimization of quantum feature maps
in a quantum kernel SVM algorithm using evolutionary multiobjective
algorithms. The feature map is built as a parameterized quantum circuit that
depends on the input data. The genetic algorithm stored the structure of the
circuit, the actual gates and the functional dependence on the data as a
string of binary-encoded genes. The algorithm evolves a population of
individuals with genetic operators that seek to maximize the accuracy of these
feature maps in modeling the data, while minimizing the complexity of the
circuit. This is implemented using a nonlinear fitness function that combines
both goals, and simultaneously applying a Pareto front selection strategy for
the individuals.

We have applied this algorithm both to synthetic and to realistic benchmarks
in the field of supervised machine learning, both single- and multiclass
classification. The algorithm produces 100% accurate classifiers that can
still generalize to unseen data since this metric is obtained from test sets.
Moreover, the classifiers have a simple structure, with minimal or no
correlations, which still capture the underlying nonlinear patterns. We
attribute the simplicity of these circuits to the classification power of
single qubits and single-qubit operations [32], which is enhanced by the
combination of multiple parallel circuits. We believe that the resulting
circuits are amenable to further interpretation strategies, in a simpler way
than neural networks or other ML ansätze. Moreover, our results suggest the
power of product states as another quantum-inspired variational strategy for
supervised learning.

Our work leaves many avenues for exploration. The gene encoding that we have
implemented contains a minimalistic set of entangling, local and parameterized
gates, with sufficient precision for the problems we have explored. This can
be extended in various ways, such as enlarging the set of weights in the
parameterization, changing the order in which parameters appear in the
circuit, including also more local and entangling gates, including free
parameters $\theta_{i}$ that can be optimized using SPSA or other strategies,
etc. If we focus on entanglement-free ansätze, we also find a rich avenue to
explore the implementation of these models as standalone tools for machine
learning, or developing a more clear strategy for the interpretation of the
resulting classifiers—e.g. developing a kind of rule-based explanation of the
model.

The authors gratefully acknowledges the computer resources at Artemisa, funded
by the European Union ERDF and Comunitat Valenciana as well as the technical
support provided by the Instituto de Física Corpuscular, IFIC (CSIC-UV). This
work has been supported by Spanish project PGC2018-094792-B-100
(MCIU/AEI/FEDER, EU), CAM/FEDER Project No. S2018/TCS-4342 (QUITEMAD-CM), and
CSIC Platform PTI-001.

##  6 References

## References

  * [1] Biamonte J, Wittek P, Pancotti N, Rebentrost P, Wiebe N and Lloyd S 2017 Nature 549 195–202 URL https://doi.org/10.1038/nature23474
  * [2] Schuld M and Petruccione F 2018 Supervised Learning with Quantum Computers (Springer International Publishing) URL https://doi.org/10.1007/978-3-319-96424-9
  * [3] Kerenidis I, Landman J, Luongo A and Prakash A 2018 q-means: A quantum algorithm for unsupervised machine learning (Preprint 1812.03584)
  * [4] Liu N and Rebentrost P 2018 Physical Review A 97 URL https://doi.org/10.1103/physreva.97.042315
  * [5] Lloyd S, Mohseni M and Rebentrost P 2014 Nature Physics 10 631–633 URL https://doi.org/10.1038/nphys3029
  * [6] Cong I and Duan L 2016 New Journal of Physics 18 073011 URL https://doi.org/10.1088/1367-2630/18/7/073011
  * [7] Duan B, Yuan J, Xu J and Li D 2019 Physical Review A 99 URL https://doi.org/10.1103/physreva.99.032311
  * [8] Rebentrost P, Mohseni M and Lloyd S 2014 Physical Review Letters 113 URL https://doi.org/10.1103/physrevlett.113.130503
  * [9] Benedetti M, Lloyd E, Sack S and Fiorentini M 2019 Quantum Science and Technology 4 043001 URL https://doi.org/10.1088/2058-9565/ab4eb5
  * [10] Romero J, Olson J P and Aspuru-Guzik A 2017 Quantum Science and Technology 2 045001 URL https://doi.org/10.1088/2058-9565/aa8072
  * [11] Schuld M and Killoran N 2019 Physical Review Letters 122 URL https://doi.org/10.1103/physrevlett.122.040504
  * [12] Havlíček V, Córcoles A D, Temme K, Harrow A W, Kandala A, Chow J M and Gambetta J M 2019 Nature 567 209–212 URL https://doi.org/10.1038/s41586-019-0980-2
  * [13] Dallaire-Demers P L and Killoran N 2018 Physical Review A 98 URL https://doi.org/10.1103/physreva.98.012324
  * [14] Lloyd S and Weedbrook C 2018 Physical Review Letters 121 URL https://doi.org/10.1103/physrevlett.121.040502
  * [15] Du Y, Hsieh M H, Liu T and Tao D 2020 Physical Review Research 2 URL https://doi.org/10.1103/physrevresearch.2.033125
  * [16] Sim S, Johnson P D and Aspuru-Guzik A 2019 Advanced Quantum Technologies 2 1900070 URL https://doi.org/10.1002/qute.201900070
  * [17] McClean J R, Boixo S, Smelyanskiy V N, Babbush R and Neven H 2018 Nature Communications 9 URL https://doi.org/10.1038/s41467-018-07090-4
  * [18] Grant E, Wossnig L, Ostaszewski M and Benedetti M 2019 Quantum 3 214 ISSN 2521-327X URL https://doi.org/10.22331/q-2019-12-09-214
  * [19] Sim S, Romero J, Gonthier J F and Kunitsa A A 2021 Quantum Science and Technology 6 025019 URL https://doi.org/10.1088/2058-9565/abe107
  * [20] Ostaszewski M, Grant E and Benedetti M 2021 Quantum 5 391 URL https://doi.org/10.22331/q-2021-01-28-391
  * [21] Li R, Alvarez-Rodriguez U, Lamata L and Solano E 2017 Quantum Measurements and Quantum Metrology 4 1–7 ISSN 2299-114X URL http://dx.doi.org/10.1515/qmetro-2017-0001
  * [22] Lamata L, Alvarez-Rodriguez U, Martín-Guerrero J D, Sanz M and Solano E 2018 Quantum Science and Technology 4 014007 ISSN 2058-9565 URL http://dx.doi.org/10.1088/2058-9565/aae22b
  * [23] Chivilikhin D, Samarin A, Ulyantsev V, Iorsh I, Oganov A R and Kyriienko O 2020 Mog-vqe: Multiobjective genetic variational quantum eigensolver (Preprint 2007.04424)
  * [24] Géron A 2019 Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow: Concepts, tools, and techniques to build intelligent systems (O’Reilly Media)
  * [25] Schuld M 2021 Quantum machine learning models are kernel methods (Preprint 2101.11020)
  * [26] Barán B, Carballude A and Villagra M 2021 SN Computer Science 2 URL https://doi.org/10.1007/s42979-020-00398-3
  * [27] Gutiérrez Reina D, Tapia Córdoba A and Rodríguez Del Nozal A 2020 Algoritmos Genéticos con Python (ALFAOMEGA MARCOMBO)
  * [28] Thirion B, Varoquaux G, Gramfort A, Michel V, Grisel O, Louppe G and Nothman J scikit-datasets (generate samples of synthetic data sets). URL https://github.com/scikit-learn/scikit-learn
  * [29] Little M, McSharry P, Roberts S, Costello D and Moroz I 2007 BioMedical Engineering OnLine 2007 6–23
  * [30] Intelligent irrigation system (by using temperature and moisture data) URL https://www.kaggle.com/harshilpatel355/autoirrigationdata
  * [31] Drug classification dataset URL https://www.kaggle.com/prathamtripathi/drug-classification
  * [32] Pérez-Salinas A, López-Núñez D, García-Sáez A, Forn-Díaz P and Latorre J I 2021 One qubit as a universal approximant (Preprint 2102.04032)


# The style transformer with common knowledge optimization for image-text
retrieval

Wenrui Li, Zhengyu Ma, Jinqiao Shi, and Xiaopeng Fan This work was supported
in part by the National Key R&D Program of China (2021YFF0900500), and the
National Natural Science Foundation of China (NSFC) under grants U22B2035 and
62206141. (Corresponding author: Jinqiao Shi.)Wenrui Li and Xiaopeng Fan are
with the Department of Computer Science and Technology, Harbin Institute of
Technology, Harbin 150001, China (e-mail<EMAIL_ADDRESS>fxp@hit.edu.cn).Zhengyu Ma is with the Peng Cheng Laboratory, Shenzhen 518055,
China (e-mails: mazhy@pcl.ac.cn).Jinqiao Shi is with the School of Cyberspace
Security, Beijing University of Posts and Telecommunications, Beijing 100876,
China (e-mails: shijinqiao@bupt.edu.cn).

###### Abstract

Image-text retrieval which associates different modalities has drawn broad
attention due to its excellent research value and broad real-world
application. However, most of the existing methods haven’t taken the high-
level semantic relationships (“style embedding”) and common knowledge from
multi-modalities into full consideration. To this end, we introduce a novel
style transformer network with common knowledge optimization (CKSTN) for
image-text retrieval. The main module is the common knowledge adaptor (CKA)
with both the style embedding extractor (SEE) and the common knowledge
optimization (CKO) modules. Specifically, the SEE uses the sequential update
strategy to effectively connect the features of different stages in SEE. The
CKO module is introduced to dynamically capture the latent concepts of common
knowledge from different modalities. Besides, to get generalized temporal
common knowledge, we propose a sequential update strategy to effectively
integrate the features of different layers in SEE with previous common feature
units. CKSTN demonstrates the superiorities of the state-of-the-art methods in
image-text retrieval on MSCOCO and Flickr30K datasets. Moreover, CKSTN is
constructed based on the lightweight transformer which is more convenient and
practical for the application of real scenes, due to the better performance
and lower parameters.

###### Index Terms:

Image-text retrieval, transformer

##  I Introduction

Image-text retrieval [1]–[3] refers to the process of retrieving relevant
images and text from a database containing both modalities. It is an
interdisciplinary field that combines computer vision [4] and natural language
processing [5, 6] and has been extensively studied. Most previous methods pay
more attention to fine-grained alignment [7]–[9] instead of the high-level
semantic relationships. These methods not only lack the utilization of global
information but also suffer from a large number of parameters. Besides, most
of the current approaches [10]–[16] ignore the common knowledge among
different modalities, which is significantly important for understanding the
meaning of words in context and the feature representation ability of the
network.

We proposed a novel style transformer network with common knowledge
optimization (CKSTN) to tackle the above issues. To enhance the practicality
of the model for real-world applications, we incorporate a lightweight feed-
forward network instead the attention layer in transformer to reduce the
model’s parameters and computation costs. The style embedding extractor (SEE)
is proposed to better utilize the high-level semantic relationships, which
extract “style embedding” of feature maps row by row using the multi-layer
perceptron (MLP). The concatenation and shuffle operations [17] are utilized
to ensure the “style embedding” contains more global information and shares
different row features between feature maps. The style embedding extractor is
a recurrent architecture to extract the multi-level features by fusing low-
level and high-level semantic features effectively. The “style embedding” not
only contains the semantic concepts in high-level but also incorporates the
pixel-level alignment relationships in low-level features. As for the high-
level semantic information, we also employ common knowledge across modalities,
which can effectively improve the feature representation as well. In the end,
we propose the common knowledge optimization (CKO) module to dynamically
update the latent concepts of common knowledge from the “style embedding” of
different modalities, which can benefit the feature adjustment module. The
sequential update strategy in CKO is proposed to dynamically adjust the common
knowledge, which optimizes the feature representation among different
modalities based on the style embedding of different items. We summarize the
main contributions of this paper as follows:

1) We propose a novel style transformer network with common knowledge
optimization (CKSTN), which utilized the common knowledge dynamically adjusted
based on “style embeddings” to optimize the feature representations of two
modalities.

2) The SEE uses the concatenation and shuffle operation to share different row
features across feature maps, and MLP to get compacted efficient
representations. The CKA is proposed to capture the latent concepts of common
knowledge across different modalities.

3) The sequential update strategy is introduced to integrate the features of
different stages in SEE with previous common feature units, which helps to get
generalized temporal common knowledge.

Figure 1: Architecture of the CKSTN. The “C&S” represents concatenation and
shuffle operation. The SEE could extract the high-level semantic relationships
that represent global information effectively. The CKA could dynamically
capture the common latent concepts of different modalities. Finally, the
learnt common knowledge is utilized to further assist the formation of the
item feature representations.

##  II Approach

###  II-A Architecture

Feature extractor of image and text RAVLN uses Faster-RCNN [18] to extract
visual features and pre-trained BERT [5] to extract textual features following
[19] respectively. The information related to geometry bonding boxes is
integrated into visual features extracted from images using a fully connected
neural network. In pre-trained BERT, the standard transformer architecture
could use the self-attention mechanism to encode the memory connections
between words in sentences. Given the visual and textual features input
$\boldsymbol{\mathcal{X}}_{c}\in\mathbb{R}^{n\times d_{o}}$, $n$ and $d_{o}$
are the sequence length and dimension of $\boldsymbol{\mathcal{X}}_{c}$, and
$c\in(\boldsymbol{v},\boldsymbol{t})$. The outputs of the visual and textual
feature extractor can be written as:
$\boldsymbol{\mathcal{E}}_{v}=E_{vis}(\boldsymbol{\mathcal{X}}_{v})$ and
$\boldsymbol{\mathcal{E}}_{t}=E_{tex}(\boldsymbol{\mathcal{X}}_{t})$, where
$\boldsymbol{\mathcal{E}}_{v}\in\mathbb{R}^{n\times d_{in}}$ and
$\boldsymbol{\mathcal{E}}_{t}\in\mathbb{R}^{n\times d_{in}}$.

Inner-modal reasoning module. After the feature extractor, the inner-modal
semantic relationships are further explored using a stack of lightweight
transformers. A complete lightweight transformer layer in visual pipeline can
be written as:

$\displaystyle\boldsymbol{\mathcal{E}}_{v}^{a}$
$\displaystyle=\frac{(\boldsymbol{\mathcal{E}}_{v}\boldsymbol{T}_{Q}\cdot(\boldsymbol{\mathcal{E}}_{v}\boldsymbol{T}_{K})^{T})}{\sqrt{d_{e}}}\boldsymbol{\mathcal{E}}_{v}\boldsymbol{T}_{V},$
(1) $\displaystyle\boldsymbol{P}_{v}$
$\displaystyle=\mathrm{Add\&Norm}(\boldsymbol{\mathcal{E}}_{v}^{a},\boldsymbol{\mathcal{E}}_{v}),$
$\displaystyle\hat{\boldsymbol{\mathcal{E}}_{v}}$
$\displaystyle=\mathrm{Add\&Norm}(\mathrm{FFN}(\boldsymbol{P}_{v}),\boldsymbol{P}_{v}),$

where $\boldsymbol{T}_{(\cdot)}\in\mathbb{R}^{d_{in}\times d_{e}}$ denote the
learnable linear projections of query, key and value, $d_{e}$ represents the
dimension of the common space, $\mathrm{Add\&Norm}(\cdot)$ contains a layer
normalization operation and a residual connection, and $\mathrm{FFN}(\cdot)$
denotes the lightweight feed-forward network, which composed of two nonlinear
layers with GLUE activation function.

Common knowledge adapter. Rational use of high-level semantic information can
optimize feature representation. The SEE is proposed to encode the semantic
relationships of high-level features (“style embedding”). The outputs of
$i$-th layer of SEE is defined as:

$\displaystyle\boldsymbol{R}_{i}=\mathrm{C\&S}(\mathrm{CLIP}_{i}(\boldsymbol{\mathcal{E}}_{v}),\boldsymbol{M}_{i-1}),\boldsymbol{M}_{i}=\mathrm{MLP}(\boldsymbol{R}_{i}),$
(2)

where $\mathrm{CLIP}_{i}(\cdot):\mathbb{R}^{n\times
d_{e}}\rightarrow\mathbb{R}^{n\times(d_{e}/m)}$ represents the clip function
to cut and return the $i$-th row of the feature map, and $m$ is the number of
layers in SEE, The $\mathrm{C\&S}(\cdot,\cdot):(\mathbb{R}^{n\times
d_{m}},\mathbb{R}^{n\times
d_{m}})\rightarrow\mathbb{R}^{n\times(2*d_{m})},d_{m}=d_{e}/m$, denotes the
concatenation and shuffle operation, which could contain more global
information and share different row features between feature maps and
$\mathrm{MLP}(\cdot):\mathbb{R}^{n\times(2*d_{m})}\rightarrow\mathbb{R}^{n\times
d_{m}}$ is a multi-layer perceptron consists of 3-layer linear layers.

The common knowledge optimization (CKO) consists of a set of common feature
units
$\boldsymbol{S}=\\{\boldsymbol{S}_{1},\boldsymbol{S}_{2},\ldots,\boldsymbol{S}_{k}\\}$
which represents the common knowledge between two modalities. The illustration
of CKO is shown in Fig. 2. For each visual and textual input
$\boldsymbol{M}_{c}\in\mathbb{R}^{n\times d_{m}}$ and
$c\in(\boldsymbol{v},\boldsymbol{t})$ from the last layer of SEE. The CKO
could compute the importance of each common feature unit according to the
input vectors and effectively combine them together, which can be written as:

$\boldsymbol{S}_{o}=\sum_{i=1}^{k}\mathrm{Softmax}(\boldsymbol{S}_{i}\boldsymbol{M}_{c})\boldsymbol{M}_{c},$
(3)

where $\mathrm{Softmax}(x)=1/(1+e^{-x})$. The memory gate is proposed to
selectively remain and exclude the information of fused features. The memory
gate in visual pipeline is defined as follows:

$\boldsymbol{G}_{vis}=\mathrm{ReLU}(\boldsymbol{W}_{o}\boldsymbol{S}_{ovis}+b_{o}),$
(4)

where $\boldsymbol{W}_{o}\in\mathbb{R}^{n\times n}$ is learnable weight metric
and $b_{o}$ is the bias item. After the memory gate, the style embeddings are
integrated with the common knowledge reasonable.

In order to extract the effective common knowledge, we propose a sequential
update strategy to connect the features of different stages in SEE with
previous common feature units $\boldsymbol{S}_{t-1}\in\mathbb{R}^{n\times
d_{m}}$. The common feature units are updated as follows:

$\boldsymbol{S}_{t}=(\boldsymbol{G}_{vis}\boldsymbol{G}_{tex})\boldsymbol{S}_{t-1}+(1-\boldsymbol{G}_{vis}\boldsymbol{G}_{tex})\boldsymbol{S}_{ovis}\boldsymbol{S}_{otex}.$
(5)

Finally, the features reasoned by lightweight transformers will be globally
adjusted based on the style embeddings. The feature adjustment block in visual
pipeline is defined as:

$\boldsymbol{Y}_{vis}=\mathrm{Softmax}(\boldsymbol{W}_{g}\boldsymbol{G}_{vis})\boldsymbol{\hat{\mathcal{E}}}_{v},$
(6)

where $\boldsymbol{W}_{g}\in\mathbb{R}^{n\times n}$ is learnable weight metric
to fine-turning the outputs of the memory gate.

Figure 2: Architecture of the common knowledge optimization. The central red
lines represent the sequential update strategy of $\boldsymbol{s}_{t}$. Update
details could be found in Eq. (3-5). The extracted $\boldsymbol{s}_{t}$ is
fused with visual and textual style embedding to update and optimize the next
input of visual and textual features.

###  II-B Training strategy

We trained our model for 30 epochs on a single NVIDIA V100s GPU, the optimizer
we choose Adam. We perform the bottom-up visual features extracted as proposed
in [4], and mapped the features of two modalities into the dimension of
embedding space which is 1024 to explore their relationships using a
lightweight transformer and SEE module. To avoid overfitting, we utilized a
warm-up strategy with a learning rate ranging from $1e^{-5}$ to $1e^{-4}$ for
the first 10 epochs, which was then linearly decreased to $1e^{-5}$. We set
the number of layers in the style embedding layers to 4, and for triplet
ranking loss we used a hard negative margin of 0.2. To encourage the model to
learn more accurate feature representations and increase the distance between
mismatched pairs in the embedding space, the contrastive and matching loss is
conpute based on the visual features and textual features.

Contrastive loss. A batch containing $N$ pairs of images and sentences, the
intra-batch similarity between images and sentences can be defined as:

$\boldsymbol{\mathcal{L}}_{i2t}=-\frac{1}{N}\sum_{i=1}^{N}log\frac{exp((\boldsymbol{G}_{vis})_{i}^{T}(\boldsymbol{G}_{tex})_{i}/\tau)}{\sum_{N}^{j=1}exp((\boldsymbol{G}_{vis})_{i}^{T}(\boldsymbol{G}_{tex})_{i}/\tau)}.$
(7)

The definition of sentence-to-image similarity is shown as:

$\boldsymbol{\mathcal{L}}_{t2i}=-\frac{1}{N}\sum_{i=1}^{N}log\frac{exp((\boldsymbol{G}_{tex})_{i}^{T}(\boldsymbol{G}_{vis})_{i}/\tau)}{\sum_{N}^{j=1}exp((\boldsymbol{G}_{tex})_{i}^{T}(\boldsymbol{G}_{vis})_{j}/\tau)}.$
(8)

The contrastive loss is formulated as
$\boldsymbol{\mathcal{L}}_{con}=\boldsymbol{\mathcal{L}}_{i2t}+\boldsymbol{\mathcal{L}}_{t2i}$

Matching loss. We utilized a hinge-based triplet ranking loss [5] to calculate
the matching loss, which emphasizes on the hard negatives $l^{{}^{\prime}}$
and $k^{{}^{\prime}}$. The region-word similarity matrix
$\boldsymbol{C}\in\mathbb{R}^{dk\times dl}$ is obtained by computing the
cosine similarity between $\boldsymbol{Y}{vis}$ and $\boldsymbol{Y}{tex}$,
where $dk$ represents the set of indices of region features from the $k$-th
image and $dl$ represents the indices of the $l$-th sentence words. The
matching loss is defined as:

$\mathcal{L}_{kl}=\max_{l^{{}^{\prime}}}[\gamma+\boldsymbol{C}_{kl^{{}^{\prime}}}-\boldsymbol{C}_{kl}]_{+}+\max_{k^{{}^{\prime}}}[\gamma+\boldsymbol{C}_{k^{{}^{\prime}}l}-\boldsymbol{C}_{kl}]_{+},$
(9)

where is the margin parameter that minimum distance between negative pairs and
visual-textual embeddings of truly matched, and $[s]_{+}\equiv\max(s,0)$.

The total loss is formulated as
$\mathcal{L}_{all}=\mathcal{L}_{con}+\mathcal{L}_{kl}$.

TABLE I: Experiment results on two benchmark dataset. Models | MS-COCO Dataset | Flickr30K Dataset |
---|---|---|---
Image Retrieval | Sentence Retrieval | Rsum | Image Retrieval | Sentence Retrieval | Rsum | Venue
R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10
DREN [22] | 61.8 | 88.2 | 96.0 | 76.6 | 95.7 | 98.3 | 516.6 | 53.6 | 81.5 | 87.0 | 74.3 | 93.5 | 96.2 | 483.8 | TCSVT 22
SSAMT [23] | 62.7 | 89.6 | 95.3 | 78.2 | 95.6 | 98.0 | 519.4 | 54.8 | 81.5 | 88.0 | 75.4 | 92.6 | 96.4 | 488.7 | ICMR 22
CGMN [24] | 63.8 | 90.7 | 95.7 | 76.8 | 95.4 | 98.3 | 520.7 | 59.9 | 85.1 | 90.6 | 77.9 | 93.8 | 96.8 | 504.1 | TOMM 22
GraDual [25] | 63.7 | 90.8 | 95.6 | 76.8 | 95.9 | 98.3 | 521.1 | 57.7 | 83.1 | 90.5 | 76.1 | 93.7 | 96.7 | 497.8 | WACV 22
MACM [26] | 63.1 | 90.5 | 95.6 | 77.2 | 96.7 | 98.5 | 521.6 | 58.8 | 84.1 | 90.0 | 77.6 | 94.5 | 97.1 | 502.1 | IJCNN 22
DIME [27] | 63.0 | 90.5 | 96.2 | 77.9 | 95.9 | 98.3 | 521.8 | 60.1 | 85.5 | 91.8 | 77.4 | 95.0 | 97.4 | 507.2 | SIGIR 21
TERAN [28] | 65.0 | 91.2 | 96.4 | 77.7 | 95.9 | 98.6 | 524.8 | 59.5 | 84.9 | 90.6 | 75.8 | 93.2 | 96.7 | 500.7 | TOMM 21
LTAN [19] | 67.5 | 92.2 | 97.4 | 79.6 | 97.9 | 99.7 | 534.3 | 60.5 | 85.1 | 91.1 | 76.5 | 93.5 | 96.5 | 503.2 | ICASSP 22
CKSTN | 69.1 | 92.3 | 98.8 | 81.1 | 98.1 | 99.3 | 538.7 | 62.3 | 86.8 | 91.3 | 78.3 | 92.9 | 96.9 | 508.5 |
TABLE II: The methods comparison on Flickr30K dataset. Models | R@1 | R@5 | R@10 | Rsum |  #params | Venue
---|---|---|---|---|---|---
ViLBERT [29] | 58.2 | 84.9 | 91.5 | 234.6 | 275M | NeurIPS 19
TERAN [28] | 59.5 | 84.9 | 90.6 | 235.0 | 216M | TOMM 21
LTAN [19] | 60.5 | 85.1 | 91.1 | 236.7 | 181M | ICASSP 22
CKSTN | 62.3 | 86.8 | 91.3 | 240.4 | 175M |

##  III Experiment

###  III-A Results comparison

Our model is compared with the state-of-the-art baselines on Flick30K [20] and
MSCOCO [21] datasets. To unify the criteria, we only evaluate basic models
without ensemble. We utilize the recall at rank k (R@K) as the evaluation
metric to measure the retrieval performance of the compared methods. The TERAN
[28], ViLBERT [29], and LTAN [19] use the transformer to get the attention
map. The DIME [27] uses the “rectified identity cell” and “global-local
guidance cell” to extract the general knowledge which helps the interaction of
different modalities. However, the general knowledge extracted by DIME can’t
adjust dynamically. Our model uses transformer to extract the attention
relationships between different modalities and proposes the CKO module to
optimize feature formation dynamically.

Table 1 shows that our CKSTN achieves superior performance, outperforming most
of the baselines. For MSCOCO, CKSTN consistently outperforms the state-of-the-
art method DERN with a relative improvement of 11.8% and 5.9% on R@1 for image
retrieval and sentence retrieval, respectively. Moreover, our model improves
Rsum by 22.1. For Flickr30K, our method outperforms the state-of-the-art model
LTAN by 3.1% and 2.4% on R@1 for image retrieval and sentence retrieval,
respectively. Table 2 compares our model with transformer-based models,
indicating that our model achieves better performance with fewer parameters.
While ViLBERT has 275M parameters, our model has only 175M parameters.
Considering the practicality and efficiency requirements for real-world
applications, our approach is more feasible and convenient for deployment.

###  III-B Ablation study

The effectiveness of the CKO, SEE and matching loss. To demonstrate the
effectiveness of our proposed CKO and SEE for image-text retrieval, we compare
the model without the CKO and SEE on the left of Fig. 3, denote as “W/o common
knowledge optimization” and “standard” with 0 number of layers in SEE. As for
CKO, We find that “standard” obtains a significant improvement of 2.5% and
3.1% in R@1 for image and sentence retrieval respectively in 4 layers of SEE.
CKO can capture the latent concepts of common between different modalities,
which can better help the formation of feature representation. The model in 4
layers of SEE gets 5.2% relative gains on Rsum compared with the model without
SEE. It is worth mentioning that in the model without CKO, increasing the
number of layers in SEE instead improves the model performance, which is
inconsistent with the change of the model with CKO. With CKO, the global
information of the item is extracted from fewer SEE layers with common
knowledge for macro regulation. Without CKO, the more detailed style embedding
can better assist the feature representation.

The effects of different number of layers in style embedding extractor. We
designed the experiments to investigate the effect of the number of layers in
the SEE, by incrementally increasing the number of layers to 2, 4, 8, and 16.
The CKSTN model without any modification is denoted as ”standard” on the left
of Fig. 3. Our findings suggest that an increase in the number of layers can
improve retrieval accuracy, within a certain range, from 2 to 4 layers.
However, when the number of layers is further increased to 8, the model’s
representation ability starts to decrease.

The effects of contrastive loss. We fine-tune the final model by using the
contrastive loss in the CKA to measure the difference between the style
embeddings of visual features and textual features. As shown on the left of
Fig. 3, the results without contrastive loss are slightly lower than the
”standard” results, as expected.

Further analysis compared with LTAN. LTAN is also one of the latest state-of-
the-art papers using the lightweight transformer to compress the model
parameters. On the right of Fig. 3, the structure of LTAN would suffer the
“cliff effect” when the dimension of the intermediate layer is reduced.
However, adding our proposed CKO module, not only relieves the “cliff effect”,
but also optimizes the feature representation with the same dimensions in the
intermediate layer.

Figure 3: The ablation study on Flickr30K dataset. Figure 4: The visualization
comparison of region-word matching.

###  III-C Visualization of Region-Word Matching

In Fig. 4, we present the cosine similarity between every word and its
corresponding image region with the highest association. The affinity between
visual and textual features is measured by cosine similarity, just like in the
training phase. Without the CKO, the similarity of alignment relationships of
instance objects (e.g., boy, ball) will drop. See the red area in Fig. 4. The
article “a” modifies “boy”. However, without the common knowledge optimization
module, the article “a” makes mistakes of modifying “ball”. This also
indicates that common knowledge contains global information to optimize the
feature representation.

##  IV conclusion

The proposed style embedding module employs concatenation and shuffle
operations to share distinct row features across feature maps. To capture the
latent concepts of different modalities and dynamically adjust them based on
the style embeddings, we propose common knowledge optimization operation. The
experimental results validate the effectiveness of CKSTN, which outperforms
previous state-of-the-art methods on two benchmark datasets while having fewer
parameters than transformer-based methods.

## References

  * [1] M. Zhao, H. Zhang, and J. Sun, “A novel image retrieval method based on multi-trend structure descriptor,” _Journal of Visual Communication and Image Representation_ , 2016.
  * [2] F. Shang, H. Zhang, L. Zhu, and J. Sun, “Adversarial cross-modal retrieval based on dictionary learning,” _Neurocomputing_ , 2019.
  * [3] X. Xu, H. Lu, J. Song, Y. Yang, H. T. Shen, and X. Li, “Ternary adversarial networks with self-supervision for zero-shot cross-modal retrieval,” _IEEE Transactions on Cybernetics_ , 2020.
  * [4] P. Anderson, X. He, C. Buehler, D. Teney, M. Johnson, S. Gould, and L. Zhang, “Bottom-up and top-down attention for image captioning and visual question answering,” in _Proceedings of the IEEE conference on computer vision and pattern recognition_ , 2018.
  * [5] J. D. M.-W. C. Kenton and L. K. Toutanova, “Bert: Pre-training of deep bidirectional transformers for language understanding,” in _Proceedings of naacL-HLT_ , 2019.
  * [6] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, “Attention is all you need,” _Advances in neural information processing systems_ , vol. 30, 2017.
  * [7] J. Song, Y. Yang, Z. Huang, H. T. Shen, and R. Hong, “Multiple feature hashing for real-time large scale near-duplicate video retrieval,” in _Proceedings of the 19th ACM International Conference on Multimedia_ , 2011\.
  * [8] J. Song, Y. Yang, Z. Huang, H. T. Shen, and J. Luo, “Effective multiple feature hashing for large-scale near-duplicate video retrieval,” _IEEE Transactions on Multimedia_ , 2013.
  * [9] W. Li, Z. Ma, L.-J. Deng, X. Fan, and Y. Tian, “Neuron-based spiking transmission and reasoning network for robust image-text retrieval,” _IEEE Transactions on Circuits and Systems for Video Technology_ , 2022.
  * [10] K.-H. Lee, X. Chen, G. Hua, H. Hu, and X. He, “Stacked cross attention for image-text matching,” in _Proceedings of the European conference on computer vision_ , 2018.
  * [11] H. Chen, G. Ding, X. Liu, Z. Lin, J. Liu, and J. Han, “Imram: Iterative matching with recurrent attention memory for cross-modal image-text retrieval,” in _Proceedings of the IEEE/CVF conference on computer vision and pattern recognition_ , 2020.
  * [12] X. Xu, T. Wang, Y. Yang, L. Zuo, F. Shen, and H. T. Shen, “Cross-modal attention with semantic consistence for image–text matching,” _IEEE transactions on neural networks and learning systems_ , 2020.
  * [13] K.-H. Lee, X. Chen, G. Hua, H. Hu, and X. He, “Stacked cross attention for image-text matching,” in _Proceedings of the European conference on computer vision_ , 2018.
  * [14] H. Lan and P. Zhang, “Learning and integrating multi-level matching features for image-text retrieval,” _IEEE Signal Processing Letters_ , 2022.
  * [15] Y. Liu, H. Liu, H. Wang, and M. Liu, “Regularizing visual semantic embedding with contrastive learning for image-text matching,” _IEEE Signal Processing Letters_ , 2022.
  * [16] M. Zheng, W. Wang, and Q. Li, “Fine-grained image-text retrieval via discriminative latent space learning,” _IEEE Signal Processing Letters_ , 2021.
  * [17] S. Mehta, M. Ghazvininejad, S. Iyer, L. Zettlemoyer, and H. Hajishirzi, “Delight: Deep and light-weight transformer,” in _International Conference on Learning Representations_ , 2021.
  * [18] S. Ren, K. He, R. Girshick, and J. Sun, “Faster r-cnn: Towards real-time object detection with region proposal networks,” in _Advances in Neural Information Processing Systems_ , 2015.
  * [19] W. Li and X. Fan, “Image-text alignment and retrieval using light-weight transformer,” in _IEEE International Conference on Acoustics, Speech and Signal Processing_ , 2022.
  * [20] P. Young, A. Lai, M. Hodosh, and J. Hockenmaier, “From image descriptions to visual denotations: New similarity metrics for semantic inference over event descriptions,” in _Transactions of the Association for Computational Linguistics_ , 2014.
  * [21] T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick, “Microsoft coco: Common objects in context,” in _Proceedings of the European conference on computer vision_ , 2014.
  * [22] S. Yang, Q. Li, W. Li, X. Li, and A.-A. Liu, “Dual-level representation enhancement on characteristic and context for image-text retrieval,” _IEEE Transactions on Circuits and Systems for Video Technology_ , 2022.
  * [23] Z. Fan, Z. Wei, Z. Li, S. Wang, H. Shan, X. Huang, and J. Fan, “Constructing phrase-level semantic labels to form multi-grained supervision for image-text retrieval,” in _International Conference on Multimedia Retrieval_ , 2022\.
  * [24] Y. Cheng, X. Zhu, J. Qian, F. Wen, and P. Liu, “Cross-modal graph matching network for image-text retrieval,” _ACM Transactions on Multimedia Computing, Communications, and Applications_ , 2022.
  * [25] S. Long, S. C. Han, X. Wan, and J. Poon, “Gradual: Graph-based dual-modal representation for image-text matching,” in _Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision_ , 2022.
  * [26] H. Zhang, W. Wu, and M. Zhang, “Multi-attention cascade model based on multi-head structure for image-text retrieval,” in _2022 International Joint Conference on Neural Networks_ , 2022.
  * [27] L. Qu, M. Liu, J. Wu, Z. Gao, and L. Nie, “Dynamic modality interaction modeling for image-text retrieval,” in _Proceedings of the 44th International ACM SIGIR Conference on Research and Development in Information Retrieval_ , 2021.
  * [28] N. Messina, G. Amato, A. Esuli, F. Falchi, C. Gennaro, and S. Marchand-Maillet, “Fine-grained visual textual alignment for cross-modal retrieval using transformer encoders,” _ACM Transactions on Multimedia Computing, Communications, and Applications_ , 2021.
  * [29] J. Lu, D. Batra, D. Parikh, and S. Lee, “Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks,” in _Advances in Neural Information Processing Systems_ , H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, Eds., 2019.


# Probability distribution of classical observables

Pierre Nazé<EMAIL_ADDRESS>Universidade Estadual Paulista, 14800-090,
Araraquara, São Paulo, Brazil

###### Abstract

In this work, I derive the time-dependent probability density function of
classical observables using the Hamiltonian mechanics approach, extending the
notion of fluctuation theorems for any observables. In particular, the time-
dependent probability density function of the thermodynamic work evolving in
the switching time is solved as a special case. From such a relation, I prove
Jarzynski’s equality and Crook’s fluctuation theorem. The particular case of a
Gaussian distribution for slowly-varying processes is derived as well at the
end.

##  I Preliminaries

Consider a time-dependent driven Hamiltonian
$\mathcal{H}_{t}=\mathcal{H}(q_{t},p_{t};\lambda(t/\tau))$ with one degree of
freedom, such that a driving is performed during a switching time $\tau$
between the points $\lambda_{0}$ and $\lambda_{0}+\delta\lambda$.

##  II Time-dependent probability density function of observables

Consider an observable $\mathcal{O}(q_{0},p_{0})$ with one degree of freedom.
If the system is prepared in the phase space $\Gamma$ with a probability
density function $\rho(q_{0},p_{0})$ and is evolved in time, the observable
will have its own probability density function
$\rho_{\mathcal{O}_{t}}(\mathcal{O}_{t},t)=\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)$
at time $t$. At the same instant, the probability density associated will be
$\rho_{t}=\rho(q_{t},p_{t},t)$. Over the evolution in time, the normalization
property holds

$\int_{\Gamma_{\mathcal{O}_{t}}}\rho_{\mathcal{O}_{t}}(\mathcal{O}_{t},t)d\mathcal{O}_{t}=1,$
(1)

for all instants $t$. Consider now the probability measure
$\mu_{t}=\mu(q_{t},p_{t},t)$ associated with $\rho(q_{t},p_{t},t)$ in the
following way

$\mu_{t}(q_{t},p_{t},t)=\int_{-\infty}^{q_{t}}\int_{-\infty}^{p_{t}}\rho(q^{\prime}_{t},p^{\prime}_{t},t)dq^{\prime}_{t}dp^{\prime}_{t}.$
(2)

It holds the probability normalization

$\int_{\Gamma_{\mu_{t}}}d\mu_{t}=1,$ (3)

also for all instants $t$. To determine $\rho_{\mathcal{O}_{t}}$, I multiply
both normalizations presented before and made a change of variables
$(\mathcal{O}_{t},\mu_{t})\rightarrow(q_{t},p_{t})$. Therefore

$\int_{\Gamma}\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)\left|\frac{\partial\mathcal{O}_{t}}{\partial
q_{t}}\frac{\partial\mu_{t}}{\partial
p_{t}}-\frac{\partial\mathcal{O}_{t}}{\partial
p_{t}}\frac{\partial\mu_{t}}{\partial
q_{t}}\right|dq_{t}dp_{t}=\int_{\Gamma}\rho(q_{t},p_{t},t)dq_{t}dp_{t}.$ (4)

Equalling the integrands of the left and right sides of the equation, one has

$\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)=\frac{\rho(q_{t},p_{t},t)}{\left|\frac{\partial\mathcal{O}_{t}}{\partial
q_{t}}\frac{\partial\mu_{t}}{\partial
p_{t}}-\frac{\partial\mathcal{O}_{t}}{\partial
p_{t}}\frac{\partial\mu_{t}}{\partial q_{t}}\right|},$ (5)

or also

$\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)=\frac{\rho(q_{t},p_{t},t)}{\left|\\{\mathcal{O}_{t},\mu_{t}\\}_{t}\right|}.$
(6)

Observe that the observable probability density function per point
$\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)$ is positive. Also, since
$\rho(q_{t},p_{t},t)$ satisfy Liouville’s theorem, one has

$\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)=\frac{\rho_{\mathcal{O}_{0}}(\mathcal{O}(q_{0},p_{0}))\left|\\{\mathcal{O}_{0},\mu_{0}\\}_{0}\right|}{\left|\\{\mathcal{O}_{t},\mu_{t}\\}_{t}\right|}=\frac{\rho(q_{0},p_{0})}{\left|\\{\mathcal{O}_{t},\mu_{t}\\}_{t}\right|},$
(7)

and

$\frac{d\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t}),t)}{dt}=0,\quad\frac{d\left|\\{\mathcal{O}_{t},\mu_{t}\\}_{t}\right|}{dt}=0.$
(8)

Constructing the set
$\mathcal{E}_{\mathcal{O}_{t}}=\\{(q_{t},p_{t}),\mathcal{O}_{t}=\mathcal{O}(q_{t},p_{t},t)\\}$,
the observable probability density function $\rho_{\mathcal{O}_{t}}$ will be

$\rho_{\mathcal{O}_{t}}(\mathcal{O}_{t})=\sum_{(q_{t},p_{t})\in\mathcal{E}_{\mathcal{O}_{t}}}\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t},t),t),$
(9)

which is nothing more than the multiplication by the probability density
function $\rho(q_{t},p_{t},t)$

$\rho_{\mathcal{O}_{t}}(\mathcal{O}_{t})=N\rho(q_{t},p_{t},t)\rho_{\mathcal{O}_{t}}(\mathcal{O}(q_{t},p_{t},t),t),$
(10)

where $N$ is a new normalization factor. One can derive a fluctuation theorem
for observables now. First, I consider dimensionless observables made by the
multiplication of a factor $\beta$. Indeed, using Eq. (6), one has the
following fluctuation theorem

$\int_{\Gamma_{t}}\frac{\left|\\{\beta\mathcal{O}(q_{t},p_{t}),\mu_{t}(q_{t},p_{t})\\}_{t}\right|}{\rho(q_{0},p_{0})}\rho(q_{t},p_{t},t)dq_{t}dp_{t}=\int_{\Gamma_{t}}\left|\\{\beta\mathcal{O}(q_{t},p_{t}),\mu_{t}(q_{t},p_{t})\\}_{t}\right|dq_{t}dp_{t},$
(11)

which can be written as

$\int_{\Gamma_{\mathcal{O}_{t}}}\frac{\left|\\{\beta\mathcal{O}_{t},\mu_{t}\\}_{t}\right|}{\rho_{0}}\rho_{\mathcal{O}_{t}}(\mathcal{O}_{t},t)d\mathcal{O}_{t}=\int_{\Gamma_{t}}\left|\\{\beta\mathcal{O}(q_{t},p_{t}),\mu_{t}(q_{t},p_{t})\\}_{t}\right|dq_{t}dp_{t}.$
(12)

##  III Time-dependent work probability density function

Consider that the time-dependent driven system with one degree of freedom is
initially weakly coupled to a heat bath at temperature $\beta^{-1}$. When the
system starts to evolve, the heat bath is removed from the system. After the
switching time $\tau$, the work performed on the system is

$W_{\tau}(q_{0},p_{0})=\mathcal{H}_{\tau}(q_{\tau}(q_{0},p_{0}),p_{\tau}(q_{0},p_{0}))-\mathcal{H}_{0}(q_{0},p_{0}),$
(13)

Let us use the same reasoning used in the previous section to derive the time-
dependent work probability density function. Using a measure $\mu_{\tau}$
related to the probability density function $\rho(q_{\tau},p_{\tau},\tau)$, I
make the change of variables $(\beta
W_{\tau},\mu_{\tau})\rightarrow(q_{0},p_{0})$ and compare it with
$\rho(q_{0},p_{0})$. The work probability density function per points is

$\rho_{\beta W_{\tau}}(\beta
W_{\tau}(q_{0},p_{0}),\tau)=\frac{\rho(q_{0},p_{0})}{\left|\\{\beta
W_{\tau},\mu_{\tau}\\}_{0}\right|}.$ (14)

###  III.1 Jarzynski’s equality

Now let us digress deducting the fluctuation theorem associated. One has

$\frac{\left|\\{\beta
W_{\tau}(q_{0},p_{0}),\mu_{\tau}(q_{0},p_{0})\\}_{0}\right|}{\rho(q_{0},p_{0})}=\frac{\left|\\{\beta
W_{\infty}(q_{0},p_{0}),\mu^{\prime}_{\infty}(q_{0},p_{0})\\}_{0}\right|}{e^{-\beta\mathcal{H}_{0}}}e^{\beta\Delta
F},$ (15)

where I used the fact that
$\left|\\{\beta\mathcal{O}(q_{0},p_{0}),\mu_{\tau}(q_{0},p_{0})\\}_{0}\right|$
is invariant over $\tau$ and consider the measure $\mu^{\prime}_{\infty}$
associated with $\rho^{\prime}_{\infty}=N_{\rho_{\infty}}\rho_{\infty}$, where
$N_{\rho_{\infty}}$ the normalization factor associated for the equilibrium
state at $\tau=\infty$. Here, $\Delta F$ is the difference of Helmholtz’s free
energy calculated at the final and initial equilibrium states. Observe also
that

$\frac{d\left|\\{\beta
W_{\infty},\mu^{\prime}_{\infty}\\}_{0}\right|}{d(\beta\mathcal{H}_{\infty})}={\rm
sign}(\\{\beta W_{\infty},\mu^{\prime}_{\infty}\\}_{0})\left\\{\beta
W_{\infty},\frac{d\mu^{\prime}_{\infty}}{d(\beta\mathcal{H}_{\infty})}\right\\}_{0}=-\left|\\{\beta
W_{\infty},\mu^{\prime}_{\infty}\\}_{0}\right|$ (16)

since
$\rho^{\prime}(q_{\infty},p_{\infty},\infty)=e^{-\beta\mathcal{H}_{\infty}}$
and I suppose that there exists a measure $m$ to make the transformation to
variable $(q_{0},p_{0})\rightarrow(e^{-\beta\mathcal{H}_{\infty}},m)$. This
leads to

$\left|\\{\beta
W_{\tau},\mu^{\prime}_{\tau}\\}_{0}\right|=e^{-\beta\mathcal{H}_{\tau}}.$ (17)

Using the above result and the invariance over $\tau$, one can show

$\int_{\Gamma_{t}}\left|\\{\beta
W_{\tau}(q_{0},p_{0}),\mu_{t}(q_{0},p_{0})\\}_{t}\right|dq_{t}dp_{t}=1.$ (18)

Using Eq. (11), one obtains Jarzynski’s equality [1]

$\int_{\Gamma}e^{-\beta W_{\tau}^{\rm irr}}\rho(q_{t},p_{t},t)dq_{t}dp_{t}=1,$
(19)

where $W_{\tau}^{\rm irr}=W_{\tau}-\Delta F$.

###  III.2 Work probability density function

The final form of the work probability density function is

$\rho_{\beta W_{\tau}}(\beta
W_{\tau},\tau)=\rho(q_{\tau},p_{\tau},\tau)e^{\beta W_{\tau}^{\rm
irr}(q_{\tau},p_{\tau})}.$ (20)

The trick here is to express $\rho(q_{\tau},p_{\tau},\tau)$ in terms of the
$W_{\tau}$. I discuss this in the section III.4.

###  III.3 Crook’s fluctuation theorem

Observe that such an expression (20) satisfies Crook’s fluctuation theorem
[2]. Indeed

$\displaystyle\rho_{W_{\tau}}(W_{\tau}^{+},\tau)$
$\displaystyle=\frac{\rho(q_{0},p_{0})}{e^{-\beta W_{\tau}^{\rm irr+}}}$ (21)
$\displaystyle=\frac{e^{-\beta\mathcal{H}_{0}}}{e^{-\beta F_{0}}e^{\beta
W_{\tau}^{\rm irr-}}}$ (22)
$\displaystyle=\frac{e^{-\beta\mathcal{H}_{\tau}}e^{\beta W_{\tau}^{\rm
irr+}}}{e^{-\beta F_{\tau}}e^{-\beta(-W_{\tau}^{\rm irr-})}}$ (23)
$\displaystyle=\rho_{W_{\tau}}(-W_{\tau}^{-},\tau)e^{\beta W_{\tau}^{\rm
irr+}}.$ (24)

Also, relating Crook’s fluctuation theorem and Eq. (20), and using Liouville’s
theorem, one has

$\rho_{W_{\tau}}(-W_{\tau}^{-},\tau)=\rho(q_{\tau},p_{\tau},\tau).$ (25)

One more time, to have the complete expression it is necessary to express
$\rho(q_{\tau},p_{\tau},\tau)$ in terms of the $W_{\tau}^{-}$.

###  III.4 Gaussian distribution in slowly-varying processes

In this section, I am going to deduce the Gaussian distribution for the work
probability distribution for slowly-varying processes, and discuss how one can
express $\rho(q_{\tau},p_{\tau},\tau)$ in terms of $W_{\tau}$. Observe first
that the previous result was derived for a thermally isolated driven system.
Since Jarzynski’s equation holds for systems in contact with a heat bath, I
consider that the derived probability density functions holds here as well.
Assuming this we are going to see a posteriori that it is reasonable
assumption.

For quasistatic process the work probability density function is approximately
equal to the initial canonical ensemble. In particular, in this regime, all
the initial conditions go to the difference of Helmholtz’s free energy between
the final and initial equilibrium states

$\rho_{W_{\infty}}(W_{\infty},\infty)\approx\rho(q_{0},p_{0})=\delta(W_{\infty}-\Delta
F).$ (26)

To generalize such quantity to any switching time, one must preserve the
invariance of $\rho(q_{0},p_{0})$ over $\tau$ in the new expression related to
$W_{\tau}$. Mathematically speaking, this is done by mollifiers
$\mathcal{I}(x)$ [3], where

$\int_{-\infty}^{\infty}\mathcal{I}(x)dx=1,\quad\lim_{\epsilon\rightarrow
0}\epsilon^{-1}\mathcal{I}(x/\epsilon)=\delta(x).$ (27)

Indeed

$\int_{\Gamma_{0}}\rho(q_{0},p_{0})dq_{0}dp_{0}=\int_{\Gamma_{t}}\rho(q_{t},p_{t},t)dq_{t}dp_{t}\Rightarrow\int_{-\infty}^{\infty}\delta(W_{\infty})dW_{\infty}=\int_{-\infty}^{\infty}\epsilon^{-1}\mathcal{I}(W_{\tau}/\epsilon)dW_{\tau}.$
(28)

In particular, I choose the following mollifier

$\mathcal{I}(W-\Delta F)=\frac{e^{-\frac{\beta^{2}(W-\Delta
F)^{2}}{2}}}{\sqrt{2\pi/\beta^{2}}}.$ (29)

Also, $\Delta F$ becomes equal to the averaged work $\overline{W}_{\tau}$. In
particular, for slowly-varying processes, where $\tau\gg 1$, the irreversible
work is close to zero, so $e^{\beta W_{\tau}^{\rm irr}}\approx 1$. Also, I
choose $\epsilon=\beta^{2}\sigma_{\tau}^{2}$, where $\sigma_{\tau}^{2}$ is the
variance of the work, which $\sigma_{\tau}^{2}\rightarrow 0$ as
$\tau\rightarrow\infty$ [4]. One has then

$\rho_{W_{\tau}}(W_{\tau},\tau)\approx\frac{1}{\sqrt{2\pi\sigma_{\tau}^{2}}}e^{-\frac{(W_{\tau}-\overline{W}_{\tau})^{2}}{2\sigma^{2}_{\tau}}},$
(30)

which leads to the expected result of a Gaussian distribution for slowly-
varying processes [5]. Observe that $\overline{W}_{\tau}$ and
$\sigma^{2}_{\tau}$ should be calculated by alternative definitions than by
using this distribution.

##  IV Conclusions

In this work, I derived the time-dependent probability density function of
classical observables using the Hamiltonian mechanics approach, extending the
notion of fluctuation theorems for any observables. In particular, the time-
dependent probability density function of the thermodynamic work evolving in
the switching time was solved as a special case. From such a relation, I
proved Jarzynski’s equality and Crook’s fluctuation theorem. The particular
case of a Gaussian distribution for slowly-varying processes was derived as
well at the end.

## References

  * Jarzynski [1997] C. Jarzynski, Phys. Rev. Lett. 78, 2690 (1997).
  * Crooks [1999] G. E. Crooks, Phys. Rev. E 60, 2721 (1999).
  * Friedrichs [1944] K. O. Friedrichs, Transactions of the American Mathematical Society 55, 132 (1944).
  * Yi and Talkner [2021] J. Yi and P. Talkner, Phys. Rev. E 104, L062102 (2021).
  * Speck and Seifert [2004] T. Speck and U. Seifert, Phys. Rev. E 70, 066112 (2004).