# How is quantum machine learning reversible?

Say I have a binary classification network, which takes in inputs and classifies them. I can put in different inputs and get the same output, right? So does that not make QML non reversible, since just by looking at the output, I will never know the input?

• that's not that much of a problem. You can imagine a reversible algorithm that gives you very efficiently the (non-reversible) solution you seek in some output qubit(s), but is still reversible as far as the whole thing is concerned. In other words, you can encode the solution to the problem in a subset of the output qubits.
– glS
Apr 26, 2021 at 11:14

There are a couple of ways reversibility might be coming into play in this context. The first is that the measurement at the end of the circuit will be typically be an irreversible step. For example one scheme for training a quantum circuit to classify classical data is by encoding each data point $$x_i$$ (with a corresponding $$0,1$$ label $$y_i$$ for the binary classification task) in your dataset into a state $$\rho(x_i)$$ (probably using a unitary parameterized by $$x_i$$, i.e. $$\rho(x_i) = U(x_i) |0 \rangle \langle 0| U^\dagger(x_i)$$) and then learning some observable $$M(\theta)$$ to classify these quantum states according to a rule like
$$\tag{1} f(x_i) = \text{sign} \left[ \text{Tr} \left(\rho(x_i) M(\theta) \right)\right]$$
and then training the quantum circuit will consist of finding $$\theta$$ such that that $$\text{Pr}(f(x_i)=y_i)$$ is maximized over some training set. Evaluating (1) is usually an irreversible process because it requires setting up a circuit with measurements that estimate $$\langle M(\theta) \rangle$$, and each of these measurements will end up "collapsing" $$\rho(x_i)$$.
A very different take on this question is to think about reversing the learning task itself. If we think of each training pattern and label $$(x_i, y_i)$$ as being a pair of random variables $$(X, Y)$$ drawn from a distribution $$\text{Pr}(X, Y)$$, then the goal of the above algorithm was to learn the conditional distribution $$\tag{2} \text{Pr}(Y=y_i | X=x_i)$$ therefore answering the question, "given a pattern $$x_i$$, what is the likelihood that the true label was $$y_i$$?". But one may instead be interested in a generative model where the goal is to learn a function approximating $$\tag{3} \text{Pr}(X=x_i| Y=y_i)$$ which answers the question, "if I am provided a label $$y_i$$, what is the corresponding distribution of patterns $$x_i$$ with that label?"$$^1$$ Of course (3) isn't a unique function sending $$y_i \rightarrow x_i$$ so its not "reversible" in the sense of being invertible, but knowledge of this likelihood does allow you to sample a reasonable set of datapoints $$\{x_i\}$$ given a single label $$y$$. There has been some recent research into "quantum generative models" that propose using quantum computers to do just this, and so you might find some interesting topics in that area.
$$^1$$ This task is generally much harder; one way to understand this is that if you learn (3) then you will immediately have an optimal Bayes classifier that is at least as good at classifying input data as any other model.