A data anomaly detection method based on quantum self-encoder
The anomaly detection method using quantum autoencoders solves the problems of large parameter volume and training latency in high-dimensional data processing, achieving efficient and accurate anomaly detection, and utilizing quantum properties for feature extraction and dimensionality reduction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-03-02
- Publication Date
- 2026-06-19
AI Technical Summary
Existing deep learning-based autoencoders suffer from problems such as large number of parameters, high training computational cost, and inference latency when processing high-dimensional data, and lack effective anomaly detection schemes for high-dimensional classical and quantum state data.
A quantum autoencoder is used for data anomaly detection. A quantum autoencoder model is constructed through quantum state mapping, and the parameters are optimized using classical machine learning training strategies. Anomaly detection is then performed in conjunction with quantum measurement.
It improves the speed and accuracy of anomaly detection in high-dimensional data, reduces training costs, leverages quantum advantages for efficient feature extraction and dimensionality reduction, and minimizes information loss.
Smart Images

Figure CN121745331B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum machine learning technology, and more specifically to a method for detecting data anomalies using a quantum autoencoder. Background Technology
[0002] In fields such as industrial quality inspection, medical imaging diagnosis, and security monitoring, data anomaly detection is a critical task. While traditional deep learning-based autoencoders (AEs) excel in feature extraction, they face challenges such as a massive number of parameters, high training computational costs, and inference latency when processing high-dimensional data.
[0003] Quantum computing, as an emerging computing paradigm, possesses inherent parallel advantages in processing high-dimensional vector space data due to its quantum superposition and entanglement properties. A quantum autoencoder (QAE) is a type of classical-quantum hybrid neural network (CQHNN) whose task is to map high-dimensional N-dimensional input quantum state data to a low-dimensional latent space, obtaining a K-dimensional compressed quantum state while retaining key features and removing unimportant ones, ultimately recovering the original high-dimensional quantum state from the low-dimensional representation. It uses classical machine learning optimization strategies to train, optimize, and iterate the parameters of the quantum autoencoder model to obtain the optimal parameter configuration for the most suitable quantum autoencoder. Current QAE research largely focuses on theoretical verification, lacking complete implementation plans for specific data anomaly detection tasks. Furthermore, besides classical high-dimensional data, there are currently no feasible industrial-grade technical solutions for processing already generated high-dimensional quantum state data.
[0004] Therefore, there is an urgent need for a novel data detection method based on quantum autoencoders that can efficiently extract dimensionality-reduced features from high-dimensional classical data and high-dimensional quantum state data, thereby simplifying the training cost of data anomaly detection, improving the accuracy and efficiency of data anomaly detection tasks, and achieving high-performance anomaly detection. Summary of the Invention
[0005] To address the problems existing in the prior art, the purpose of this invention is to provide a data anomaly detection method based on a quantum autoencoder, so as to realize the anomaly detection of classical high-dimensional data and high-dimensional quantum related data, and improve the anomaly detection speed and accuracy.
[0006] To achieve the above objectives, the present invention provides a data anomaly detection method based on a quantum autoencoder, comprising the following steps:
[0007] S1. Data Preprocessing: Obtain the original training dataset to be detected, perform grayscale conversion and resizing on the data, and normalize the resized data to generate a preprocessed training sample dataset; the original training dataset to be detected contains normal and abnormal samples; if the original data is directly quantum state data, this step is not required;
[0008] S2. Quantum State Mapping: Perform quantum state mapping on the preprocessed training sample dataset from step S1 to form N-dimensional quantum state data; if the original data is directly quantum state data, this step is not required.
[0009] S3. Construct a quantum autoencoder model: Construct a quantum autoencoder model, including parameters to be trained, to encode N-dimensional quantum state data into K-dimensional compressed quantum state data;
[0010] S4. Training the quantum autoencoder model: Using a classical machine learning training strategy, the N-dimensional normal sample quantum state data from the N-dimensional quantum state data in step S2 is input into the quantum autoencoder model part, and the target loss function is iteratively optimized to find the optimal training parameter configuration of the quantum autoencoder model.
[0011] S5. Calculation of anomaly detection threshold for quantum autoencoder: Input the N-dimensional quantum state data from step S2 into the trained quantum autoencoder to obtain NK-dimensional discarded quantum state data, and calculate the fidelity between the discarded quantum state data and the reference quantum state data; based on the fidelity result, perform preliminary selection of anomaly detection threshold and calculate the optimal threshold solution to obtain the calculated optimal discrimination threshold;
[0012] S6. Anomaly Detection: After processing the original verification dataset to be detected through steps S1 and S2, input it into the trained quantum autoencoder to obtain NK-dimensional discarded quantum state data. The original verification dataset to be detected contains normal and abnormal samples. Perform the steps in S5 to calculate the fidelity between the NK-dimensional discarded quantum state data and the reference quantum state, and compare it with the optimal discrimination threshold calculated in step S5. If the comparison result does not meet the preset normal range, the data is determined to be abnormal data; if it meets the preset normal range, the data is determined to be normal data.
[0013] Furthermore, in step S2, quantum state preparation technology is used to map classical data into quantum states that the quantum system can process; if the original data is directly quantum state data, this step is not required, and the quantum state data can be used directly.
[0014] Furthermore, classic data includes numerical, vector, matrix, or image data.
[0015] Furthermore, in step S3, the quantum autoencoder model contains adjustment parameters, and through the parameter training process in S4, different parameter value configurations are obtained to simulate the weight matrix configuration in a classical neural network.
[0016] Furthermore, in step S3, the quantum autoencoder model is a programmable optical quantum network, and its construction technology is a discrete device or an integrated cascaded Mach-Zehnder Interferometer (MZI) network or a cascaded micro-ring sequence.
[0017] Furthermore, in step S4, during the training of the quantum autoencoder model, the input quantum state dimension is N, the compressed quantum state dimension is K, and the discarded quantum state dimension is [missing information]. This study employs a classical machine learning training strategy, selecting appropriate iteration counts and gradient methods for the classical optimization algorithm to train and adjust the parameters of the quantum autoencoder model. The goal is to minimize the objective loss function, ensuring that after the K-dimensional quantum state passes through the quantum autoencoder model configured with these parameters, as much information as possible from the original quantum input state N is concentrated in the K-dimensional compressed quantum state. Minimize the information occupancy rate in the discarded quantum state when the loss function converges to 0 or close to 0. The output of the discarded quantum state is close to the vacuum state, and training is complete.
[0018] Furthermore, in step S6, the execution mode of anomaly detection is as follows: for the quantum state data output by the trained quantum autoencoder, a quantum measurement process is used to compare and calculate the measurement result with the optimal discrimination threshold for anomaly detection obtained in S5. If it meets the preset normal range, the data is determined to be normal data.
[0019] Furthermore, the quantum measurement process employs single-photon detection technology.
[0020] Furthermore, the quantum measurement process employs fidelity measurement technology.
[0021] On the other hand, the present invention provides a data anomaly detection system based on a quantum autoencoder, used to implement the method described according to the present invention, comprising: a preprocessing module for preprocessing the raw data to be detected and converting it into a normalized preprocessed feature vector; a quantum mapping module for mapping the preprocessed feature vector into quantum states; a quantum autoencoder model training module for performing training of the quantum autoencoder, taking minimizing the target loss function as the training objective, adjusting the model parameters, and obtaining the optimal model parameter configuration; an anomaly detection discrimination threshold calculation module for calculating and determining the optimal discrimination threshold; and an anomaly detection usage module for acquiring the output result of the trained quantum autoencoder and performing quantum measurement, comparing the measurement result with the optimal discrimination threshold, and outputting the anomaly detection result.
[0022] The beneficial effects of this invention are as follows:
[0023] (1) Using quantum properties to extract features and reduce dimensions of high-dimensional complex data. Quantum states have great advantages in representing and processing high-dimensional data. Quantum advantages can be used to improve the efficiency of data feature extraction, efficiently reduce data dimensions, avoid the computation and storage bottleneck caused by the curse of dimensionality in classical anomaly detection, and provide a new solution to the classical anomaly detection problem.
[0024] (2) In scenarios such as quantum communication and quantum sensing, anomaly detection can be performed directly on quantum states without converting them into classical data before anomaly detection, thereby reducing process complexity and information loss during the process;
[0025] (3) The construction of the quantum autoencoder model provides a great deal of freedom for the parameter training and model configuration scheme of the quantum autoencoder model;
[0026] (4) The quantum autoencoder model is trained using common classical machine learning training strategies, without the need to develop additional quantum machine learning methods;
[0027] (5) Since conventional quantum algorithms often encounter the barren plateau phenomenon during training, resulting in poor training effect, the probability of this problem increases with the increase of quantum state dimension. Therefore, by reducing the data dimension through quantum autoencoder and then training, better output performance can be obtained compared with quantum algorithms of the same dimension.
[0028] (6) On N qubits, it is possible to simultaneously represent The K-dimensional complex coefficient space far exceeds the capacity of a classical vector of the same size. The K-dimensional compressed quantum state after being compressed by a quantum autoencoder still retains the characteristics of the high-dimensional compressed space, and the anomaly detection process can utilize richer pattern information. Attached Figure Description
[0029] Figure 1 A flowchart illustrating the overall training and use of a quantum autoencoder-based data anomaly detection method;
[0030] Figure 2 The illustration uses image 0 from the MNIST dataset as an example to show the data results of normal data (before occlusion) and abnormal data (after occlusion) to be detected;
[0031] Figure 3 An example of a quantum autoencoder based on a programmable optical quantum network and its training flowchart;
[0032] Figure 4This is an example of a detection index in step anomaly detection, showing the fidelity distribution curves of the input and output quantum states for normal and abnormal data. Detailed Implementation
[0033] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0035] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0036] The following combination Figures 1-4 Specific embodiments of the present invention will be described in detail below. It should be understood that the specific embodiments described herein are for illustrative and explanatory purposes only and are not intended to limit the present invention.
[0037] According to a data anomaly detection method based on a quantum autoencoder of the present invention, taking image data type as an example, a programmable optical quantum network is used to realize the function of a programmable arbitrary-dimensional universal unitary matrix, thereby constructing a quantum autoencoder; at the same time, fidelity distribution curve calculation and subject operating characteristic curve are used as examples to realize the anomaly detection discrimination threshold comparison step and detection index; it includes the following steps:
[0038] S1. Data Preprocessing: Obtain the original training dataset to be detected, perform grayscale processing and size adjustment on the data, and normalize the adjusted data to generate a preprocessed training sample dataset; the original training dataset to be detected contains normal and abnormal samples; if the original data is directly quantum state data, this step is not required;
[0039] S2. Quantum state mapping: Perform quantum state mapping on the preprocessed training sample dataset described in step S1 to form N-dimensional quantum state data; if the original data is directly quantum state data, this step is not required;
[0040] S3. Construct a quantum autoencoder model: Construct a quantum autoencoder model, containing parameters to be trained, to encode N-dimensional quantum state data into K-dimensional compressed quantum state data;
[0041] S4. Training the quantum autoencoder model: Using a classical machine learning training strategy, the N-dimensional normal sample quantum state data from the N-dimensional quantum state data described in step S2 is input into the quantum autoencoder model part, and the target loss function is iteratively optimized to find the optimal training parameter configuration of the quantum autoencoder model;
[0042] S5. Calculation of anomaly detection threshold for quantum autoencoder: Input the N-dimensional quantum state data described in step S2 into the trained quantum autoencoder to obtain NK-dimensional discarded quantum state data, and calculate the fidelity between the discarded quantum state data and the reference quantum state data; based on the fidelity result, perform preliminary selection of anomaly detection threshold and calculate the optimal threshold solution to obtain the calculated optimal discrimination threshold;
[0043] S6. Anomaly Detection: After processing the original verification dataset to be detected through steps S1 and S2, input it into the trained quantum autoencoder to obtain NK-dimensional discarded quantum state data. The original verification dataset to be detected contains normal and abnormal samples. Perform the steps in S5 to calculate the fidelity between the NK-dimensional discarded quantum state data and the reference quantum state, and compare it with the optimal discrimination threshold calculated in step S5. If the comparison result does not meet the preset normal range, the data is determined to be abnormal data; if it meets the preset normal range, the data is determined to be normal data.
[0044] Specifically, in step S1, data preprocessing, this embodiment uses handwritten digit images from the MINIST dataset as the dataset. To adapt to the scale of current programmable quantum networks and accelerate the training process, the image data is preprocessed: the image pixel resolution is cropped from 28 × 28 to 8 × 8 as preprocessed training data, such as... Figure 2As shown, taking the handwritten digit image 0 as an example, this paper demonstrates the results of preprocessing training data by cropping the image pixel resolution from 28 × 28 to 8 × 8. The image on the left is the preprocessed data of normal samples, while the image on the right is the preprocessed data of abnormal samples generated by occluding one row and one column. As the scale of the programmable photonic quantum network increases, this method can be directly extended to the preprocessing of image data with higher pixel resolution.
[0045] Step S2, quantum state mapping, involves flattening the clipped preprocessed data into a one-dimensional vector. To satisfy the input characteristics of an N-dimensional programmable optical quantum network (e.g., N=64), quantum state mapping is required: the clipped preprocessed data is concatenated and flattened row by row into a classical row vector of 64 elements. Quantum states are prepared using encoding methods such as amplitude encoding and angle encoding, and mapped to N-dimensional quantum state data. It contains both normal and abnormal samples; taking amplitude encoding as an example, the specific mapping implementation of step S2 is as follows:
[0046] For a classical row vector of length N as shown in formula (1) Amplitude encoding maps it to N-dimensional quantum state data as shown in formula (2). Subsequently, the N-dimensional quantum state data In this context, a quantum data state containing normal samples is called a quantum data state. A quantum data state containing anomalous samples is called a quantum data state. Among them, the selection A portion of the data was used as the training dataset. The remainder will be used as the test dataset. ;Will A portion of the data was used as the training dataset. The remainder will be used as the test dataset. ;Will A portion of it was used as the training dataset. The remainder will be used as the test dataset. ;
[0047] (1)
[0048] (2)
[0049] in, , indicating the ground state The complex probability amplitude; , representing a classic row vector The Euclidean norm, This represents a classic row vector after the preprocessed data has been clipped, concatenated, and flattened. Represents row vectors The first in Each data element.
[0050] Step S3: Constructing a quantum autoencoder model. Taking a programmable optical quantum network as an example, a quantum autoencoder model based on a programmable optical quantum network is constructed. This model consists of a cascaded Mach-Zehnder interferometer (MZI) network, with each MZI unit containing two tunable phase shifters (PS). By combining a series of MZIs and configuring their tunable phase shifter sets, an arbitrary-dimensional universal unitary matrix can be achieved, thus forming a programmable optical quantum network. The beam splitting ratio of the MZI beam splitters (BS) in the network can generally be fixed at 50:50, and the tunable phase shifters can provide the phase set. Φ, as adjustable parameters of the programmable optical quantum network, participate in the training of the quantum autoencoder model; a schematic diagram of the training process of the quantum autoencoder model based on the programmable optical quantum network is attached. Figure 3 As shown, a classic machine learning training strategy is employed, adjusting the phase set by minimizing the target loss function. By determining the specific values in Ф, an optimal configuration of programmable optical quantum network parameters can be obtained, thus leading to the most suitable quantum autoencoder model.
[0051] Step S4: Train the quantum autoencoder model, as shown in the attached diagram. Figure 1 As shown, during the training phase of the quantum autoencoder model, as described in step S3, a quantum state training dataset containing only normal samples is selected. Input the quantum autoencoder model to be trained; define the quantum state data to be output as K=48 dimensions, where the discarded quantum state is NK=16 dimensions; set the training objective loss function to minimize the expected value of the projection of the 16-dimensional discarded quantum state; use a classical machine learning training strategy, preferably a half-way training strategy, to train the quantum autoencoder model, continuously adjusting the parameter set of the quantum autoencoder model described in step S3. The values of Ф are used to obtain the target loss function value that is minimized. When the loss function converges to 0 or close to 0, it means that the output of the 16-dimensional discarded quantum state is close to the vacuum state, the training is completed, and the trained quantum autoencoder is obtained.
[0052] Step S5. Calculate the anomaly detection threshold for the quantum autoencoder. As described in step S3, select the quantum state training dataset of normal samples. Quantum state training dataset of anomalous samples The data are input into the trained quantum autoencoder from step S4 to obtain the output NK-dimensional compressed discarded quantum state data; anomaly detection threshold calculation is performed, for example, calculating the fidelity between the output NK-dimensional discarded quantum state and the NK-dimensional reference quantum state, where the NK-dimensional reference quantum state can be selected as... The quantum states of the normal samples are calculated sequentially in the training dataset. Quantum state training dataset of anomalous samples The set of fidelity results for all sample data in the dataset Optimal discrimination threshold The calculation and determination of mainly involve the following steps:
[0053] ① Taking the traversal method as an example, it can be found that... A temporary threshold is set within the interval with a step size of 0.01. The initial selection is based on this temporary discrimination threshold. For each fidelity value in the fidelity result set F Compare;
[0054] ②When Then the fidelity value The corresponding quantum state training data It will be classified as a normal quantum state. If at this time, this quantum state... If the quantum state is indeed a normal quantum state in the original dataset, then the judgment is correct and is defined as a true positive (TP) judgment; otherwise, if the quantum state is not a normal quantum state, then the judgment is correct and is defined as a true positive (TP) judgment. If an abnormal quantum state exists in the original dataset, then this judgment is incorrect and is defined as a false positive (FP) judgment.
[0055] ③ Similarly, when Then the This will be classified as an anomalous quantum state. If the quantum state is indeed an anomalous quantum state in the original dataset, then the judgment is correct and defined as a true positive. Otherwise, if the quantum state is not an anomalous quantum state, then the judgment is incorrect. If the quantum state is a normal state in the original dataset, then this judgment is incorrect and is defined as a false positive.
[0056] ④ Obtain each fidelity value in the fidelity result set F. The corresponding true positive or false positive results can be statistically calculated to obtain the overall true positive rate (TPR) and false positive rate (FPR).
[0057] ⑤ For each temporary discrimination threshold By following steps ①-④, the corresponding true positive probability can be obtained. and false positive probability ;
[0058] ⑥ Optimize the objective function based on the threshold, and calculate the deviation between the measured decision rate and the ideal decision, such as the distance value in the Euclidean distance calculation formula. ,in and This can represent the ideal accuracy rate of the judgment, and can take values of 0 and 1 respectively. The temporary threshold corresponding to the minimum value. That is, it is identified as the optimal discrimination threshold. Complete the calculation and determination of the discrimination threshold.
[0059]
[0060] Step S6 Anomaly Detection, such as Figure 1 As shown, during the detection process, the validation dataset is first preprocessed and loaded into quantum states according to the procedures described in steps S1 and S2. Then, the N-dimensional test quantum state data is input into the trained quantum autoencoder to obtain the NK-dimensional discarded quantum state. The set of test data fidelity results between the NK-dimensional discarded quantum state and the NK-dimensional reference state is calculated. Here, the NK-dimensional reference quantum state can be selected. State; Perform the threshold comparison process: A direct comparison method can be used to compare the fidelity results of the test data set. Each fidelity value in To make a direct comparison, The value is lower than the optimal discrimination threshold obtained in step S5. When, then the fidelity value The corresponding original verification data was judged as anomalous data; if Above the threshold If the original verification data corresponding to the fidelity value is determined to be normal data, the detection of abnormal results is completed.
[0061] In step S1, the dataset used in the experiment of the quantum autoencoder anomaly detection method is the MNIST dataset. This does not mean that this anomaly detection algorithm can only be applied to the MNIST dataset. Users can customize the dataset they want to apply it to. Also, in this example, the definition of normal and abnormal data is whether there is occlusion. This does not mean that this anomaly detection algorithm can only be applied to this type of occlusion. Users can customize the occlusion method.
[0062] In step S2, in addition to amplitude encoding, methods for mapping row vectors to quantum states include angle encoding and path encoding. Different encoding methods determine the complexity of quantum state preparation and the required quantum resources (such as the number of qubits or optical modes), but do not affect the overall approach of this algorithm.
[0063] Although the embodiments of the present invention are illustrated using amplitude encoding as an example, those skilled in the art should understand that, depending on actual hardware conditions (such as the number of qubits, the scale of photonic chips, and quantum technology paths), the above-mentioned angle encoding, path encoding, or a hybrid encoding method can all be applied to step S2 of the present invention, which does not deviate from the technical solution of the present invention.
[0064] In step S3, when constructing the quantum autoencoder model, a Reck-type or Clements-type programmable optical quantum network can be used. This invention preferably uses a Reck-type programmable optical quantum network. Any unitary matrix can be decomposed and realized through a series of MZIs, providing an efficient and feasible hardware architecture for optical quantum computing and optical neural networks, which is beneficial for application in different computational processes. For any unitary matrix, it can be decomposed into the product of multiple rotation matrices and phase shift matrices as shown in equation (3):
[0065] (3)
[0066] in, This is the final phase shift matrix, used to adjust the optical phase, and its expression is shown in equation (4). yes Givens rotation matrix, implemented by MZI.
[0067] (4)
[0068] Among them, the non-zero elements on the diagonal (n=1,2,…,N), representing the transfer functions of the N phase shifters located before the output port of the optical quantum network.
[0069] In step S4, a half-way training strategy can be used to train the quantum autoencoder. This strategy implicitly optimizes the compression fidelity by maximizing the probability that discarded qubits at the encoder output are in the ground state, thereby significantly reducing the quantum circuit depth and noise impact. The goal of the quantum autoencoder is to compress N-dimensional quantum states to K-dimensional states. M N-dimensional quantum states are used for training. The quantum autoencoder randomly receives these quantum states with equal probability, and the resulting density matrix is shown in equation (5).
[0070] (5)
[0071] Where M is the total number of quantum states, For the first A quantum state, for The conjugate transpose of .
[0072] Transform the density matrix into the diagonal form shown in equation (6):
[0073] (6)
[0074] in, This represents the quantum state dimension, which also corresponds to the total number of eigenvectors. For the first orthogonal eigenvectors for The conjugate transpose of . Let be the probability of the corresponding eigenvector. The projection of the discarded quantum state is shown in equation (7):
[0075] (7)
[0076] Where K is the dimension of the compressed quantum state. To discard the dimension of the quantum state, The reference state used for discarding quantum states. for The conjugate transpose of . It is a K-dimensional identity matrix.
[0077] By maximizing the projection P, the occupancy rate of discarded quantum states is minimized, ensuring that as much information from the original input state as possible is contained in the K-dimensional compressed states. The training principle diagram of the quantum autoencoder based on a programmable optical quantum network is attached. Figure 3 As shown. The N-dimensional quantum state input includes adjustable parameters. Programmable optical quantum networks of Ф In this process, the expected value of the projection of the discarded quantum state is used as the objective function, as shown in Equation (8). A classical machine learning optimization strategy is adopted, and the optimization is performed by continuously adjusting the... By minimizing the values of Ф and the objective function, efficient compression of quantum states can be achieved.
[0078] (8)
[0079] in, Let be the objective function. For the set of tunable parameters in optical quantum networks, This is a linear algebra operation, representing the sum of the diagonal elements of a matrix. For projection operators, For parameters The operation matrix of the input state in a programmable optical quantum network for The conjugate transpose of .
[0080] Calculate the fidelity set of all sample data in the quantum state training dataset of normal samples and the quantum state training dataset of abnormal samples in turn. , The calculation is shown in equation (9):
[0081]
[0082] in, For the i-th original input state, For programmable optical quantum networks, These are tunable parameters in optical quantum networks. (Collection) Each fidelity value in The closer it is to 1, the higher the fidelity, and the less information loss.
[0083] This invention discloses a data anomaly detection method based on a quantum autoencoder, the advantages of which are:
[0084] (1) Using quantum properties to extract features and reduce dimensions of high-dimensional complex data. Quantum states have great advantages in representing and processing high-dimensional data. Quantum advantages can be used to improve the efficiency of data feature extraction, efficiently reduce data dimensions, avoid the computation and storage bottleneck caused by the curse of dimensionality in classical anomaly detection, and provide a new solution to the classical anomaly detection problem.
[0085] (2) In scenarios such as quantum communication and quantum sensing, anomaly detection can be performed directly on quantum states without converting them into classical data before anomaly detection, thereby reducing process complexity and information loss during the process;
[0086] (3) The construction of the quantum autoencoder model provides a great deal of freedom for the parameter training and model configuration scheme of the quantum autoencoder model;
[0087] (4) The quantum autoencoder model is trained using common classical machine learning training strategies, without the need to develop additional quantum machine learning methods;
[0088] (5) Since conventional quantum algorithms often encounter the barren plateau phenomenon during training, resulting in poor training effect, the probability of this problem increases with the increase of quantum state dimension. Therefore, by reducing the data dimension through quantum autoencoder and then training, better output performance can be obtained compared with quantum algorithms of the same dimension.
[0089] (6) On N qubits, it is possible to simultaneously represent The K-dimensional complex coefficient space far exceeds the capacity of a classical vector of the same size. The K-dimensional compressed quantum state after being compressed by a quantum autoencoder still retains the characteristics of the high-dimensional compressed space, and the anomaly detection process can utilize richer pattern information.
[0090] Any process or method described in the flowcharts of this invention or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, which can be implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device. The computer-readable medium can be any medium containing a program for storage, communication, propagation, or transmission for use by the execution system, apparatus, or device, including read-only memory, magnetic disks, or optical disks.
[0091] In the description of this specification, references to terms such as "embodiment," "example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, those skilled in the art can combine or combine the different embodiments or examples described in this specification and the features therein without causing contradiction.
[0092] While embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and alterations to the above embodiments within the scope of the present invention.
Claims
1. A method for data anomaly detection based on quantum autoencoder, characterized in that, Includes the following steps: S1. Data Preprocessing: Obtain the original training dataset to be detected, perform grayscale conversion and size adjustment on the data, and normalize the adjusted data to generate a preprocessed training sample dataset; the original training dataset to be detected contains normal and abnormal samples; the data is image data; S2. Quantum state mapping: Perform quantum state mapping on the preprocessed training sample dataset from step S1 to form N-dimensional quantum state data; S3. Construct a quantum autoencoder model: Construct a quantum autoencoder model, containing parameters to be trained, to encode N-dimensional quantum state data into K-dimensional compressed quantum state data; S4. Training the quantum autoencoder model: Using a classical machine learning training strategy, the N-dimensional normal sample quantum state data from the N-dimensional quantum state data in step S2 are input into the quantum autoencoder model. The target loss function is iteratively optimized to find the optimal training parameter configuration for the quantum autoencoder model. M N-dimensional quantum states are used for training, and the quantum autoencoder randomly receives these quantum states with equal probability. The resulting density matrix is as follows: ; And then transform the density matrix into diagonal form: ; The compression fidelity is implicitly optimized by maximizing the probability that discarded qubits at the encoder output are in the ground state. The projection of the discarded qubits is: ; By maximizing the projection P, the occupancy rate of discarded quantum states is minimized, and the objective function is minimized. To achieve efficient compression of quantum states: ; Where M is the total number of quantum states, For quantum state dimension, For the first A quantum state, for The conjugate transpose of . For the first orthogonal eigenvectors for The conjugate transpose of . represents the probability of the corresponding eigenvector; K is the dimension of the compressed quantum state. To discard the dimension of the quantum state, The reference state used for discarding quantum states. for The conjugate transpose of . It is a K-dimensional identity matrix; For the set of tunable parameters in optical quantum networks, It is the sum of the diagonal elements of the matrix. For parameters The operation matrix of the input state in a programmable optical quantum network for The conjugate transpose of; S5. Anomaly detection threshold calculation for quantum autoencoder: Input the N-dimensional quantum state data from step S2 into the trained quantum autoencoder to obtain NK-dimensional discarded quantum state data, and calculate the fidelity between the discarded quantum state data and the reference quantum state data; sequentially calculate the fidelity result set of all sample data for normal samples, and the fidelity value. The calculation formula is: ; in, For the i-th original input state, For programmable optical quantum networks, For adjustable parameters in optical quantum networks, It is a K-dimensional identity matrix; Based on the fidelity results, the anomaly detection threshold is initially selected and the optimal threshold solution is calculated to obtain the calculated optimal discrimination threshold. S6. Anomaly Detection: After processing the original verification dataset to be detected through steps S1 and S2, input it into the trained quantum autoencoder to obtain NK-dimensional discarded quantum state data. The original verification dataset to be detected contains normal and abnormal samples. Calculate the fidelity between the NK-dimensional discarded quantum state data and the reference quantum state, and compare it with the optimal discrimination threshold calculated in step S5. If the comparison result does not meet the preset normal range, the data is determined to be abnormal data; if it meets the preset normal range, the data is determined to be normal data.
2. The method according to claim 1, characterized in that, In step S3, the quantum autoencoder model contains adjustment parameters. Through the parameter training process in S4, different parameter value configurations are obtained to simulate the weight matrix configuration in a classical neural network.
3. The method of claim 1, wherein, In step S3, the quantum autoencoder model is a programmable optical quantum network, which is constructed using discrete devices or integrated cascaded Mach-Zehnder interferometer networks or cascaded micro-ring sequences.
4. The method of claim 1, wherein, In step S4, during the training of the quantum autoencoder model, the input quantum state dimension is N, the compressed quantum state dimension is K, and the discarded quantum state dimension is [missing information]. Using a classical machine learning training strategy, and selecting appropriate classical optimization algorithm iterations and gradient methods, the parameters of the quantum autoencoder model are trained and adjusted to minimize the target loss function. This ensures that after the K-dimensional quantum state passes through the quantum autoencoder model configured with these parameters, the information from the original quantum input state N is concentrated in the K-dimensional compressed quantum state, thus... Minimize the information occupancy rate in the discarded quantum state when the loss function converges to 0 or close to 0. The output of the discarded quantum state is close to the vacuum state, and training is complete.
5. The method according to claim 1, characterized in that, In step S6, the execution mode of anomaly detection is as follows: for the quantum state data output by the trained quantum autoencoder, a quantum measurement process is used to compare the measurement result with the optimal discrimination threshold for anomaly detection obtained in S5. If it meets the preset normal range, the data is determined to be normal data.
6. The method of claim 4, wherein, The quantum measurement process employs single-photon detection technology.
7. The method according to claim 4, characterized in that, The quantum measurement process employs fidelity measurement techniques.