{'fraction_non_alphanumeric': 0.02954497944394119, 'fraction_numerical': 0.00912828374329315, 'mean_word_length': 4.901315789473684, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Application of Quantum Density Matrix in Classical Question Answering and Classical Image Classification

Quantum density matrix represents all the information of the entire quantum system, and novel models of meaning employing density matrices naturally model linguistic phenomena such as hyponymy and linguistic ambiguity, among others in quantum question answering tasks. Naturally, we argue that applying the quantum density matrix into classical Question Answering (QA) tasks can show more effective performance. Specifically, we (i) design a new mechanism based on Long Short-Term Memory (LSTM) to accommodate the case when the inputs are matrixes; (ii) apply the new mechanism to QA problems with Convolutional Neural Network (CNN) and gain the LSTM-based QA model with the quantum density matrix. Experiments of our new model on TREC-QA and WIKI-QA data sets show encouraging results. Similarly, we argue that the quantum density matrix can also enhance the image feature information and the relationship between the features for the classical image classification. Thus, we (i) combine density matrices and CNN to design a new mechanism; (ii) apply the new mechanism to some representative classical image classification tasks. A series of experiments show that the application of quantum density matrix in image classification has the generalization and high efficiency on different datasets. The application of quantum density matrix both in classical question answering tasks and classical image classification tasks show more effective performance.


Introduction
In a quantum system, the quantum density matrix represents all the information of the entire quantum system. Earlier work has already demonstrated potential quantum advantage for natural language processing (NLP) [1] in a number of manners, and novel such as hyponymy and linguistic ambiguity, among others [2]. In addition, the methods of solving classical problems in accordance with the ideas from quantum theory [3] to improve the performance of classical algorithms have already emerged [4][5][6][7][8]. Naturally, we argue that applying the quantum density matrix into classical question answering tasks can show more effective performance. To test our conjecture, we (i) design a new mechanism based on Long Short-Term Memory (LSTM) [9] to accommodate the case when the inputs are matrixes; (ii) apply the new mechanism to Question Answering (QA) [10] problems with Convolutional Neural Network (CNN) [11] and gain the LSTM-based QA model with the quantum density matrix. Experiments of our new model on both TREC-QA [12] and WIKI-QA [13] data sets show encouraging results.
Similarly, we argue that the quantum density matrix can also enhance the image feature information and the relationship between the features for the classical image classification [14]. Thus, we (i) combine density matrices and CNN to design a new mechanism that is called QIM for convenience; (ii) apply the new mechanism to some representative classical image classification tasks. Our experiments on Intel dataset [15] have verified our conjecture that it can also enhance the image feature information and the relationship between the features by applying the quantum density matrix method to the classical image classification tasks. Besides, a series of experiments on Mnist [16], Fashion-Mnist [17], Cifar 10/100 [18], ......, have shown that the quantum density matrix fits these different datasets in image classification tasks.
In a nutshell, the application of quantum density matrix both in classical question answering and classical image classification tasks show more effective performance.
The structure of this paper is described as follows. In Section 2, the application of quantum density matrix in classical question answering is introduced, and the corresponding experimental results are provided. In Section 3, the application of quantum density matrix in classical image classification is introduced, and the corresponding experimental results are provided. In Section 4, a brief conclusion and the introduction of our future work are given.

Scheme Design
A quantum language model (QLM) [19] represents a word or a compound dependency between words by a quantum elementary event [20] which represented the query q and document d, respectively [19].
Inspired by the quantum language model and quantum density matrix, we argue that applying the quantum density matrix into classical question answering tasks can show more effective performance. At first, we represent the quantum density matrix with linear algebra to generate the density matrices. The mathematical formalism of quantum theory is based on linear algebra. In quantum probability [21], the probabilistic space is naturally represented in a Hilbert space, denoted as n H . For practical reasons, the previous models with the method of quantum limited the problem in the real space, denoted as n R [19]. The Dirac's notation is often utilized, which denotes a unit vector u R ⊂  as a ket u and its transpose T u  as a bra u . The inner product between two state vectors is denoted as u v . The projector onto the direction u is u u , which is an outer product (dyad) of u itself. Each rank-one projector u u can represent a quantum elementary event. Density matrix is a generalization of the conventional finite probability distributions. A quantum density matrix ρ can be defined as a mixture of dyads i i ϕ ϕ where i ϕ is a pure state vector with probability i p . ρ is symmetric, positive semidefinite, and of trace 1 ( ( ) tr 1 ρ = ). Similarly, we provide the expression of the density matrix ' ρ in our work: where i k denotes the weight of vector u  and 1 We design a new mechanism based on LSTM to accommodate the case when the inputs are matrixes, and the new mechanism is shown in Figure 1

Experimental Evaluation
A series of experiments are carried out for a systematic evaluation, and experiments of our new model on the TREC-QA [12] and WIKI-QA [13] data sets show encouraging results. The experiment results are summarized in Table 1, where LSTM(V) represents the model without the new mechanism we designed and LSTM(M) represents LSTM-based question answering model with the quantum density matrix. It is clear that our new model has advantages in both two datasets, which shows the effectiveness of our new model with the density matrix together. Therefore, applying the quantum density matrix into classical question answering tasks can show more effective performance.

Image Classification
Image classification, one of the main applications of computer vision (CV) [23], is the task of assigning labels to images through image analysis. The process of traditional image classification algorithms (refer to Figure 3 (a)) consists of two steps: (i) extracting features manually from the image; (ii) making use of the training support vector machine (SVM) [24] or other classifiers to execute image classification according to the extracted features. In general, the accuracy of the whole system of traditional image classification algorithms is limited to the method of extracting features. To solve the problem of feature extraction, AlexNet [25] is designed by applying deep learning [26] to large-scale image classification tasks and achieves better results. After that, many methods based on AlexNet emerged, such as LeNet [27], ZFNet [28], VGG-Net [29], ResNet [30], and so on.

Scheme Design
Similar to the application of quantum density matrix in classical question answering tasks, we consider making the density matrix to enhance image features and the correlation information between features in classical image classification tasks. In a quantum system, every particle i is in its own state i s , and the tensor product i i s s is its own quantum density matrix. The quantum density matrix of the entire system is generated by adding the quantum density matrix of each particle in the quantum system according to a certain weight i p , the generation of quantum density   Finally, we add density matrices to CNN with 2D convolution kernels to generate our scheme of employing quantum density matrix in classical image classification tasks.
We name our scheme as Quantum Inspired Mechanism (QIM) for convenience, and the QIM is shown in Figure 6.
Suppose the number of filters is c . The th j convolution operation is where 1 j c ≤ ≤ , δ is the non-liner activation function, * is the 2D convolution, j m p and j b are the weight and bias respectively for the th j convolution kernel, and j C is the feature map. After the convolution layer obtains the feature maps, we then use row-wise and column-wise max-pooling to generate vectors We concatenate these vectors as follow: [ ] where 1 t c ≤ ≤ . The above convolution operation aims to extract useful similarity patterns and each convolution kernel corresponds to a feature. We can adjust the parameters of the kernels when the model is being trained. Figure 6 The quantum-inspired mechanism (QIM)

Experimental Evaluation
To verify our scheme, we apply QIM to the classical image classification tasks.
The specific process of the classical image classification task based on CNN with quantum density matrix is shown in Figure 3  To verify whether QIM helps classical image classification tasks, we do some preliminary ablation experiments with StandardCNN [31] on Intel dataset at first, and the results are shown in Table 2. these better results and the results obtained by adding QIM to these typical models are shown in Table 3. As for Cifar series, Cifar10 dataset contains small-sized images, as well as smaller classification space compared to Cifar 100, so we do not apply large models (e.g. VGG, ResNet) on it.
-StandardCNN [31]: A CNN model carried out for our baseline experiments. Its structure is designed in particular, including 3 convolutional layers, 3 pooling layers and 2 fully connected layers.
-LeNet-5 [27] LeNet is a CNN model. In general, LeNet-5 refers to lenet-5 and it is a simple CNN, built up with 2 convolutional layers, 2 pooling layers and 2 fully connected layers. Though simpler than StandardCNN, it still performs better on some datasets such as Mnist-series.
-AlexNet [25]: AlexNet is a CNN model, and it contains 11 layers: 5 layers are convolutional layers, 3 layers are max-pooling layers, and the last 3 layers are fully connected layers. It used the non-saturating ReLU activation function, which showed improved training performance over tanh and sigmoid. In our experiments, it has the ability to perform well in many tasks.
-ZFNet [28]: ZFNet is a CNN model, which is very similar to AlexNet in structure. Theoretically, ZFNet can be seen as an enhanced version of AlexNet.
-VGG [29]: VGG is a CNN model, and it may be one of the deepest traditional CNNs up to now. It has many types such as VGG-16 and VGG-19. Take VGG-19 as example, it is built up with 24 layers, including 16 convolutional layers, 5 pooling layers and 3 fully connected layers. Its design suits well for multi-sort image classification tasks with large-sized image information, but failed to match small-sized image classification tasks in our experiments. Such result has also proved that a wider and deeper neural network isn't always equivalent to a better model. is a proof-of-concept, and there are many possible optimizations but they are beyond the scope of this paper.

Case Study
The comparative experiments with StandardCNN on Cifar10 are shown in Figure   8, where the upper part stands for the initial experiment, and the lower part represents the experiment with QIM. In image classification tasks, traditional CNN models usually make consideration of just applying fully connect layers on feature maps extracted by convolution layers, but QIM tends to juice more valid information from those feature maps. Therefore, after convolution layers have produced feature maps, QIM firstly flattens those feature maps and does an outer product calculation within it, in which step the density matrices are built. Secondly, QIM applies another group of large-sized convolution layers on the density matrices mentioned above. This operation usually makes those matrices resize to 10x10 called the product density feature maps.  Table 3, QIM achieves higher performance improvement on accuracy when dimension of image data is obviously broader or original CNN could hardly suit a designated image classification task. The upper is the initial experiment, the lower is the same as the upper except that QIM is added.

Conclusion and Future Work
To investigate whether the quantum density matrix helps the classical question answering problems and the classical image classification tasks, we have designed two schemes. On the one hand, we have applied the quantum density matrix into classical question answering tasks. We have designed a new mechanism based on LSTM with quantum density matrix and further proposed a new LSTM-based question answering model with the quantum density matrix. Experiments of our new model on different data sets have shown encouraging results. On the other hand, we have also applied the quantum density matrix into classical image classification tasks. We have proposed the quantum inspired mechanism, i.e., QIM, which re-represented the quantum density matrix with linear algebra and combined CNN with density matrices. To the best of our knowledge, this is the first time for the quantum method applied to image classification tasks. In QIM, density matrices enhance image features and the correlation between features in classical CV algorithms, which has been verified by a series of preliminary ablation experiments. We gained the optimum parameters for QIM from preliminary ablation experiments and applied these parameters to the further ablation experiments.
Results have shown that QIM has the generalization in classical image classification tasks on different datasets.
To sum up, the application of quantum density matrix both in classical question answering problems and classical image classification tasks have shown more effective performance, which confirms our argues about the quantum density matrix.
For future work, we plan to develop optimization techniques to improve the performance and try to apply the quantum density matrix to other classical tasks.