Literature DB >> 35741510

Alpha-Beta Hybrid Quantum Associative Memory Using Hamming Distance.

Angeles Alejandra Sánchez-Manilla1, Itzamá López-Yáñez2, Guo-Hua Sun1.   

Abstract

This work presents a quantum associative memory (Alpha-Beta HQAM) that uses the Hamming distance for pattern recovery. The proposal combines the Alpha-Beta associative memory, which reduces the dimensionality of patterns, with a quantum subroutine to calculate the Hamming distance in the recovery phase. Furthermore, patterns are initially stored in the memory as a quantum superposition in order to take advantage of its properties. Experiments testing the memory's viability and performance were implemented using IBM's Qiskit library.

Entities:  

Keywords:  Alpha-Beta associative model; hamming distance; pattern recognition; quantum associative memory; quantum machine learning

Year:  2022        PMID: 35741510      PMCID: PMC9222362          DOI: 10.3390/e24060789

Source DB:  PubMed          Journal:  Entropy (Basel)        ISSN: 1099-4300            Impact factor:   2.738


1. Introduction

Quantum computing is an emerging area of computing based on the principles of quantum mechanics. In it, information is represented by quantum states, generally using qubits as the basic unit of storage, and the properties of quantum mechanics such as superposition, are exploited in order to improve the processing speed. Consequently, in recent years, there has been an increasing interest for new developments in the field [1,2,3]. One of these new developments is the creation of quantum algorithms that can provide a quadratic or even an exponential speed-up compared to their classical counterparts. Among the best known quantum algorithms are those of Shor and Grover et al. [4,5], of which different versions have been developed for several areas. Quantum machine learning is one of the particular interests for this work. Machine learning (ML) is based on the minimization of a constrained multivariate function, and its algorithms are used for data mining and data visualization techniques [6]. In particular, associative memories are a specific class of machine learning algorithms that perform the task known as “retrieval”. In order to take advantage of quantum computing, the idea of a quantum associative memory (QAM) arose similarly to a Hopfield network, although its quantum formulation did not require a reference to artificial neurons [7]. To date, there exist some proposals of quantum associative memories; however, it is worth commenting that the first time they were mentioned was by Ventura et al. in [7], where Grover’s algorithm is used as the main approach. Subsequently, other approaches have been used: quantum associative memories including linear and nonlinear algorithms by Zhou et al. [8], in which the quantum matrix is constructed using binary decision diagrams; in [9], the authors proposed a QAM that performs image recognition for face detection using the Gabor transform; multidirectional associative memories [10,11,12], where fuzzy inference is used, and by means of different layers, it is able to be noise tolerant; in another interesting work [13], the authors propose a QAM that is used as a tool for medical personnel to obtain the diagnosis of four tropical diseases. In this work, a hybrid quantum associative memory (HQAM) is proposed, using the Alpha-Beta support vector machine [14,15] at the learning phase and the quantum Hamming distance subroutine at the retrieval phase. It should be mentioned that it is considered hybrid because it combines both classical and quantum computing to obtain the greatest potential of both parts. The advantage of this model over a classical model lies in the reduction of operations at the recovery or retrieval phase when calculating the Hamming distance, since it takes advantage of the parallelism that allows the superposition of patterns in the trained memory.

2. Materials and Methods

2.1. Basic Concepts on Associative Memories

