Quantum algorithm generation method and device based on image recognition, and quantum computing system
Through the quantum algorithm generation method based on image recognition, quantum circuit diagrams are identified and generated and converted into waveform parameter information of quantum measurement and control signals, the problem of manually operating quantum circuit diagrams in the prior art is solved, and high automation and scalability quantum algorithm generation is realized.
Patent Information
- Application Number
- CN202411999767.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-13
AI Technical Summary
In the existing quantum computing process, the quantum circuit diagram needs to be manually operated, which has low automation and poor scalability.
Using a quantum algorithm generation method based on image recognition, by obtaining the quantum algorithm images submitted by the user, using the image recognition algorithm to identify the quantum algorithm information, determine the arrangement position of the quantum gate, generate a quantum circuit map, and convert it into waveform parameter information used to generate quantum measurement and control signals.
The automatic generation of quantum algorithms is realized without manual operations, which improves the degree of automation, and can identify various types of quantum algorithm images, which is highly scalable.
Smart Images

Figure CN119990352A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a quantum algorithm generation method and device based on image recognition, and a quantum computing system. Background Art
[0002] Quantum algorithms are the core of the field of quantum computing. Quantum algorithms can use the characteristics of quantum mechanics to solve problems that are difficult for classical computers to handle. Unlike classical algorithms, quantum algorithms rely on the superposition and entanglement of quantum bits, and can achieve exponential acceleration on certain problems. At present, when performing quantum computing, if a superconducting quantum algorithm needs to be input into a superconducting quantum computer, it is generally done manually by dragging a quantum circuit diagram on the superconducting quantum computer platform. This method is based on the existing circuit elements on the quantum computer and has great limitations. In addition, it requires manual operation, which is cumbersome to operate, inconvenient, and has a low degree of automation. Summary of the invention
[0003] In view of the above problems, the present invention is proposed to provide a quantum algorithm generation method and device based on image recognition, and a quantum computing system that overcomes the above problems or at least partially solves the above problems.
[0004] An embodiment of the present invention provides a quantum algorithm generation method based on image recognition, comprising:
[0005] Get quantum algorithm images submitted by users;
[0006] Using an image recognition algorithm, identifying quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image;
[0007] According to the characters and character position information in the image, the arrangement position of the quantum gate corresponding to each character in the image is determined, and a quantum circuit diagram is generated based on the quantum gate corresponding to each character and its arrangement position;
[0008] The quantum gates in the quantum circuit diagram are converted into waveform parameter information for generating quantum measurement and control signals and sent to the quantum computer.
[0009] In some optional embodiments, the using an image recognition algorithm to identify quantum algorithm information in the quantum algorithm image includes:
[0010] Extracting character features from the quantum algorithm image, and identifying characters in the quantum algorithm image based on the extracted character feature information;
[0011] For each recognized character, a classification algorithm is used to classify the character based on the character feature information, and according to the classification result, it is determined whether the recognized character belongs to a specific character in a specific character library;
[0012] If it is a specific character, the character position information of the specific character is obtained according to the position where the specific character appears in the quantum algorithm image.
[0013] In some optional embodiments, the character feature information includes at least one of character edge feature information, character structure feature information and local shape feature information;
[0014] The position information includes the arrangement position of the characters in the quantum algorithm image, the column spacing of characters in the same row, and the row spacing of characters in the same column.
[0015] In some optional embodiments, extracting character features from the quantum algorithm image includes performing at least one of the following character feature extraction operations:
[0016] Performing character edge detection on the quantum algorithm image to extract character edge feature information;
[0017] Using the Hough transform method, extracting the character structure feature information in the quantum algorithm image; the character structure information includes at least one of a straight line structure and a curve structure;
[0018] Using a scale-invariant feature conversion method or a directional gradient histogram method, local feature detection is performed on the quantum algorithm image to extract local shape feature information of the character;
[0019] The step of identifying characters in the quantum algorithm image based on the extracted character features includes:
[0020] Based on at least one of the character edge feature information, the character structure feature information and the local shape feature information, the character included in the quantum algorithm image is determined.
[0021] In some optional embodiments, the classifying the characters using a classification algorithm based on the character feature information includes:
[0022] According to the character feature information, a machine learning method is used to find the optimal classification boundary from the character feature space, and the character classification is determined according to the optimal classification boundary.
[0023] In some optional embodiments, obtaining the character position information of the specific character according to the position where the specific character appears in the quantum algorithm image includes:
[0024] Determine the row position of the first row of characters and the column position of the first column of characters according to the occurrence position of the recognized specific character;
[0025] Determine the row position of each row, the specific characters included in each row, and the column position of each specific character in each row according to the row position of the first row of characters, the column position of the first column of characters, and the appearance position of each specific character;
[0026] According to the row position of each row, the specific characters included in each row and the column position of each specific character in each row, the column spacing of characters in the same row and the row spacing of characters in the same column are determined to obtain character position information including the character arrangement position, the column spacing of characters in the same row and the row spacing of characters in the same column; the character arrangement position includes the row and column where the character is located.
[0027] In some optional embodiments, determining the row position of the first row of characters and the column position of the first column of characters according to the recognized occurrence position of the specific character includes:
[0028] The position of the first occurrence of a specific character from top to bottom is determined as the row position of the first row of characters;
[0029] The position of the first occurrence of a specific character from left to right is determined as the column position as the first column character.
[0030] In some optional embodiments, according to the characters and character position information in the image, determining the quantum gates and their arrangement positions corresponding to the characters in the image, and generating a quantum circuit diagram based on the quantum gates and their arrangement positions, includes:
[0031] Determine the placement of the quantum gate corresponding to each character in the circuit grid according to the characters and their arrangement positions in the image, as well as the column spacing of characters in the same row and the row spacing of characters in the same column;
[0032] Construct the corresponding quantum gate according to each character, add the quantum gate corresponding to each character to the corresponding circuit grid according to the placement position, connect each quantum gate in sequence to obtain a quantum circuit diagram.
[0033] In some optional embodiments, constructing a corresponding quantum gate according to each character includes:
[0034] Determine whether the quantum gate corresponding to the character belongs to the quantum gate that can be directly generated by the quantum bit;
[0035] If it meets the requirements, the corresponding quantum gate is directly generated;
[0036] If it does not match, the quantum gate corresponding to the character is split to generate the split quantum gate.
[0037] In some optional embodiments, the method further comprises: preprocessing the image; the preprocessing comprises at least one of the following processes:
[0038] Convert color images to grayscale images;
[0039] Convert grayscale images to black and white images;
[0040] Filter the image;
[0041] Perform tilt correction on the image;
[0042] Perform character segmentation on the string in the image.
[0043] An embodiment of the present invention provides a method for implementing quantum computing, including:
[0044] The above-mentioned quantum algorithm generation method is used to generate waveform parameter information for generating a quantum measurement and control signal, and the waveform parameter information is sent to a quantum computer; so that the quantum computer generates a quantum measurement and control signal based on the waveform parameter information, and the quantum measurement and control signal is sent to a quantum bit in a quantum processor;
[0045] Obtain a calculation result of the quantum bit after performing quantum calculation based on the quantum measurement and control signal, and generate a projection probability and density matrix based on the calculation result.
[0046] An embodiment of the present invention provides a quantum algorithm generation device based on image recognition, comprising:
[0047] An image recognition module is used to obtain a quantum algorithm image submitted by a user; use an image recognition algorithm to recognize quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image;
[0048] The computing module is used to determine the arrangement position of the quantum gates corresponding to each character in the image according to the characters and character position information in the image, generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions; convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send it to the quantum computer.
[0049] The embodiment of the present invention provides a quantum computing system, comprising: a quantum algorithm generation device based on image recognition and a quantum computer; the quantum algorithm generation device based on image recognition comprises an image recognition module and a computing module; the quantum computer comprises a measurement and control module and a quantum processor;
[0050] The image recognition module is used to obtain a quantum algorithm image submitted by a user; use an image recognition algorithm to recognize quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image;
[0051] The calculation module is used to determine the arrangement position of the quantum gates corresponding to each character in the image according to the characters and character position information in the image, and generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions; convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send them to the quantum computer; and generate a projection probability and density matrix based on the calculation results fed back by the measurement and control module;
[0052] The measurement and control module is used to generate a quantum measurement and control signal based on the waveform information, send the quantum measurement and control signal to the quantum bit in the quantum processor in the quantum computer, obtain the calculation result of the quantum bit after quantum calculation based on the quantum measurement and control signal, and feed it back to the calculation module.
[0053] An embodiment of the present invention provides a computer storage medium, in which computer executable instructions are stored. When the computer executable instructions are executed by a processor, the above-mentioned quantum algorithm generation method based on image recognition and / or the above-mentioned quantum computing implementation method are implemented.
[0054] An embodiment of the present invention provides a quantum computing cloud platform, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned image recognition-based quantum algorithm generation method and / or the above-mentioned quantum computing implementation method when executing the program.
[0055] The beneficial effects of the above technical solution provided by the embodiment of the present invention include at least:
[0056] The quantum algorithm generation method based on image recognition provided by the embodiment of the present invention can recognize the quantum algorithm image submitted by the user to obtain the quantum algorithm information in the image, determine the arrangement position of the quantum gate corresponding to the character based on the obtained quantum algorithm information, automatically generate the quantum gate corresponding to the character and arrange and connect it according to its arrangement position to form an electronic circuit diagram; based on the generated quantum circuit diagram, the quantum gate therein is converted into waveform parameter information for generating quantum measurement and control signals, so that the quantum computer generates quantum measurement and control signals based on the waveform parameter information. This method can realize the automatic generation of quantum algorithms without manual operation, has a high degree of automation, can recognize various types of quantum algorithm images, and has strong scalability.
[0057] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0058] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0060] Figure 1 This is a flow chart of a method for generating a quantum algorithm based on image recognition in Embodiment 1 of the present invention.
[0061] Figure 2 This is an example flowchart of the quantum algorithm picture in the first embodiment of the present invention.
[0062] Figure 3 illustrative diagram of some types of quantum logic gates in the first embodiment of the present invention.
[0063] Figure 4 This is an example diagram of a quantum circuit diagram generated in Example 1 of the present invention.
[0064] Figure 5 This is an example diagram of another quantum circuit diagram generated in the first embodiment of the present invention.
[0065] Figure 6 This is an example diagram of the waveform function converted in the first embodiment of the present invention.
[0066] Figure 7 This is a flow chart of a method for generating a quantum algorithm based on image recognition in Embodiment 2 of the present invention.
[0067] Figure 8 This is a flow chart of the method for implementing quantum computing in Embodiment 3 of the present invention.
[0068] Fig. 9 2 is a diagram showing an example of projection probability in an embodiment of the present invention.
[0069] Fig.10 Schematic diagram of density matrix in an embodiment of the present invention.
[0070] Fig.11 Schematic diagram of the structure of a quantum algorithm generation device based on image recognition in Embodiment 4 of the present invention.
[0071] Fig.12 Schematic diagram of the structure of the quantum computing system in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0072] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0073] In order to solve the problems existing in the quantum computing process of the prior art, such as the need for manual operation, low degree of automation, and poor scalability, the embodiment of the present invention provides a quantum algorithm generation method based on image recognition. In view of the limitations of the algorithm input of various quantum computing platforms, a tool for automatically generating quantum algorithms through uploaded pictures is provided, and the image recognition algorithm is introduced into the quantum computing platform to identify the quantum algorithm in the handwritten or electronic version of the quantum algorithm picture uploaded by the user, and the quantum algorithm is converted into waveform parameter information for controlling the quantum bit, and then the waveform parameter information is transmitted to the quantum computer to perform the corresponding operation. This method can automatically generate quantum algorithms without manual operation, can improve the scalability of algorithm input, and allow users to submit quantum computing experiments more freely. The quantum computing platform in this application is for example, but not limited to, a superconducting quantum computing platform, a semiconductor quantum computing platform, an ion trap quantum computing platform, etc. The following description takes the superconducting quantum computing platform as an example.
[0074] Embodiment 1
[0075] Embodiment 1 of the present invention provides a method for generating a quantum algorithm based on image recognition. The method can be implemented on a quantum computing cloud platform. The process is as follows: Figure 1 As shown, the following steps are included:
[0076] S101: Obtain a quantum algorithm image submitted by a user.
[0077] S102: Using an image recognition algorithm, identify quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image. This step implements parsing the quantum algorithm that the user expects to implement.
[0078] S103: According to the characters and character position information in the image, determine the arrangement position of the quantum gates corresponding to each character in the image; generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement position. This step realizes the presentation of the quantum algorithm that the user expects to implement in the form of a circuit diagram, which can be confirmed by the user.
[0079] S104: Convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send the information to the quantum computer, so that the quantum computer can generate quantum measurement and control signals based on the waveform parameter information.
[0080] Optionally, in one embodiment, in a superconducting quantum computer, the quantum measurement and control signal includes a quantum bit frequency modulation signal (commonly referred to as a Z signal) and a quantum bit drive signal (commonly referred to as an XY signal), wherein the Z signal is used to adjust the frequency of the quantum bit (that is, to adjust the energy level interval of the quantum bit), and the XY signal is used to drive the quantum bit to switch between the ground state |0> and the excited state |1>. Specifically, by applying a medium-frequency Z signal and a high-frequency XY signal whose frequency is close to the quantum bit energy level interval, the quantum bit can be made to oscillate between the ground state |0> and the excited state |1>, thereby realizing various quantum logic gates. The precise control of the two signals, the XY signal and the Z signal, is crucial to the successful implementation of quantum computing and quantum information processing. The frequency range of the Z signal is, for example, but not limited to, 0 to 500 MHz, and the frequency range of the XY signal is, for example, but not limited to, 4 GHz to 6 GHz.
[0081] However, alternatively, in other suitable types of quantum computers such as semiconductor quantum computers, the quantum measurement and control signal corresponds to a corresponding signal, and the present application does not impose any limitation on this.
[0082] The quantum algorithm image obtained in the above step S101 can be a photo or scanned image of a quantum algorithm circuit diagram hand-drawn by the user, or a photo or scanned image of other printed quantum algorithm circuit diagrams. The user uploads the quantum algorithm image through the human-computer interaction interface, and uploads the quantum algorithm image that the user expects to test to the quantum computing cloud platform through the image interface. The quantum algorithm image can be an image in a .jpg or .png format containing the quantum algorithm. For example, a quantum algorithm image submitted such as Figure 2 Shown is a hand-drawn image of a quantum algorithm.
[0083] In the above step S102, using an image recognition algorithm to identify quantum algorithm information in the quantum algorithm image includes:
[0084] 1) Extracting character features from the quantum algorithm image, and identifying characters in the quantum algorithm image based on the extracted character feature information; wherein the character feature information includes at least one of character edge feature information, character structure feature information, and local shape feature information.
[0085] After the user submits the quantum algorithm image, the quantum algorithm circuit diagram in the quantum algorithm image can be recognized, such as but not limited to optical character recognition (OCR) recognition. Feature extraction is the core step of character recognition. In this step, the computer will extract the unique features of the characters for subsequent classification. Character feature extraction of the quantum algorithm image includes performing at least one of the following character feature extraction operations:
[0086] (a) Perform Canny Edge Detection on the quantum algorithm image to extract the edge feature information of the character. Edge recognition can extract the edge contour of the character to obtain the shape information of the character. The characters can include letters, Chinese characters, and other types of characters.
[0087] (b) extracting character structure feature information from the quantum algorithm image using a Hough transform method; the character structure information includes at least one of a straight line structure and a curve structure;
[0088] Hough Transform can detect straight and curved structures in an image and help recognize the shapes of letters.
[0089] (c) Using the scale-invariant feature transformation method or the oriented gradient histogram method, local feature detection is performed on the quantum algorithm image to extract the local shape feature information of the characters.
[0090] Scale-Invariant Feature Transform (SIFT) and Histogram of Oriented Gradients (HOG) can detect local shape features in images, describe local features through feature points, and obtain local feature descriptors. These feature descriptors can be used to extract local shape information of characters, especially for character recognition in complex or low-quality images.
[0091] Recognizing characters in the quantum algorithm image based on the extracted character features includes: determining the characters included in the quantum algorithm image based on at least one of character edge feature information, character structure feature information and local shape feature information.
[0092] 2) For each recognized character, a classification algorithm is used to classify the character based on the character feature information, and according to the classification result, it is determined whether the recognized character belongs to a specific character in a specific character library.
[0093] After extracting the features in the image, a classification algorithm is needed to identify specific characters. Character classification can be achieved by selecting a classification algorithm, such as but not limited to a machine learning method. Machine learning methods, such as but not limited to, use a support vector machine (SVM) to identify characters by finding the optimal classification boundary in the feature space. When using a machine learning method, based on the character feature information, a machine learning method is used to find the optimal classification boundary in the character feature space, and the character classification is determined based on the optimal classification boundary.
[0094] When performing character recognition, the above methods can be used alone or in combination. For example, the combination of SVM and edge detection can accurately extract the letters of the uploaded image. Another example is the combination of SVM and Hough transform, which can accurately distinguish specific patterns. In quantum circuits, the symbols of quantum gates are letters and symbols of specific shapes. Therefore, the recognized characters can include letters and symbols of specific shapes.
[0095] Optionally, a specific character library may be pre-built to store recognizable quantum gate types and their corresponding characters, e.g. Figure 3 As shown, H, I, X, Y, Z, U, Rx, Ry, Rz, CNOT, CZ, The specific character library can be updated and supplemented at any time, so the recognizable characters can be expanded at any time, so that the recognition ability of the above method can be expanded at any time, and the method has strong scalability.
[0096] 3) If it is a specific character, the character position information of the specific character is obtained according to the position where the specific character appears in the quantum algorithm image. The position information includes the arrangement position of the character in the quantum algorithm image, the column spacing of characters in the same row, and the row spacing of characters in the same column.
[0097] Optionally, the process of determining the position information of a specific character includes:
[0098] (a) Determine the row position of the first row of characters and the column position of the first column of characters according to the position of the recognized specific character. The position of the first specific character appearing from top to bottom can be determined as the row position of the first row of characters; and the position of the first specific character appearing from left to right can be determined as the column position of the first column of characters.
[0099] (b) determining the row position of each row, the specific characters included in each row, and the column position of each specific character in each row according to the row position of the first row of characters, the column position of the first column of characters, and the appearance position of each specific character;
[0100] (c) Determine the column spacing of characters in the same row and the row spacing of characters in the same column based on the row position of each row, the specific characters included in each row, and the column position of each specific character in each row, and obtain character position information including the character arrangement position, the column spacing of characters in the same row, and the row spacing of characters in the same column; the character arrangement position includes the row and column where the character is located.
[0101] In the above step S102, the quantum algorithm information contained in the image is identified by an image recognition algorithm, and characters corresponding to the quantum gate are extracted, including letter and symbol information, such as but not limited to Pauli-X gate, CZ gate, CNOT gate, etc.
[0102] In the above step S103, after the quantum algorithm is generated, a quantum circuit diagram corresponding to the quantum algorithm in the image submitted by the user can be formed. In this step, the arrangement position of the quantum gate corresponding to each character in the image is determined according to the characters and character position information in the image. A quantum circuit diagram is generated based on the quantum gates corresponding to each character and their arrangement positions. The process of generating a circuit diagram includes: determining the placement position of the quantum gate corresponding to each character in the circuit grid according to the characters and character arrangement positions in the image, as well as the column spacing of characters in the same row and the row spacing of characters in the same column; constructing the corresponding quantum gate according to each character, adding the quantum gate corresponding to each character to the corresponding circuit grid according to the placement position, and connecting each quantum gate in sequence to obtain a quantum circuit diagram. In other words, when generating a circuit diagram, the recognized characters can be processed row by row and column by column to finally form a corresponding circuit diagram.
[0103] Optionally, when constructing a corresponding quantum gate according to each character, the more difficult quantum gate can be split according to the difficulty of the quantum gate. The process of constructing the quantum gate includes: judging whether the quantum gate corresponding to the character belongs to the quantum gate that can be directly generated by the quantum bit; if it does, directly generating the corresponding quantum gate; if it does not, splitting the quantum gate corresponding to the character to generate the split quantum gate.
[0104] When constructing the quantum gates corresponding to each character, the quantum gates that are difficult to generate directly by quantum bits can be split into several easy-to-implement quantum gates. For example, the quantum gates specified as combination gates in the cloud platform need to be split into individual quantum gates, and so on. The specific quantum gates that need to be split can be determined based on the specific situation.
[0105] Figure 4 and Figure 5 are two examples of generated quantum circuit diagrams, where Figure 4 In the generated quantum circuit diagram, the first row of characters recognized in the quantum algorithm image corresponds to the first row of the generated circuit diagram, which includes the X gate, and the first row corresponds to the quantum bit q0; the second row of characters recognized corresponds to the second row of the generated circuit diagram, which includes the CZ gate and the CNOT gate, and the second row corresponds to the quantum bit q1. Figure 5 In the generated quantum circuit diagram, the first row of characters recognized in the quantum algorithm image corresponds to the first row of the generated circuit diagram, which includes the X gate, and the first row corresponds to the quantum bit q0; the second row of characters recognized corresponds to the second row of the generated circuit diagram, which includes the CZ gate, the Ry gate (90), the CZ gate and the Ry gate (270), and the second row corresponds to the quantum bit q1.
[0106] In the above step S104, the quantum gate in the quantum circuit diagram is converted into waveform parameter information for generating quantum measurement and control signals, and sent to the quantum computer. So that the measurement and control module in the quantum computer generates quantum measurement and control signals based on the waveform parameter information, and the generated quantum measurement and control signals can be transmitted to the quantum processor of the quantum computer, and the quantum bits in the quantum processor perform operations according to the quantum measurement and control signals. For example, the FPGA in the measurement and control module can generate quantum measurement and control signals according to the waveform parameter information.
[0107] After the generated quantum circuit diagram is presented to the user for confirmation, arbitrary waveform parameter information is generated and provided to the measurement and control system according to the protocol between the quantum computer and the measurement and control system. Optionally, in this step, quantum gates that are difficult to directly implement with quantum bits can be split into a collection of several quantum gates.
[0108] Figure 6 An example diagram of the XY signal of the generated quantum measurement and control signal, where the horizontal axis is time (time) and the vertical axis is amplitude (Amplitude), where the blue waveform corresponds to the quantum bit Q0, and the orange and green waveforms correspond to the quantum bit Q1.
[0109] The above method of the embodiment of the present invention can identify the quantum algorithm image submitted by the user to obtain the quantum algorithm information in the image, determine the arrangement position of the quantum gate corresponding to the character based on the obtained quantum algorithm information, automatically generate the quantum gate corresponding to the character and arrange and connect it according to its arrangement position to form a quantum circuit diagram; based on the generated quantum circuit diagram, convert the quantum gate therein into waveform parameter information for generating quantum measurement and control signals and send it to the quantum computer, so that the quantum computer generates quantum measurement and control signals based on the waveform parameter information. This method can realize the automatic generation of quantum algorithms without manual operation, has a high degree of automation, can identify various types of quantum algorithm images, and has strong scalability.
[0110] Embodiment 2
[0111] Embodiment 2 of the present invention provides a specific implementation process of the above-mentioned quantum algorithm generation method based on image recognition, and the process is as follows: Figure 7 As shown, the following steps are included:
[0112] S201: Obtain a quantum algorithm image submitted by a user.
[0113] S202: Preprocessing the quantum algorithm image.
[0114] S203: extracting character features from the quantum algorithm image, and identifying characters in the quantum algorithm image based on the extracted character feature information.
[0115] S204: for each recognized character, classify the character using a classification algorithm based on character feature information, and determine whether the recognized character belongs to a specific character in a specific character library according to the classification result.
[0116] S205: If it is a specific character, the character position information of the specific character is obtained according to the position where the specific character appears in the quantum algorithm image. The position information includes the arrangement position of the character in the quantum algorithm image, the column spacing of characters in the same row, and the row spacing of characters in the same column.
[0117] S206: Determine the arrangement position of the quantum gate corresponding to each character in the image according to the characters in the image and the character position information.
[0118] S207: Generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions.
[0119] S208: Convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send the information to the quantum computer.
[0120] S209: The quantum computer generates a quantum measurement and control signal based on the waveform parameter information.
[0121] In the above step S202, before character recognition, the input quantum algorithm image may be preprocessed to improve the accuracy of recognition. When preprocessing the quantum algorithm image, the preprocessing operation to be performed may be selected according to the specific situation of the image, and one or more of the following preprocessing operations may be performed:
[0122] 1) Grayscale Conversion.
[0123] Converting a color image to a grayscale image can simplify subsequent processing. This operation is performed when the image input by the user is a color image.
[0124] 2) Binarization.
[0125] Convert a grayscale image to a black and white image. If the image input by the user is a color image, this operation is performed after grayscale conversion. If the image input by the user is a grayscale image, this operation is performed directly.
[0126] 3) Denoising.
[0127] The image is filtered, for example, but not limited to, by filtering the binarized image by at least one of a Gaussian filter and a median filter to reduce noise in the image.
[0128] 4) Skew Correction.
[0129] Perform tilt correction on the image. For example, but not limited to, correcting the skewed text in the image to ensure the horizontal arrangement of the text. You can detect whether there is tilted text in the image, and if so, perform this operation.
[0130] 5) Character segmentation.
[0131] Perform character segmentation on the character string in the image. When there are multiple continuous characters in the image, such as a whole paragraph of text, the continuous characters can be segmented into multiple individual characters. The multiple continuous characters include two or more continuous characters. The method for segmenting the characters can be selected as needed, such as but not limited to character segmentation through projection analysis, connected component analysis and other technologies.
[0132] The quantum computing cloud platform processes images using grayscale algorithms, binarization algorithms, etc. to improve the contrast of the images, then uses the selected filtering method to remove image noise, and then uses tilt correction and character segmentation to pre-process the images to improve the accuracy of subsequent character recognition.
[0133] In the above step S205, the characters may be recognized in order according to the order of appearance, or the characters in the image may be recognized and arranged according to the positions of appearance.
[0134] An optional implementation process includes: after the image uploaded by the user is tilt-corrected, a preliminary search is made from left to right for the position where the first character appears, and the position is determined as the column position of the first column of characters, corresponding to the first column of the quantum circuit diagram; the row position of the first row of characters is determined from the position where the character first appears from top to bottom, corresponding to the first row of the quantum circuit diagram. The quantum gates in the first row are regarded as quantum gates applied to quantum bit 0, the quantum gates in the second row are regarded as quantum gates applied to quantum bit 1, and so on. For example, the quantum gates allowed to be identified in the present invention are "X", "Y", "Z", "H", "U", "Rx***", "Ry***", "Rz***" (*** is a number), "CZ" "CNOT" "barrier" "I" (space), if the image recognition algorithm recognizes other characters, the quantum algorithm uploaded by the user is invalid, and "recognition failed" is fed back to the user.
[0135] Optionally, the recognition algorithm of the present application can also measure the distance between the recognized characters in the same row or column, especially the distance between adjacent characters. If the distance between the characters exceeds a threshold, the recognition algorithm will add a space "I" between the two characters when finally outputting the result. For example: Based on the above image recognition method, Figure 2The recognition result of the quantum algorithm in is:
[0136] First row: Qubit0: "X" "CZ" "CNOT"
[0137] Second row: Qubit1: "I" "CZ" "CNOT"
[0138] Each group of double quotes "" is regarded as a group of graticules, and the characters in each group of graticules correspond to a quantum gate, which is placed in a circuit grid. The above results include the quantum gates in each row and their corresponding column positions, and I representing spaces is inserted according to the character spacing, so that the column positions of the quantum gates in the second row are more accurately represented.
[0139] The relevant steps in this embodiment have been described in detail in Embodiment 1, and will not be described in detail in this embodiment. The methods provided in Embodiments 1 and 2 analyze the gate circuit information in the image through image recognition algorithms, provide a more extensive quantum algorithm uploading method, and significantly improve the compatibility of the quantum computing platform.
[0140] Embodiment 3
[0141] Embodiment 3 of the present invention provides a method for implementing quantum computing, which can be implemented by a quantum computing system, and its process is as follows: Figure 8 As shown, the following steps are included:
[0142] S301: Use the above-mentioned quantum algorithm generation method to obtain waveform parameter information for generating quantum measurement and control signals, and send it to a quantum computer.
[0143] In this step, waveform parameter information can be generated based on the quantum algorithm image submitted by the user, and the waveform parameter information can be generated using the generation method described in Embodiment 1 and Embodiment 2. Fig.12 The system shown can generate waveform parameter information through the quantum algorithm generation device 1.
[0144] S302: The quantum computer generates a quantum measurement and control signal based on the waveform parameter information, and sends the quantum measurement and control signal to the quantum bit in the quantum processor.
[0145] A quantum computer can be placed in a dilution refrigerator. A quantum computer can include a quantum processor, and the quantum bits are located in the quantum processor. Fig.12 In the system shown, the quantum algorithm generation device transmits waveform parameter information to the measurement and control module 21 in the quantum computer. The measurement and control module 21 generates a quantum measurement and control signal based on the received waveform parameter information, and outputs the quantum measurement and control signal to the quantum bit in the quantum processor 22.
[0146] S303: Obtain the calculation result of the quantum bit after performing quantum calculation based on the quantum measurement and control signal.
[0147] After the measurement and control signal corresponding to the quantum algorithm is transmitted, the measurement and control module 21 outputs a read signal to the quantum bit in the quantum processor 22. After the quantum bit performs quantum calculation based on the quantum measurement and control signal, the calculation result is fed back to the measurement and control module 21. The measurement and control module 21 receives the feedback signal of the quantum bit, performs FFT or DFT transformation on the feedback signal, and then transmits the processed feedback signal to the quantum algorithm generation device 1.
[0148] S304: Generate a projection probability and density matrix based on the calculation results.
[0149] The quantum algorithm generation device analyzes the processed feedback signal, wherein the calculation module 12 generates the algorithm result, including the projection frequency and density matrix, based on the calculation result, and submits it to the user. For example: Fig. 9 is an example graph of the generated projection probabilities, Fig.10 An example plot of the generated density matrix is shown below.
[0150] Embodiment 4
[0151] Based on the same inventive concept, the fourth embodiment of the present invention provides a quantum algorithm generation device based on image recognition, which is used to implement the methods provided in the first and second embodiments. The structure of the device is as follows: Fig.11 As shown, including:
[0152] The image recognition module 11 is used to obtain the quantum algorithm image submitted by the user; use the image recognition algorithm to identify the quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes the characters and character position information in the image.
[0153] The computing module 12 is used to determine the arrangement position of the quantum gates corresponding to each character in the image according to the characters and character position information in the image, generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions; convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send the waveform parameter information to the quantum computer.
[0154] Embodiment 5
[0155] Based on the same inventive concept, the fifth embodiment of the present invention provides a quantum algorithm generation system based on image recognition, which is used to implement the method described in the third embodiment. The structure of the system is as follows: Fig.12 As shown, it includes: a quantum algorithm generation device based on image recognition 1 and a quantum computer 2; the quantum algorithm generation device based on image recognition includes an image recognition module 11 and a calculation module 12; the quantum computer includes a measurement and control module 21 and a quantum processor 22, and the quantum processor includes at least one quantum bit.
[0156] The image recognition module 11 is used to obtain the quantum algorithm image submitted by the user; use the image recognition algorithm to recognize the quantum algorithm information in the quantum algorithm image, and the quantum algorithm information includes the characters and character position information in the image;
[0157] The calculation module 12 is used to determine the arrangement position of the quantum gates corresponding to each character in the image according to the characters and character position information in the image, and generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions; convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send it to the quantum computer; and generate a projection probability and density matrix based on the calculation results fed back by the measurement and control module 21;
[0158] The measurement and control module 21 is used to generate a quantum measurement and control signal based on the waveform information, and send the quantum measurement and control signal to the quantum bit in the quantum processor 22 of the quantum computer 1; obtain the calculation result of the quantum bit after quantum calculation based on the quantum measurement and control signal, and feed it back to the calculation module 12. The measurement and control module 21 includes an FPGA, and the received waveform parameter information includes parameter information such as phase and amplitude. The FPGA generates a pulse waveform for controlling the quantum bit according to the waveform parameter information, that is, the quantum measurement and control signal. The calculation generation of the pulse waveform is realized in the FPGA, which can reduce the calculation amount of the PC end.
[0159] An embodiment of the present invention provides a computer storage medium, in which computer executable instructions are stored. When the computer executable instructions are executed by a processor, the above-mentioned quantum algorithm generation method based on image recognition and / or the above-mentioned quantum computing implementation method are implemented.
[0160] An embodiment of the present invention provides a quantum computing cloud platform, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned image recognition-based quantum algorithm generation method and / or the above-mentioned quantum computing implementation method when executing the program.
[0161] Regarding the apparatus and system in the above-mentioned embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments of the method, and will not be elaborated here.
[0162] Unless otherwise specifically stated, terms such as processing, computing, calculating, determining, displaying, etc. may refer to the actions and / or processes of one or more processing or computing systems, or similar devices, which operate and convert data represented as physical (e.g., electronic) quantities within registers or memories of a processing system into other data similarly represented as physical quantities within memories, registers, or other such information storage, transmission, or display devices of the processing system. Information and signals may be represented using any of a variety of different techniques and methods. For example, data, instructions, commands, information, signals, bits, symbols, and chips mentioned throughout the above description may be represented by voltages, currents, electromagnetic waves, magnetic fields or particles, light fields or particles, or any combination thereof.
[0163] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.
[0164] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
[0165] Those skilled in the art will also appreciate that the various illustrative logic blocks, modules, circuits, and algorithmic steps described in conjunction with the embodiments herein can all be implemented as electronic hardware, computer software, or a combination thereof. In order to clearly illustrate the interchangeability between hardware and software, various illustrative components, blocks, modules, circuits, and steps are generally described above around their functions. Whether such functions are implemented as hardware or software depends on specific applications and the design constraints imposed on the entire system. A skilled person can implement the described functions in an alternative manner for each specific application, but such implementation decisions should not be interpreted as departing from the scope of protection of the present disclosure.
[0166] The steps of the method or algorithm described in conjunction with the embodiments herein may be directly embodied as hardware, a software module executed by a processor, or a combination thereof. The software module may be located in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a mobile disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium may also be an integral part of the processor. The processor and the storage medium may be located in an ASIC. The ASIC may be located in a user terminal. Of course, the processor and the storage medium may also be present in a user terminal as discrete components.
[0167] For software implementation, the techniques described in this application can be implemented with modules (e.g., procedures, functions, etc.) that perform the functions described in this application. These software codes can be stored in a memory unit and executed by a processor. The memory unit can be implemented within the processor or outside the processor. In the latter case, it is coupled to the processor in a communication manner via various means, which are well known in the art.
[0168] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".
Claims
1. A quantum algorithm generation method based on image recognition, characterized in that: include: Get quantum algorithm images submitted by users; Using an image recognition algorithm, identifying quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image; According to the characters and character position information in the image, the arrangement position of the quantum gate corresponding to each character in the image is determined, and a quantum circuit diagram is generated based on the quantum gate corresponding to each character and its arrangement position; The quantum gates in the quantum circuit diagram are converted into waveform parameter information for generating quantum measurement and control signals and sent to the quantum computer.
2. The method according to claim 1, characterized in that The using an image recognition algorithm to identify quantum algorithm information in the quantum algorithm image includes: Extracting character features from the quantum algorithm image, and identifying characters in the quantum algorithm image based on the extracted character feature information; For each recognized character, a classification algorithm is used to classify the character based on the character feature information, and according to the classification result, it is determined whether the recognized character belongs to a specific character in a specific character library; If it is a specific character, the character position information of the specific character is obtained according to the position where the specific character appears in the quantum algorithm image.
3. The method according to claim 2, characterized in that The character feature information includes at least one of character edge feature information, character structure feature information and local shape feature information; The position information includes the arrangement position of the characters in the quantum algorithm image, the column spacing of characters in the same row, and the row spacing of characters in the same column.
4. The method according to claim 3, characterized in that The extracting character features from the quantum algorithm image includes performing at least one of the following character feature extraction operations: Performing character edge detection on the quantum algorithm image to extract character edge feature information; Using the Hough transform method, extracting the character structure feature information in the quantum algorithm image; the character structure information includes at least one of a straight line structure and a curve structure; Using a scale-invariant feature conversion method or a directional gradient histogram method, local feature detection is performed on the quantum algorithm image to extract local shape feature information of the character; The step of identifying characters in the quantum algorithm image based on the extracted character features includes: Based on at least one of the character edge feature information, the character structure feature information and the local shape feature information, the character included in the quantum algorithm image is determined.
5. The method according to claim 2, characterized in that The classifying of characters using a classification algorithm based on character feature information includes: According to the character feature information, a machine learning method is used to find the optimal classification boundary from the character feature space, and the character classification is determined according to the optimal classification boundary.
6. The method according to claim 1, characterized in that The step of obtaining character position information of a specific character according to the position where the specific character appears in the quantum algorithm image includes: Determine the row position of the first row of characters and the column position of the first column of characters according to the occurrence position of the recognized specific character; Determine the row position of each row, the specific characters included in each row, and the column position of each specific character in each row according to the row position of the first row of characters, the column position of the first column of characters, and the appearance position of each specific character; According to the row position of each row, the specific characters included in each row and the column position of each specific character in each row, the column spacing of characters in the same row and the row spacing of characters in the same column are determined to obtain character position information including the character arrangement position, the column spacing of characters in the same row and the row spacing of characters in the same column; the character arrangement position includes the row and column where the character is located.
7. The method according to claim 6, characterized in that Determining the row position of the first row character and the column position of the first column character according to the occurrence position of the recognized specific character, including: The position of the first occurrence of a specific character from top to bottom is determined as the row position of the first row of characters; The position of the first occurrence of a specific character from left to right is determined as the column position as the first column character.
8. The method according to claim 3, characterized in that According to the characters and character position information in the image, the quantum gates and their arrangement positions corresponding to the characters in the image are determined, and a quantum circuit diagram is generated based on the quantum gates and their arrangement positions, including: Determine the placement of the quantum gate corresponding to each character in the circuit grid according to the characters and their arrangement positions in the image, as well as the column spacing of characters in the same row and the row spacing of characters in the same column; Construct the corresponding quantum gate according to each character, add the quantum gate corresponding to each character to the corresponding circuit grid according to the placement position, connect each quantum gate in sequence to obtain a quantum circuit diagram.
9. The method according to claim 1, characterized in that Construct corresponding quantum gates according to each character, including: Determine whether the quantum gate corresponding to the character belongs to the quantum gate that can be directly generated by the quantum bit; If it meets the requirements, the corresponding quantum gate is directly generated; If not, the quantum gate corresponding to the character is split to generate the split quantum gate.
10. The method according to claim 1, characterized in that Also includes: Preprocessing the image; the preprocessing includes at least one of the following processes: Convert color images to grayscale images; Convert grayscale images to black and white images; Filter the image; Perform tilt correction on the image; Perform character segmentation on the string in the image.
11. A method for implementing quantum computing, characterized in that: include: Using the quantum algorithm generation method as described in any one of claims 1 to 10 to obtain waveform parameter information for generating a quantum measurement and control signal, and sending it to a quantum computer; So that the quantum computer generates a quantum measurement and control signal based on the waveform parameter information, and sends the quantum measurement and control signal to the quantum bit in the quantum processor; Obtain a calculation result of the quantum bit after performing quantum calculation based on the quantum measurement and control signal, and generate a projection probability and density matrix based on the calculation result.
12. A quantum algorithm generation device based on image recognition, characterized in that: include: An image recognition module is used to obtain a quantum algorithm image submitted by a user; use an image recognition algorithm to recognize quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image; The computing module is used to determine the arrangement position of the quantum gates corresponding to each character in the image according to the characters and character position information in the image, generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions; convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send it to the quantum computer.
13. A quantum computing system, characterized in that: include: A quantum algorithm generation device and a quantum computer based on image recognition; the quantum algorithm generation device based on image recognition comprises an image recognition module and a calculation module; the quantum computer comprises a measurement and control module and a quantum processor; The image recognition module is used to obtain a quantum algorithm image submitted by a user; use an image recognition algorithm to recognize quantum algorithm information in the quantum algorithm image, wherein the quantum algorithm information includes characters and character position information in the image; The calculation module is used to determine the arrangement position of the quantum gates corresponding to each character in the image according to the characters and character position information in the image, and generate a quantum circuit diagram based on the quantum gates corresponding to each character and their arrangement positions; convert the quantum gates in the quantum circuit diagram into waveform parameter information for generating quantum measurement and control signals, and send them to the quantum computer; and generate a projection probability and density matrix based on the calculation results fed back by the measurement and control module; The measurement and control module is used to generate a quantum measurement and control signal based on the waveform information, send the quantum measurement and control signal to the quantum bit in the quantum processor of the quantum computer, obtain the calculation result of the quantum bit after quantum calculation based on the quantum measurement and control signal, and feed it back to the calculation module.
14. A computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, which, when executed by a processor, implement the quantum algorithm generation method based on image recognition described in any one of claims 1 to 10 and / or the quantum computing implementation method described in claim 11.
15. A quantum computing cloud platform, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for generating a quantum algorithm based on image recognition according to any one of claims 1 to 10 and / or the method for implementing quantum computing according to claim 11 are implemented.