Some of the basic concepts regarding the theory of associative memories in classical computing are explained below. Their operation is divided into two phases: Learning phase (generation) Retrieval phase (operation) The fundamental purpose of an associative memory is to correctly recall complete patterns from possibly altered input patterns as this is the most attractive feature of associative memories. In the particular case where the patterns have only binary data, the only possible types of alterations (i.e., noise) are additive, subtractive or mixed. Thus, an associative memory M can be formulated as an input-output system [16]: The input pattern is represented by a column vector, denoted by x, and the output pattern by a column vector, denoted by y. Each of the input patterns form an association with the corresponding output pattern, the notation for this association is similar to that of an ordered pair, e.g., the x and y patterns in the schematic form the association (x, y); a specific association is denoted as (x, y), where k is a positive integer. The associative memory M is represented by a matrix whose i j component is denoted as m [17]. The matrix M is generated from a finite set of associations that is known as the fundamental set of associations or simply as the fundamental set. The cardinality of the fundamental set is denoted by p. If μ is an index, the fundamental set is represented as follows: The patterns that form the associations of the fundamental set are called fundamental patterns. If it holds that x = y, for ∀μ ∈ {1, 2, …, p}, the memory is said to be autoassociative, otherwise, it is called heteroassociative. It is possible for the fundamental patterns to be altered by different types of noise, thus, in order to differentiate an altered pattern from its fundamental counterpart, a tilde is used over the pattern, that is, denotes an altered version of the fundamental pattern x. When the memory M receives an altered pattern as input (ω ∈ {1, 2, …, p}, and M responds with the corresponding fundamental output pattern y, it is said that the memory recall is correct. Two sets A and B, need to be specified; the components of the column vectors, representing both input and output patterns, are elements of the set A, whereas the components of the matrix M are elements of B. There are no prerequisites or limitations on the choice of these two sets, so they do not necessarily have to be different or have special characteristics. The positive integer numbers n and m are used to represent the dimension of the input and output patterns respectively. Then the fundamental input and output pattern can be represented as:

2.2. Alpha-Beta HQAM Algorithm

The architecture of the proposed Alpha-Beta HQAM model is shown in Figure 1, and the detailed algorithm flow is summarized as following the figure:
Figure 1

Alpha-Beta HQAM model architecture.

Preprocessing is performed to reduce the number of qubits required. Based on the Alpha-Beta SVM associative model, it is intended to take advantage of only that information which is not repeated in the patterns of the fundamental set. At result of this point, there will be two fundamental sets: the restricted fundamental set and the negated restricted fundamental set, as is further explained bellow. A segmentation of the patterns with a length of n = 4 is performed, assuming that they are binary images (0 white, 1 black). Once this is completed, partial fundamental sets are formed to start training the Alpha-Beta HQAM. Its principal objective is to mitigate the limited number of available qubits and to make it feasible to run experiments using Qiskit SDK. The training set is encoded into a superimposed quantum state with the equal probability amplitudes: , where x is the i-th binary pattern of length n. The storage complexity of this algorithm is a linear function related to the number of patterns in the training set. The retrieval algorithm computes the Hamming distance between the input and all overlapping patterns in the quantum state of the memory. It indicates the probability that an input pattern is in memory, based on the results of its distance distribution over all stored patterns at once. This algorithm is described in Section 2.4. This process must be repeated several times until all the subsets of the training set have been recovered. Once the previous step is finished, the retrieval for each segment (obtained in step 2) of the patterns in the training set is performed and reintegrated to get the original length of the patterns.

2.3. Preprocessing Module

In this first part, the information is preprocessed to reduce its volume and keep only the most relevant information in the fundamental patterns, this is based on the Alpha-Beta SVM associative model [18], the details are as follows.

2.3.1. The α and β Operators

In this model, the main mathematics used are binary operators designed for the original Alpha-Beta associative memories [15]. They are based on two binary operators: the α operator used in the learning phase and the β operator for the retrieval phase. The sets are defined A = {0, 1} and B = {0, 1, 2}, then: the binary operator α: A × A → B and the binary operator β: B × A → A are defined in Table 1, where ∨ is the max operator and ∧ is the min operator. The sets A and B, the operators α and β, together with the operators ∧ and ∨, form the algebraic system that is the mathematics basis for Alpha-Beta Associative Models.
Table 1

Operators α and β.

α: A × A → Bβ: B × A → A
x y α(x,y) x y β(x,y)
001000
010010
102101
111111
201
211

2.3.2. Alpha-Beta SVM Associative Model

Some important definitions within the Alpha-Beta SVM associative model are explained below. A zero vector is defined as the vector whose components are all of value 0, and is denoted 0. A one vector is defined as the vector whose components are all of value 1, and is denoted by 1. Let A = {0, 1} be a binary set, x and y are two vectors, x,y ∈ A, n ∈ , with x,y ≠ 0,1. The auxiliary c and k are defined as: with k being a positive integer number which can have a value between 1 and r inclusive. Elimination: The elimination of the vector y with respect to the vector x can be obtained as follows: Define the index c according to Equation (5); Eliminate the components x and y; Decrease the indices of the x and y, where c < i ≤ n if they exist; Obtain the eliminated vectors ε1(x) and ε1(y), the dimension of the vectors are decreased to n − 1. If the elimination in y according to x is applied continually with: in the k-th iteration, the transformed vectors are denoted ε(x) and ε(y). Restriction: Continue to repeat the elimination, until the valid k-th iteration, in other words, ε((x) ≠ 0, andε(x) = 0, we get a new vector , which is the restriction of y with respect to x, denoted by . In this definition, the vector y is really eliminated by the corresponding component with respect to those components of the vector x with a value of 1 Let and ; obtain : Therefore . Let A = {0, 1} be a binary set, x and z are two vectors x ∈ A, z ∈ A, n, and m = n − k, with x,z ≠ 0, 1.. Insertion: The insertion of the vector z with respect to the vector x can be obtained as follows: Define the index c according to Equation (5); Shift the components z to z, where c ≤ i ≤ m; Insert z = 1, assign x = 0; Obtain the inserted vectors I1(x) and I1(y), the dimension of the vector z increased to m + 1. If the insertion in z according to x is applied continually with: in the k-th iteration, the transformed vectors are denoted I and I. Expansion: Continue to repeat the insertion, until the valid k-th iteration, in other words, I((x) ≠ 0, and I = 0, we get a new vector z ∈A, which is the expansion of z with respect to x, denoted by . In this definition, the vector z is really inserted with a value of 1 to the corresponding position with respect to those components of the vector x with a value of 1. For example, Let and ; obtain : Therefore . Support Vector: Let A = {0, 1}, be the binary set, let x be a vector x ∈ A of dimension , and , is the cardinality of the fundamental set of an Alpha-Beta SVM associative model. The vector S is made up of n binary components, which are calculated from the fundamental set as: Returning to the current proposal, based on the fundamental set and using Equation (10), a pattern can be obtained that contains the repeated information in all the fundamental patterns, subsequently, it is eliminated from the fundamental set, leaving only the information that differentiates a fundamental pattern from all the others. This repeated information is stored in a vector called Support Vector (S). Since we are looking for the information that can be more significant in the patterns, the next step is to negate the fundamental set and repeat the procedure described in the previous paragraph, thus obtaining the Negated Support Vector . By the end of this part, there are two fundamental sets: the restricted fundamental set and the negated restricted fundamental set. Figure 2 shows an example of pattern reduction on a fundamental set and Algorithm 1 shows the process of obtaining the fundamental sets:
Figure 2

Alpha-Beta HQAM preprocessing: (a) Restricted Fundamental Set. (b) Negated Restricted Fundamental Set.

2.4. Segmentation

At present, commercial quantum computers do not yet exist, however, some are available through platforms such as the IBM Q Experience, where up to five qubits can be freely used. Therefore, in order to be able to recover images that exceed this capacity, in the proposed Alpha-Beta HQAM model the images are segmented into 4-bit patterns considering that they are binary images (0 white and 1 black) to reduce their length. Figure 3 shows an example of the segmentation process of the Restricted Fundamental Set length, which was calculated as explained in Section 2.3.2, and repeated for the Negated Restricted Fundamental Set.
Figure 3

Alpha-Beta HQAM segmentation.

Once this segmentation is completed, fundamental partial sets are formed to start training the proposed model.

2.5. Training Phase

To use some of the properties of quantum mechanics in this model, it is necessary to pass the fundamental ensemble to the quantum state. That is, to transform the bits into qubits to take advantage of the superposition property. The first step is to obtain the unique patterns of the fundamental sets so that the probabilities are distributed and thus there is no class imbalance. This is undertaken to avoid that the probability is biased and, when retrieving it, the majority class is always taken as the result. At this phase, memory initialization is carried out, which consists of an operation that transforms the training set into quantum states with the same probability. Given p binary patterns of length n, the memory represented as a quantum state is shown as: The complexity of this algorithm is linear as a function of the number of patterns in the training set. A detailed description of how the storage is performed with an n bits pattern dataset as input is given below. Algorithm 2 shows the necessary gates to perform each of the steps: Three registers are used: first register x of n qubits in which the patterns to store are represented. An ancilla register u of two qubits sets up in state. Another register m of n qubits to store the memory, the order is from right to left which is initially prepared in state. The second qubit of the register u, , in state, for the stored patterns and the first qubit in for the processing term. For every pattern in the training set to be stored, if the contents of the patterns and the memory registers are identical, all these qubits will be transformed in ’s. The first ancilla qubit of the processing term is transformed from , leaving it unchanged for the stored patterns term. The input pattern is added to the memory register with uniform amplitudes. This is carried out by applying the gate, as shown below: Further steps apply inverse operations to return the memory to its initial state and prepare it to receive the next pattern. This algorithm runs several times until all the patterns have been processed and stored on .

2.6. Retrieval Phase

The Hamming distance [20] in classical computing is defined as the count of the number of bits that are different between two patterns of equal length, for example, has a distance of three. However there is a quantum version of this algorithm that was proposed by Trugenberger [21] where the output is determined by a probability distribution in the memory that has a peak around the stored patterns that are closest with respect to the Hamming distance of the input. If the input pattern is far away from the patterns stored in memory, will be obtained as output. Otherwise, would be obtained. The following is a detailed description of how retrieval is carried out. Algorithm 3 shows the necessary gates to perform each of the steps. In the initial step of the algorithm, an overlay of the training set containing the training data is constructed: Starting from this, construct the initial state: The initial state consists of three registers, the first contains the input pattern, the second contains the memory , and the third contains the ancilla qubit set to zero. During the first step, the ancilla is a superposition through the Hadamard gate, giving rise to: Next, by applying a CNOT gate to all j components of the patterns ( is the control qubit and is the target qubit), followed by an X gate to each of the target qubits, the following is obtained Applying unitary operator , where H is a hamiltonian summing over all the components , calculate the Hamming distance between and , which obtains: Applying Hadamard gate on the last qubit, is obtaining the next state: Qubits and need to be measured. By measuring and it is possible to know which pattern is the result of the retrieval, unlike the original version of the algorithm, we only can know whether the pattern to be retrieved belongs to the trained memory or not.

2.7. Validation Methods

To evaluate the capacity of retrieval of the model proposed in this work, two validation methods belonging to the state of the art of machine learning were used, which are explained below. Resubstitution Error (RE): In this method the test set is the same as the training set [22], the formula for calculating it is: Leave One Out: Is a special case of cross-validation where the number of folds equals the number of instances in the dataset. Thus, the learning algorithm is applied once for each instance, using all other instances as a training set and using the selected instance as a single-item test set [23].

3. Results and Discussion

In this section the results obtained in the proposed Alpha-Beta HQAM model are presented and analyzed. Two datasets were chosen, the first one is a set of 10 letters of the alphabet as shown in Figure 4, each of the letters consists of a 5 × 5 pixels image that is binarized to apply the model, considering one to the black pixel and zero to the white pixel. The second one is the digit numbers shown in Figure 4.
Figure 4

Original datasets: (a) Letters dataset. (b) Digit numbers dataset.

For the execution of the experiments, Python language is used with the Qiskit SDK to simulate quantum circuits in a computer. Remembering that the proposal is hybrid, the preprocessing and segmentation part is performed with Python programming and the associative memory phases with the Qiskit SDK. Appendix A shows the code that was used to run the experiments presented below. The experimental results with these two datasets are presented in five parts. First, the preprocessing of each of the datasets is described. Then, in the second subsection, a summary of the results obtained with the resubstitution error validation method is shown. In the third subsection, the results with the Leave One Out validation method are reported, as well as their corresponding discussion. The fourth subsection shows the result of applying the three types of noise (Additive, Subtractive and Mixed) to the first database and finally in the last subsection a summary of the results and their corresponding discussions are represented.

3.1. Dataset Preprocessing

When preparing the fundamental set, it is composed of 10 patterns and each one has 25 features, then the Support Vector and the Negated Support Vector are calculated and as a result the restricted fundamental sets are obtained. For the experiment using resubstitution error as the validation method in both datasets, the number of features has no variation on its original state In Table 2 and Table 3 the respective results are shown.
Table 2

Number of features in the letters dataset with the resubstitution error as validation method.

ABCDEFGHIJ
Restricted Fundamental Set25252525252525252525
Negated Restricted Fundamental Set15151515151515151515
Table 3

Number of features in the digit numbers dataset with the resubstitution error as validation method.

0123456789
Restricted Fundamental Set25252525252525252525
Negated Restricted Fundamental Set15151515151515151515
On the other hand, for the experiment using Leave One Out as the validation method, the number of features varies between each letter or number depending on the datasets, the respective results are shown in Table 4 and Table 5.
Table 4

Number of features in the letters dataset with the Leave One Out as validation method.

ABCDEFGHIJ
Restricted Fundamental Set25252525252525242225
Negated Restricted Fundamental Set15151515151515151515
Table 5

Number of features in the digit numbers dataset with the Leave One Out as validation method.

0123456789
Restricted Fundamental Set25222525242525242125
Negated Restricted Fundamental Set15151515151515151515
At the end of this part, the segmented training sets are formed into 4 bits that upon application of the initialization algorithm become qubits.

3.2. Results with the Resubstitution Error as Validation Method

For this validation method, the retrieval is accurate for each of the images of both fundamental sets in the proposed model. In Figure 5 the results are shown for both datasets, with this it can be said that its forgetting factor is zero. That is, the patterns with which the quantum associative memory is already trained are no longer forgotten during the retrieval phase.
Figure 5

Retrieval results with Resubstitution Error: (a) Letters dataset. (b) Digit numbers dataset.

3.3. Results with Leave One out as Validation Method

For this experiment, the results obtained are shown in Figure 6. For these cases, the retrieval could be obtained for most of the images, for the letters there were seven of a set of ten and for the digits six of ten. Notice that although it was not complete in the other cases they were very close approximations.
Figure 6

Retrieval results with Leave One Out: (a) Letters dataset. (b) Digit numbers dataset.

In the case of the letter dataset, since most of the letters resemble each other, it generates a little confusion in some pixels, perhaps this depends on the length that was chosen for the patterns and does not allow one to have considerably different training from each other. Analyzing the results of the dataset of numbers, the one with the highest error is one, this may be happening because the other digits are very different from it, so in the learning phase it does not have enough training to obtain a better retrieval. These latter two hypotheses merit further analysis. In addition, the results were compared with those obtained in Neto et al. [24], they designed a quantum associative memory, where the retrieval phase consists of three parts: Exchange, Quantum Fourier Transform and Grover’s algorithm. To test their method, they used a dataset of 10 letters as shown in Figure 7, in order to directly compare the result with them, a variant of the letters dataset was created to match the letter J.
Figure 7

Dataset of letters with different J.

In Figure 8, item (a) shows the obtained result in [24], item (b) shows the obtained results by the proposed Alpha-Beta HQAM model.
Figure 8

(a) Figure designed from the results obtained in [24]. (b) The obtained results by the proposed Alpha-Beta HQAM model.

By comparison, for the proposed Alpha-Beta HQAM model, there was a completely correct retrieval for six of the ten letters, while they did not retrieve any correctly, and with respect to the others it is noticeable at a glance that there are fewer incorrect pixels, so it can be said that, in general, the proposed model in the retrieval is better than the one reported in [24] It should be noted that the retrieval phase proposed in the new model is less complex to implement, since only the Quantum Hamming Distance algorithm is used, compared to the others which need three algorithms, increasing the number of quantum gates and more qubits needed

3.4. Noisy Input Data

To further experiment with the proposed memory, different types of noise were applied at (Additive, Subtractive and Mixed) to the original datasets shown in Figure 4. In order to easily identify the type of noise applied, pixels with Additive noise are shown in gray and pixels with Subtractive noise in blue. For Additive Noise, in the letters dataset, Figure 9 in (a) shows the set to be recovered with noisy, and (b) shows the result obtained by the proposed Alpha-Beta HQAM model. The letters that could not be recovered were , but for the others the recovery was completely correct. It is possible that it was influenced by the fact that the patterns to be recovered had no loss of information in the qubits that make up the letters.
Figure 9

Letters dataset: (a) Patterns with additive noise. (b) Results of the retrieval.

In the digit numbers dataset, Figure 10 in (a) shows the set to be recovered with noisy, and in the same Figure 10 but in (b), the result obtained by the proposed Alpha-Beta HQAM model is shown. Only could be recovered and only varied by one and two pixels respectively, but only had a recovery of half of the original pattern.
Figure 10

Digit numbers dataset: (a) Patterns with aditive noise. (b) Results of the retrieval.

For the Subtractive noise, in the letters dataset, the result was not as expected since only three letters were completely recovered, although for the others one or two pixels varied. The results are shown in Figure 11, in (a) are the patterns with subtractive noise and in (b) are the results of the retrieval.
Figure 11

Letters dataset: (a) Patterns with subtractive noise. (b) Results of the retrieval.

In the digit numbers dataset, the results were favorable because five were complete retrieval . However, for it only varied in one pixel and for it failed in two pixels. The results are shown in Figure 12, in (a) are the patterns with subtractive noise and in (b) are the results of the retrieval.
Figure 12

Digit numbers dataset: (a) Patterns with subtractive noise. (b) Results of the retrieval.

Lastly, for the mixed noise, in the letters dataset, a completely correct retrieval was only obtained for , in the case of there was only a variation in one pixel. The results are shown in Figure 13, in (a) are the patterns with mixed noise and in (b) are the results of the retrieval.
Figure 13

Letters dataset: (a) Patterns with mixed noise. (b) Results of the retrieval.

In addition, for the digit numbers dataset, were retrieved completely correctly, but only failed in one pixel, so it is very close to a perfect retrieval. The results are shown in Figure 14, in (a) are the patterns with mixed noise and in (b) are the results of the retrieval.
Figure 14

Digit numbers dataset: (a) Patterns with mixed noise. (b) Results of the retrieval.

Additionally, Table 6 and Table 7 show a summary of the results obtained in all the experiments described in the previous sections, these performances are calculated as the percentage of correctly recovered pixels.
Table 6

Summary table of the accuracy (%) obtained in the experiments of the letters dataset.

ABCDEFGHIJ
Resubstitution Error100100100100100100100100100100
Leave One Out100100961001009610010010096
Additive Noise1001009610010010010096100100
Substractive Noise92969696969696100100100
Mixed Noise9610010010096100100100100100
Table 7

Summary table of the accuracy (%) obtained in the experiments of the digit numbers dataset.

0123456789
Resubstitution Error100100100100100100100100100100
Leave One Out10012881009210010088100100
Additive Noise10092961009210010096100100
Substractive Noise9692961009610010096100100
Mixed Noise10096100100969210010010096

4. Conclusions

In this work, a hybrid quantum associative memory was proposed and tested on different datasets. The two main attributes of the proposal are the dimensionality reduction of the input patterns using the Alpha-Beta support vector subroutine, which allows the algorithm to run on currently available quantum hardware; and the use of a quantum subroutine to calculate the Hamming distance in the retrieval phase of the memory. The presented results were obtained using IBM’s Qiskit SDK, and show a competitive performance compared to other state-of-the-art works. It is important to note that the overall quantum complexity of Alpha-Beta HQAM is precisely because the memory has to be reconstructed for each retrieval. This is a widespread problem among quantum algorithms, since the cost of constructing a specific superposition is high. However, it is worth mentioning that Alpha-Beta HQAM does have an advantage over classical memory for retrievals of less than one training. Specifically, for a single retrieval, the advantage is huge: versus . This advantage can be used for specific applications in quantum noise correction, for example, if an algorithm is run once, then memory can be used to recover the noise-free version of the output. An interesting potential extension of this proposal includes the realization of experiments with patterns of higher dimension (more attributes) in order to analyze the retrieval performance of the memory in datasets with this specific feature, and even include efficient initialization protocols to reduce quantum complexity in the training phase.
  3 in total

1.  Probabilistic quantum memories.

Authors:  C A Trugenberger
Journal:  Phys Rev Lett       Date:  2001-07-18       Impact factor: 9.161

2.  Quantum-Inspired Multidirectional Associative Memory With a Self-Convergent Iterative Learning.

Authors:  Naoki Masuyama; Chu Kiong Loo; Manjeevan Seera; Naoyuki Kubota
Journal:  IEEE Trans Neural Netw Learn Syst       Date:  2017-02-03       Impact factor: 10.451

3.  Quantum associative memory with linear and non-linear algorithms for the diagnosis of some tropical diseases.

Authors:  J-P Tchapet Njafa; S G Nana Engo
Journal:  Neural Netw       Date:  2017-09-21
  3 in total

北京卡尤迪生物科技股份有限公司 © 2022-2023.