A system and method for building a quantum-classical hybrid machine learning model

Through the quantum classic hybrid machine learning model construction system, the model construction process is simplified, the problems of complexity and gradient propagation barriers in the existing technology are solved, and more efficient and flexible model construction is achieved.

CN119151013BActive Publication Date: 2025-03-14INST OF COMPUTING TECH CHINESE ACAD OF SCI
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411596723.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-14
Estimated Expiration
2044-11-11

AI Technical Summary

Technical Problem

The existing quantum classic hybrid machine learning methods are complex and have high barriers. Users need to have deep knowledge of quantum computing and classic machine learning, and there are gradient propagation barriers, resulting in waste of computing resources and increased system complexity.

Method used

A quantum classic hybrid machine learning model construction system is proposed, including data set units, computing layer units, automatic differential units and model training units, providing preset services and custom interfaces, simplifying the model construction process, and avoiding lengthy gradient propagation by directly calculating gradients at the quantum computing layer.

Benefits of technology

It reduces the complexity and learning cost of model construction, improves user convenience and efficiency, reduces the waste of computing resources, and achieves higher degrees of freedom and diversity in model construction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119151013B_ABST
    Figure CN119151013B_ABST
Patent Text Reader

Abstract

The present invention proposes a quantum-classical hybrid machine learning model construction system, which includes a data set unit, a computing layer unit, an automatic differentiation unit and a model training unit. The data set unit provides optional data set loading services, data set preprocessing services and encoding services to generate a target training set. The computing layer unit builds an initial machine learning model based on the classical and quantum computing layers selected or customized by the user. The automatic differentiation unit provides optional loss function configuration services and differentiator configuration services and automatically configures the classical differentiator based on the initial machine learning model. The model training unit provides classical optimizer configuration services, classical scheduler configuration services and training method configuration services and trains the initial machine learning model into a target machine learning model based on the user's selection. At the same time, in the forward and backward propagation processes of the model training, the gradient information of the machine learning model is automatically updated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of quantum computing and machine learning technology, and specifically to the implementation of a quantum-classical hybrid machine learning system and framework, and more specifically to a quantum-classical hybrid machine learning model construction system and method. Background Art

[0002] In the landscape of contemporary scientific research, the fusion of classical machine learning and quantum computing undoubtedly marks a new technological frontier. Classical machine learning, especially deep learning and reinforcement learning, has achieved remarkable results in image recognition, natural language processing, game intelligence and other fields. For example, the ability of advanced artificial intelligence systems such as ChatGPT in understanding and generating natural language, as well as the application of AI painting technology in artistic creation, all reflect the excellent performance of classical machine learning algorithms in processing and analyzing large-scale data sets.

[0003] As quantum computing technology matures, quantum-classical hybrid machine learning models have emerged, combining the advanced features of quantum computing with the robustness of classical algorithms. The parallelism and quantum superposition states of quantum computing provide new perspectives and possibilities for processing large-scale data sets, making quantum-classical hybrid models more efficient when performing complex computing tasks. In addition, the introduction of quantum algorithms provides new approaches to optimization problems that may be difficult to solve efficiently under traditional computing paradigms.

[0004] In the construction of quantum machine learning models, the use of parameterized quantum gates is the key to achieving adjustable quantum states. The parameters of these quantum gates are iteratively adjusted through classical optimizers, so that quantum machine learning models can adapt to various input data and learning tasks. This process not only enhances the generalization ability of the model, but also injects new vitality into the development of quantum machine learning.

[0005] In the field of quantum-classical hybrid machine learning, although the rapid development of classical machine learning algorithms and quantum computing technology has provided new possibilities for processing complex data sets and optimization problems, realizing the potential of these technologies in practical applications still faces a series of challenges. These challenges not only involve the complexity of technical implementation, but also the convenience and efficiency of users when using these technologies. Specifically, there is a lack of preset modules and model building methods at this stage. Most existing technologies only provide algorithm and model building interfaces, but do not provide preset models for commonly used algorithms. Users need to write programs for various parts including data preprocessing, encoders, quantum computing layers, classical machine learning networks, and output post-processing. This undoubtedly increases the threshold for technical application and severely limits the popularization and application scope of the technology. In addition, there is a gradient propagation barrier between the quantum computing layer and the classical computing layer. Due to the large differences in the computational models and operation methods of the two, in the quantum-classical hybrid computing model, the gradient propagation is complex. Current technologies usually rely on additional machine learning frameworks for gradient calculation and propagation, which makes the effective propagation of gradients complicated. Existing solutions often rely on additional machine learning frameworks, which require frequent data type conversion, gradient storage and transmission, which not only increases the complexity of the system, but also leads to a waste of computing resources.

[0006] In summary, current quantum-classical hybrid machine learning methods usually require users to not only have a deep knowledge base in the fields of quantum computing and classical machine learning, but also to be proficient in related programming tools and frameworks, which makes the model building process cumbersome and the learning curve steep, thus limiting the widespread adoption and practical application of this technology. In addition, existing solutions to the gradient propagation barrier problem of quantum-classical hybrid machine learning models often rely on additional machine learning frameworks, which require frequent data type conversion, gradient storage and transmission, which not only increases the complexity of the system, but also leads to a waste of computing resources.

[0007] It should be noted that this background technology is only used to introduce the relevant information of the present invention to help understand the technical solution of the present invention, but it does not mean that the relevant information is necessarily the prior art. If there is no evidence that the relevant information has been disclosed before the application date of the present invention, the relevant information shall not be regarded as the prior art. Summary of the invention

[0008] Therefore, the purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a system and method for constructing a quantum classical hybrid machine learning model.

[0009] The objective of the present invention is achieved through the following technical solutions:

[0010] According to a first aspect of the present invention, a quantum classical hybrid machine learning model construction system is proposed, the system comprising: a data set unit, which is used to provide a variety of optional data set loading services, a variety of optional data set preprocessing services, and a variety of optional data set encoding services, and loads corresponding data sets for users, performs corresponding data preprocessing, and performs corresponding data set encoding on the basis of the data set loading services, data set preprocessing services, and data set encoding services selected by users according to their needs to obtain target training sets required by users; a computing layer unit, which is used to provide a variety of optional initial machine learning model construction services, and builds an initial machine learning model for users based on the initial machine learning model construction services selected by users according to their needs; an automatic differentiation unit, which is used to provide a variety of optional loss function configuration services, a variety of optional quantum Differentiator configuration service, classical differentiator automatic configuration service, and configure the loss function and quantum differentiator required by the user based on the loss function configuration service and classical differentiator configuration service selected by the user according to the needs, and automatically configure the classical differentiator according to the initial machine learning model constructed by the computing layer unit; model training unit, used to provide a variety of optional classical optimizer configuration services, a variety of optional classical scheduler configuration services, a variety of optional training method configuration services, quantum classical hybrid machine learning model training service, which is configured as: based on the configured classical optimizer, classical scheduler, training method and the training set constructed in the data set unit and the loss function, classical differentiator, and quantum differentiator configured in the automatic differentiation unit, the initial machine learning model constructed by the computing layer unit is trained to obtain the target machine learning model required by the user.

[0011] According to a first aspect of the present invention, the dataset unit includes: a dataset loading module, which is used to provide a variety of optional dataset loading services, which is preset with a variety of optional datasets and a dataset custom loading interface so that the user can select a dataset according to needs or load a dataset defined by a custom interface; a preprocessing module, which is used to provide a variety of optional dataset preprocessing services, which is preset with a variety of optional dataset preprocessing methods and a dataset preprocessing method custom interface, and is configured to preprocess the dataset based on the preprocessing method selected by the user and / or the preprocessing method defined by the custom interface; an encoding module, which is used to provide a variety of optional dataset encoding services, which is preset with a variety of optional encoders and encoder custom interfaces, and is configured to encode the preprocessed dataset based on the encoder selected by the user or the encoder defined by the custom interface to obtain a target training set.

[0012] According to the first aspect of the present invention, the computing layer unit includes: a classical computing layer module, which is used to provide a variety of optional classical computing layers, a variety of optional activation functions, a classical computing layer custom interface, and an activation function custom interface so that users can select classical computing layers and activation functions according to their needs or define classical computing layers and activation functions through custom interfaces; a quantum computing layer module, which is used to provide a variety of optional quantum computing layers and quantum computing layer custom interfaces so that users can select quantum computing layers according to their needs or define quantum computing layers through custom interfaces, wherein each quantum computing layer includes: a quantum bit sequence composed of multiple quantum bits, a plurality of parameterized single-bit quantum gates, and a plurality of parameterized two-bit quantum gates, and each parameterized single-bit quantum gate and parameterized two-bit quantum gate contains a fixed parameter or an adjustable parameter.

[0013] According to the first aspect of the present invention, in the quantum computing layer module, the preset multiple quantum computing layers at least include a hardware efficient simulated quantum circuit, and the hardware efficient simulated quantum circuit is composed of multiple parameter layers and entanglement layers alternately, wherein each parameter layer is composed of multiple parameterized single-bit quantum gates, each entanglement layer is composed of multiple parameterized two-bit quantum gates, each parameterized two-bit quantum gate includes a control bit and a target bit, and each entanglement layer is constructed using any of the following entanglement structures: a lower ladder entanglement structure, which is a control bit and a target bit of each parameterized two-bit quantum gate that act on two consecutive quantum bits in sequence from the head of the quantum bit sequence, and act on the bit at the end The two quantum bits at the beginning and end of the quantum bit sequence; the fully connected entangled structure, in which the control bit and the target bit of each parameterized two-bit quantum gate act on all quantum bit pairs in the quantum bit sequence in turn, and the quantum bit pair consists of any two quantum bits in the quantum bit sequence; the control bit entangled structure, in which the control bits of all parameterized two-bit quantum gates act only on a specific quantum bit and the target bit acts on other quantum bits except the specific quantum bit in turn; the target bit entangled structure, in which the target bits of all parameterized two-bit quantum gates act only on a specific quantum bit and the control bits act on other quantum bits except the specific quantum bit in turn.

[0014] According to the first aspect of the present invention, in the computing layer unit, an initial machine learning model containing only a quantum computing layer is constructed, or an initial machine learning model containing a quantum computing layer and a classical computing layer is constructed, wherein the initial machine learning model containing only a quantum computing layer is constructed in the following manner: the user selects or customizes one or more quantum computing layers in the quantum computing layer module according to needs and configures one or more quantum measurement bits for each quantum computing layer; all selected or customized quantum computing layers are connected based on the connection order configured by the user according to needs to form an initial machine learning model; the initial machine learning model containing a quantum computing layer and a classical computing layer is constructed in the following manner: the user selects or customizes one or more quantum computing layers in the quantum computing layer module according to needs and configures one or more quantum measurement bits for each quantum computing layer; the user selects or customizes one or more classical computing layers and activation functions in the classical computing layer module according to needs; all selected or customized quantum computing layers and classical computing layers are connected based on the connection order configured by the user according to needs to obtain the initial machine learning model.

[0015] According to the first aspect of the present invention, when constructing an initial machine learning model, if the output end of the quantum computing layer needs to be connected to the input end of the classical computing layer, the output data obtained by measuring the quantum measurement bits of the quantum computing layer is used as the input data of the classical computing layer connected thereto, wherein the dimension of the output data of the quantum computing layer is consistent with the dimension of the input data of the classical computing layer; if the output end of the classical computing layer needs to be connected to the input end of the quantum computing layer, the output data of the classical computing layer is directly used as the adjustable parameter of the quantum computing layer connected thereto, wherein the dimension of the output data of the classical computing layer is consistent with the number of adjustable parameters of the quantum computing layer; if the classical computing layer needs to be connected to the classical computing layer, the output data of the previous classical computing layer is used as the input data of the next classical computing layer, wherein the output data of the previous classical computing layer is consistent with the dimension of the input data of the next classical computing layer; if the quantum computing layer needs to be connected to the quantum computing layer, the two quantum computing layers are combined into one quantum computing layer.

[0016] According to a first aspect of the present invention, the automatic differentiation unit includes: a loss function construction module, which is used to provide a variety of optional loss function construction services, and the loss function construction module presets a variety of optional loss functions and loss function custom interfaces so that users can select a preset loss function according to their needs or define the loss function through a custom interface; a classical differentiator automatic configuration module, which is used to provide a classical differentiator automatic configuration service, and the classical differentiator configuration module provides a preset classical differentiator, and is configured to automatically configure the classical differentiator on the basis that the initial machine learning model constructed by the computing layer unit includes a classical computing layer; a quantum differentiator configuration module, which is used to provide a variety of optional quantum differentiator construction services, and the quantum differentiator configuration module presets a variety of optional quantum differentiators so that users can select quantum differentiators according to their needs.

[0017] According to a first aspect of the present invention, the training unit includes: a classic optimizer configuration module, which is used to provide a variety of optional classic optimizer configuration services, and the classic optimizer configuration module presets a variety of optional classic optimizers and classic optimizer custom interfaces so that users can select or define classic optimizers through custom interfaces according to their needs; a classic scheduler configuration module, which is used to provide a variety of optional classic scheduler configuration services, and the classic scheduler configuration module presets a variety of optional classic schedulers and classic scheduler custom interfaces so that users can select classic differentiators according to their needs or define classic schedulers through custom interfaces; a training method configuration module, which is used to provide a variety of optional classic scheduler configuration services. A selected training method configuration service, wherein the training method configuration module presets a default training method and a training method customization interface so that the user can select the default training method according to needs or define the training method through a customization interface; a model training module, which is used to perform multiple rounds of iterative training on the initial machine learning model based on the training set constructed in the data set unit and the training method configured in the training method configuration module to obtain a target machine learning model, wherein, during the training process, the parameters of the machine learning model are optimized based on the loss function configured in the automatic differentiation unit, the classical differentiator, the quantum differentiator, the optimizer configured in the optimizer module, and the scheduler configured in the scheduler module.

[0018] According to a first aspect of the present invention, in the multiple rounds of iterative training, each round of iterative training includes a forward propagation process and a back propagation process, wherein in the back propagation process, the gradient information of the classical computing layer is updated based on the classical differentiator selected in the classical differentiator configuration module; in the forward propagation process, the gradient information in each quantum computing layer is automatically updated in the following manner: a parameter identifier is pre-configured for each adjustable parameter in the quantum computing layer, and each parameter identifier is bound to the gradient of the corresponding adjustable parameter; in the forward propagation process of the iterative training, the gradient of the adjustable parameter and its gradient are accessed using the parameter identifier, and the gradient of each adjustable parameter is calculated based on the quantum differentiator selected in the quantum differentiator configuration module to update the gradient information in the quantum computing layer.

[0019] According to a second aspect of the present invention, a method for constructing a machine learning model using a quantum-classical hybrid machine learning model construction system as described in any one of the first aspects of the present invention is proposed, the method comprising: a user selects a data set loading service, a data set preprocessing service, and a data set encoding service according to needs, and loads a corresponding data set based on the user's selection, performs corresponding data preprocessing, and performs corresponding data set encoding to obtain a target training set required by the user; the user selects an initial machine learning model construction service according to needs to construct an initial machine learning model required by the user; the user selects a loss function configuration service, a quantum differentiator configuration service, and a classical differentiator automatic configuration service according to needs to configure the loss function and quantum differentiator required by the user, and automatically configures classical differentiation according to the initial machine learning model constructed according to the computing layer unit; the user selects a classical optimizer configuration service, a classical scheduler configuration service, and a training method configuration service according to needs to configure the classical optimizer, classical scheduler, and training method required by the user, and trains the initial machine learning model based on the configured loss function, classical differentiator, quantum differentiator, classical optimizer, classical scheduler, training method, and constructed training set to obtain the target machine learning model required by the user.

[0020] Compared with the prior art, the advantages of the present invention are:

[0021] The present invention proposes a system and method for constructing a quantum classical hybrid machine learning model. The system allows users to select the services required to build a target machine learning model according to their needs, and automatically constructs an initial machine learning model based on the user's selection and iteratively trains it to obtain a target machine learning model. The system has a simple construction process and low learning cost, and the system has a higher degree of freedom than existing systems. In addition, during the forward propagation process of model training, the gradient calculation of the adjustable parameters of the quantum computing layer is directly performed, avoiding the repeated transmission of lengthy gradient data back and forth between layers and functions, saving a lot of computing resources and training time. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The embodiments of the present invention are further described below with reference to the accompanying drawings, in which:

[0023] Figure 1 A framework diagram of a classic machine learning model construction system according to an embodiment of the present invention;

[0024] Figure 2 is an architecture diagram of a data and processing module according to an embodiment of the present invention;

[0025] Figure 3 is a structural diagram of a coding module according to an embodiment of the present invention;

[0026] Figure 4 is an architecture diagram of a quantum computing layer module according to an embodiment of the present invention;

[0027] Figure 5 It is an architecture diagram of a classic computing layer module according to an embodiment of the present invention;

[0028] Figure 6 It is an architecture diagram of a loss function configuration module according to an embodiment of the present invention;

[0029] Figure 7 It is an architecture diagram of a quantum differentiator configuration module according to an embodiment of the present invention;

[0030] Figure 8 It is an architecture diagram of a configuration module of a classic optimizer according to an embodiment of the present invention;

[0031] Fig. 9 It is an architecture diagram of a classic scheduler configuration module according to an embodiment of the present invention;

[0032] Fig.10 A diagram of the steps for building a machine learning model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail by specific embodiments below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0034] As mentioned in the background technology section, current quantum-classical hybrid machine learning construction methods usually require users to not only have a deep knowledge base in the fields of quantum computing and classical machine learning, but also to be proficient in related programming tools and frameworks, which makes the model building process cumbersome and the learning curve steep, thus limiting the widespread adoption and practical application of this technology. In addition, existing solutions to the gradient propagation barrier problem of quantum-classical hybrid machine learning models often rely on additional machine learning frameworks, which require frequent data type conversion, gradient storage and transmission, which not only increases the complexity of the system, but also leads to a waste of computing resources.

[0035] Before specifically introducing the embodiments of the present invention, some of the terms used therein are explained as follows:

[0036] Classical computing layer: A computing model used in traditional computer science, which is usually based on Turing machine theory. In the field of deep learning, classical computing layers usually refer to various hierarchical structures in machine learning, such as fully connected layers, convolutional layers, pooling layers, etc., which perform specific mathematical operations such as matrix multiplication, nonlinear activation functions, etc. The processing of these layers follows classical physical laws and computer algorithms, and the processing speed and capacity are limited by current hardware technology.

[0037] Quantum computing layer: It is a concept in quantum computing, involving the operation of quantum bits. Quantum bits are the basic units of quantum computers and can be in the state of 0 and 1 at the same time (superposition state). The quantum computing layer uses the principles of quantum mechanics, such as superposition, entanglement and quantum tunneling, to perform computing tasks, and can achieve efficient solutions to certain specific problems. The processing process of the quantum computing layer follows the laws of quantum mechanics and can provide faster processing speeds than classical computers, especially for processing large amounts of data and complex calculations.

[0038] Quantum measurement bit: A quantum measurement bit refers to a quantum bit that is measured at the final stage of the quantum computing layer. Quantum measurement is a key step in obtaining information in the quantum computing layer. It involves the process of converting quantum information into classical information. In the quantum-classical hybrid machine learning model, the quantum measurement bit of the quantum computing layer is measured to obtain the output data of the quantum computing layer.

[0039] Classical Differentiators: These are traditional differential calculation methods that are very effective when dealing with continuously differentiable functions. They rely on classical calculus theory, such as the chain rule, partial derivatives, etc., to calculate the derivatives of functions. These methods are widely used in optimization algorithms in modern machine learning, such as gradient descent, where the gradient (i.e., the derivative of the loss function with respect to the model parameters) is the key to finding the optimal solution.

[0040] Quantum differentiator: Quantum differentiator is a technology used in the field of quantum computing to calculate the gradient of adjustable parameters input into a quantum circuit. Unlike gradient operations in traditional machine learning, observable objects in quantum circuits do not have relatively easy-to-calculate gradient formulas. Traditional computers can only read samples from circuits running on quantum computers, so special differentiation algorithms are needed to handle this situation.

[0041] In summary, the present invention proposes a classical quantum hybrid machine learning model construction system, the framework of which is as follows Figure 1 As shown, it includes: a data set unit, which is used to provide a variety of optional data set loading services, a variety of optional data set preprocessing services, and a variety of optional data set encoding services, and loads the corresponding data set for the user, performs corresponding data preprocessing, and performs corresponding data set encoding on the basis of the data set loading service, data set preprocessing service, and data set encoding service selected by the user according to the needs to obtain the target training set required by the user; a computing layer unit, which is used to provide a variety of optional initial machine learning model construction services, and builds an initial machine learning model for the user based on the initial machine learning model construction service selected by the user according to the needs; an automatic differentiation unit, which is used to provide a variety of optional loss function configuration services, a variety of optional quantum differentiator configuration services, and classical differentiator automatic configuration services. The system configures the loss function and quantum differentiator required by the user based on the loss function configuration service and classical differentiator configuration service selected by the user according to the needs, and automatically configures the classical differentiator according to the initial machine learning model constructed by the computing layer unit; the model training unit is used to provide a variety of optional classical optimizer configuration services, a variety of optional classical scheduler configuration services, a variety of optional training method configuration services, and a quantum-classical hybrid machine learning model training service, which is configured as follows: based on the configured classical optimizer, classical scheduler, training method and the training set constructed in the data set unit and the loss function, classical differentiator, and quantum differentiator configured in the automatic differentiation unit, the initial machine learning model constructed by the computing layer unit is trained to obtain the target machine learning model required by the user.

[0042] In order to better understand the present invention, each module in the construction system of the classical quantum hybrid machine learning model is described in detail below in combination with specific embodiments.

[0043] According to an embodiment of the present invention, the data set unit includes: a data set loading module, a preprocessing module, and an encoding module, wherein the data set loading module is used to provide a variety of optional data set loading services, and it is preset with a variety of optional data sets and a data set custom loading interface so that the user can select a data set according to the needs or load a data set defined by a custom interface; the architecture of the data preprocessing module is as follows Figure 2 As shown, it is used to provide a variety of optional data set preprocessing services, which are preset with a variety of optional data set preprocessing methods and data set preprocessing method custom interfaces, and is configured to preprocess the data set based on the preprocessing method selected by the user and / or the preprocessing method defined by the custom interface; the architecture of the encoding module is as follows Figure 3 As shown, it is used to provide a variety of optional dataset encoding services, which preset a variety of optional encoders and encoder custom interfaces, and is configured to encode the preprocessed dataset based on the encoder selected by the user or the encoder defined by the custom interface to obtain the target training set.

[0044] According to one embodiment of the present invention, the dataset loading module presets multiple datasets, and the user can select the dataset for training the initial classical quantum hybrid model according to his own needs. At the same time, the module also supports the user to customize the input method to obtain the dataset. It should be understood that the dataset preset by the module can also be an interface, link, download address, etc. for obtaining the preset dataset. In the present invention, the module aims to provide the function of loading datasets from multiple preset datasets and custom inputting other datasets. There is no limitation on whether the preset dataset is stored in the classical quantum hybrid machine learning model construction system and the method for obtaining the preset dataset.

[0045] According to one embodiment of the present invention, the data preprocessing module includes a variety of data set preprocessing methods, such as: (1) label screening, which is to screen or filter data according to specific labels or annotation information. It is usually used to select image samples with specific labels or attributes from the original data set to facilitate subsequent training or analysis tasks. (2) Downsampling, which is to reduce the size of image data by reducing the image resolution, usually by reducing the number of pixels in the image or reducing the image size to reduce computing costs or improve processing efficiency. A certain amount of image details will be lost. (3) Binarization, which is a processing method for converting an image into black and white. By setting a threshold, the pixel values ​​in the image are divided into two categories, one represented by black (usually 0) and the other represented by white (usually 255). (4) It is to change the grayscale level and adjust the grayscale level or grayscale range of the image to make it compatible with specific processing requirements or equipment. It is achieved by adjusting the pixel value range of the image or performing a linear transformation to change the contrast, brightness or color distribution of the image. (5) It is to remove conflicting data, which means to remove images with the same content but assigned different labels. This situation may occur in the dataset after downsampling or reducing the grayscale. It should be understood that the above-mentioned multiple dataset preprocessing methods are exemplary and not exhaustive. Users can preset other dataset preprocessing methods in the preprocessing module according to actual needs.

[0046] According to one embodiment of the present invention, the preprocessing module also provides an interface for custom-writing a data set preprocessing method, through which a user can configure a custom-written data set preprocessing method. It should be understood that when configuring the data set preprocessing method, one or more data set preprocessing methods can be selected from the preset data set preprocessing methods, or the data set preprocessing method can be defined through the provided custom interface, or a combination of the two methods.

[0047] According to one embodiment of the present invention, the encoding module includes multiple data set encoding methods, such as: (1) Qubit Lattice, which is a quantum image encoding method based on a grid structure. In this encoding method, each pixel is encoded as the state of a quantum bit, for example, a black pixel is encoded as a |0> state and a white pixel is encoded as a |1> state. By arranging these quantum bits sequentially in a grid, a quantum state representing the image can be formed. (2) Flexible Representation of Quantum Images (FRQI), a quantum image representation method suitable for encoding single-channel images. FRQI encoding uses hybrid encoding to simultaneously encode the position information and intensity information of pixels in the image. Among them, the position information is represented by discrete encoding, while the intensity information is represented by continuous encoding. For a picture with a resolution of , and there is For a grayscale image with grayscale levels, FRQI needs to use 2n+1 quantum bits to encode it, of which 2n quantum bits are used to describe pixel coordinates and 1 quantum bit is used to describe pixel values. The image information will be integrated into the following quantum states:

[0048]

[0049]

[0050] in, Encodes pixel location information, Encodes the pixel intensity information at the corresponding position. Expand, utilize The value distinguishes different pixel intensities, where The value represents the parameter of the parametric rotation gate, that is, the rotation angle. This representation method can ensure that the quantum state obtained after FRQI encoding meets the normalization condition. (3) The novel enhanced image quantum representation method (NEQR) is similar to FRQI in terms of the overall encoding idea, but uses discrete encoding. For a grayscale image with grayscale levels, NEQR uses q quantum bits to form a set of orthogonal bases to describe pixel values, thereby providing a more accurate expression. Compared with FRQI, NEQR has a better logic gate compression rate. It should be understood that the above-mentioned multiple preset data encoding methods are exemplary and not exhaustive, and other data encoding methods that can encode image data are all possible.

[0051] According to one embodiment of the present invention, the computing layer unit includes a classical computing layer module and a quantum computing layer module, wherein the architecture of the classical computing layer module is as follows: Figure 4 As shown, it is used to provide a variety of optional classical computing layers, a variety of optional activation functions, a custom interface for the classical computing layer, and a custom interface for the activation function so that the user can select the classical computing layer and the activation function according to the needs or define the classical computing layer and the activation function through the custom interface; the module architecture of the quantum computing layer is as follows Figure 5 As shown, it is used to provide a variety of optional quantum computing layers and quantum computing layer custom interfaces so that users can select quantum computing layers according to their needs or define quantum computing layers through custom interfaces, wherein each quantum computing layer includes: a quantum bit sequence composed of multiple quantum bits, multiple parameterized single-bit quantum gates, and multiple parameterized two-bit quantum gates, each parameterized single-bit quantum gate and parameterized two-bit quantum gate contains a fixed parameter or an adjustable parameter, wherein the value of the fixed parameter does not change during the model training process, and the adjustable parameter is adjusted as the model is optimized during the model training process.

[0052] According to one embodiment of the present invention, a plurality of optional classical computing layers are preset in the classical computing layer module, including: a linear fully connected neural network layer, in which each input neuron is connected to each other output neuron, and each connection has a weight for adjusting the influence of the input signal. The output of this layer can be calculated by simple matrix multiplication and bias addition, that is, given the input vector x, the weight matrix W and the bias vector b, the output vector y=Wx+b of the neural network layer. The activation functions preset in this module include: (1) Sigmoid activation function, which maps the input real number to the interval (0,1). Its output has an S-shaped curve, which is often used in the output layer in binary classification problems, and can also be used for nonlinear transformation of hidden layers. (2) Rectified Linear Unit Activation Function (ReLU), which converts all negative inputs to zero and keeps positive values ​​unchanged. This simple nonlinear transformation makes the model easier to train and is often used in the hidden layer of deep neural networks. (3) Hyperbolic Tangent Activation Function (Tanh), which maps the input real number to the interval (-1,1). It is similar to the Sigmoid function, but its output range is wider and it performs better for centralized data. (4) SoftPlus activation function, which maps the input x to . Compared with ReLU, SoftPlus is smoother when x is close to zero, so it can sometimes produce more stable gradients. (5) Softmax activation function, which maps the input vector to a probability distribution so that all output values ​​are in the interval (0,1) and the sum is 1. It is often used in the output layer of multi-classification problems to convert the original output of the neural network into the probability distribution of the category. It should be understood that the above-mentioned preset types of classical computing layers and activation functions are exemplary, not exhaustive. Users can add other classical neural networks and activation functions in the classical computing layer module according to actual needs.

[0053] According to one embodiment of the present invention, the classical computing layer module includes an interface that supports custom classical computing layers and activation functions, and users can customize other classical computing layers and activation functions according to their needs to meet their construction requirements.

[0054] According to one embodiment of the present invention, the multiple quantum computing layers preset in the quantum computing layer module include: (1) Quantum Approximate Optimization Ansatz Layer (QAOA Ansatz), which includes a series of alternating evolution and mixing operations, usually composed of two unitary transformations alternating. In each step, the ansatz first applies an evolution operation to "evolve" the current quantum state and transform it into a state related to the problem, and then applies a mixing operation to mix the current quantum state to enhance the information of the problem. The evolution and mixing operations are usually composed of parameterized single-qubit rotation gates and double-qubit gates. The angles of these parameterized gates are called adjustable parameters. (2) Basic Quantum Neural Network Ansatz Layer (BasicQNN), which usually requires an additional auxiliary bit as a readout bit, and the result can be obtained by performing quantum measurement on the readout bit, and the remaining quantum bits are directly connected to the encoder as data bits. Such an ansatz can include a circuit block consisting of d double-bit gate parameter layers, and d is usually referred to as the number of layers of such an ansatz model. The same type of two-bit gates with different parameters are used inside a circuit block, one of which always acts on the readout bit, and the other acts on all data bits in sequence. (3) Color-Readout-Alternating-Double-Layer architecture (CRADL), which is only applicable to FRQI encoders or NEQR encoders for binary images. In the color-readout-alternating-double-layer architecture, the last qubit in the qubit sequence is used as the readout bit, and the remaining qubits are directly connected to the encoder, where the second-to-last qubit corresponds to the color bit of the encoder and the rest are position bits. Each layer of the architecture consists of XX gates or ZZ gates. These gates act on each position qubit and readout qubit in sequence, and then act on the position qubit and color qubit, until the last position qubit. Each pair of consecutive position-readout bit two-bit gates and position-color bit two-bit gates share the same learning parameter, namely the rotation angle. (4) The Color Readout Alternating Mixed Layer architecture (CRAML), which is almost the same as CRADL, with the only difference being that for the same position, different types of two-bit gates act alternately before the position is shifted down. (5) Hardware-Efficient Ansatz (HE-Ansatz), which is composed of a series of parameter layers and entanglement layers alternating, where the parameter layer consists of only single-bit parameter gates and the entanglement layer consists of two-bit gates. Its advantage is that it is relatively easier to deploy and implement on quantum hardware than other types of ansatz.It should be understood that the above-mentioned multiple preset quantum computing layers are only exemplary and not exhaustive, and other quantum computing layers that can construct machine learning models can be added to the quantum computing layer module.

[0055] According to one embodiment of the present invention, the hardware efficient simulated quantum circuit is composed of multiple parameter layers and entanglement layers alternately, wherein each parameter layer is composed of multiple parameterized single-bit quantum gates, each entanglement layer is composed of multiple parameterized two-bit quantum gates, each parameterized two-bit quantum gate includes a control bit and a target bit, and each entanglement layer is constructed using any of the following entanglement structures: (1) a lower ladder entanglement structure, in which the control bit and target bit of each parameterized two-bit quantum gate act on two consecutive quantum bits in sequence from the head of the quantum bit sequence, and finally act on the two quantum bits located at the beginning and end of the quantum bit sequence; (2) A fully connected entangled structure, in which the control bit and target bit of each parameterized two-bit quantum gate act on all two-bit combinations in turn; (3) A control bit entangled structure, in which the control bits of all parameterized two-bit quantum gates act only on one specific quantum bit, and the target bit of each parameterized two-bit quantum gate acts on other quantum bits except the specific quantum bit in turn; (4) A target bit entangled structure, in which the target bits of all parameterized two-bit quantum gates act only on one specific quantum bit, and the control bit of each parameterized two-bit quantum gate acts on other quantum bits except the specific quantum bit in turn.

[0056] According to one embodiment of the present invention, in the computing layer unit, different initial machine learning models are constructed according to the number and type of classical computing layers and quantum computing layers selected by the user, wherein an initial machine learning model containing only the quantum computing layer (pure quantum machine learning model) is constructed in the following manner: the user selects or customizes one or more quantum computing layers in the quantum computing layer module according to needs and configures one or more quantum measurement bits for each quantum computing layer; all selected or customized quantum computing layers are connected based on the connection order configured by the user according to needs to form an initial machine learning model; an initial machine learning model containing quantum computing layers and classical computing layers (quantum-classical hybrid machine learning model) is constructed in the following manner, the user selects or customizes one or more quantum computing layers in the quantum computing layer module according to needs and configures one or more quantum measurement bits for each quantum computing layer; the user selects or customizes one or more classical computing layers and activation functions in the classical computing layer module according to needs; all selected or customized quantum computing layers and classical computing layers are connected based on the connection order configured by the user according to needs to obtain the initial machine learning model; wherein the quantum measurement bit is a quantum bit in the quantum bit sequence of the quantum computing layer.

[0057] According to one embodiment of the present invention, the selected or customized activation function is used to configure the selected or customized classical computing layer. When connecting with other classical computing layers or quantum computing layers, the activation function can be selected without directly connecting with other classical computing layers / quantum computing layers.

[0058] According to one embodiment of the present invention, in the computing layer unit, due to the different number of adjustable parameters of different quantum circuits, the following connection method is required when connecting the constructed quantum computing layer and the classical computing layer: when the output end of the quantum computing layer is connected to the input end of the classical computing layer, the output data obtained by measuring the quantum measurement bit of the quantum computing layer is used as the input data of the classical computing layer connected thereto, wherein the dimension of the output data of the quantum computing layer is consistent with the dimension of the input data of the classical computing layer; when the output end of the classical computing layer is connected to the input end of the quantum computing layer, the output data of the classical computing layer is directly used as the adjustable parameter of the quantum computing layer connected thereto, wherein the dimension of the output data of the classical computing layer is consistent with the number of adjustable parameters of the quantum computing layer; when the classical computing layer is connected to the classical computing layer, the output data of the previous classical computing layer is used as the input data of the next classical computing layer, wherein the output data of the previous classical computing layer is consistent with the input data dimension of the next classical computing layer; when the quantum computing layer is connected to the quantum computing layer, the two quantum computing layers are combined into one quantum computing layer. Compared with the existing quantum classical hybrid model construction method, the connection method of the present invention has a higher degree of freedom and a higher diversity of constructed machine learning models.

[0059] According to one embodiment of the present invention, when connecting quantum computing layers, in the case where multiple quantum computing layers are connected together, the multiple quantum computing layers will be combined into a quantum computing layer with a greater depth, and only the quantum measurement bits of the last quantum computing layer will take effect in the machine learning model.

[0060] According to one embodiment of the present invention, the automatic differentiation unit includes a loss function configuration module, a classical differentiator configuration module, and a quantum differentiator configuration module, wherein the architecture of the loss function configuration module is as follows: Figure 6 As shown, it is used to provide a variety of optional loss function construction services. The loss function construction module presets a variety of optional loss functions and loss function custom interfaces so that users can select preset loss functions according to needs or define loss functions through custom interfaces; the classical differentiator automatic configuration module is used to provide classical differentiator automatic configuration services. The classical differentiator configuration module provides a preset classical differentiator and is configured to automatically configure the classical differentiator on the basis that the initial machine learning model constructed by the computing layer unit includes a classical computing layer; the architecture of the quantum differentiator configuration module is as shown Figure 7As shown, it is used to provide a variety of optional quantum differentiators construction services. The quantum differentiator configuration module presets a variety of optional quantum differentiators so that users can select quantum differentiators according to their needs.

[0061] According to one embodiment of the present invention, the loss functions preset in the loss function configuration module include: (1) Hinge Loss, which is commonly used in binary classification problems and takes the interval between correctly classified samples and incorrectly classified samples as loss. (2) Mean Squared Error Loss (MSE Loss), a loss function used for regression problems. It calculates the average of the squared differences between the model prediction value and the true value. (3) Binary Cross-Entropy Loss (BCE Loss), which is used for binary classification problems and measures the distance between two probability distributions. (4) Cross-Entropy Loss, which is used for multi-classification problems and measures the difference between the probability distribution output by the model and the true label. It should be understood that the above four loss functions are only exemplary and not exhaustive. The loss function configuration module is intended to provide loss function construction services, that is, to select from preset loss functions or to construct loss functions through custom interfaces. Therefore, there is no limitation on the type and number of loss functions preset in the loss function configuration module. Users can preset other loss functions or delete the above loss functions according to their needs.

[0062] According to one embodiment of the present invention, the model training unit includes: a classic optimizer configuration module, a classic scheduler configuration module, a training method configuration module, and a model training module. The classic optimizer architecture is as follows: Figure 8 As shown, it is used to provide a variety of optional classic optimizer configuration services. The classic optimizer configuration module presets a variety of optional classic optimizers and classic optimizer custom interfaces so that users can select the required classic optimizer according to their needs or define the required classic optimizer through the custom interface; the architecture of the classic scheduler configuration module is as follows Fig. 9As shown, it is used to provide a variety of optional classical scheduler configuration services. The classical scheduler configuration module presets a variety of optional classical schedulers and classical scheduler custom interfaces so that users can select classical differentiators according to their needs or customize the required classical schedulers through custom interfaces; the training method configuration module is used to provide a variety of optional training method configuration services. The training method configuration module presets a default training method and a training method custom interface so that users can select a default training method according to their needs or define a training method through a custom interface; the model training module is used to perform multiple rounds of iterative training on the initial machine learning model based on the training set constructed in the data set unit and the training method configured in the training method configuration module to obtain a target machine learning model, wherein, during the training process, the parameters of the machine learning model are optimized based on the loss function configured in the automatic differentiation unit, the classical differentiator, the quantum differentiator, the optimizer configured in the optimizer module, and the scheduler configured in the scheduler module.

[0063] According to one embodiment of the present invention, the classical optimizers preset in the classical optimizer configuration module include: (1) Stochastic Gradient Descent (SGD), in each iteration, only a single sample or a small batch of samples is used to calculate the gradient of the loss function, and then the model parameters are updated according to the gradient direction and the learning rate. (2) Adaptive Gradient Algorithm (AdaGrad), an optimization algorithm with adaptive learning rate, dynamically adjusts the learning rate according to the historical gradient size of each parameter. For frequently appearing parameters, the learning rate will become smaller, while for parameters that do not appear frequently, the learning rate will become larger. (3) Root Mean Square Propagation (RMSProp), an optimization algorithm with adaptive learning rate, which is similar to AdaGrad, but uses the exponential moving average of the square of the gradient to adjust the learning rate. (5) Adaptive Moment Estimation (Adam), an optimization algorithm that combines momentum and adaptive learning rate. It calculates the first-order moment (i.e., the exponential moving average of the gradient) and the second-order moment (i.e., the exponential moving average of the square of the gradient) of each parameter, and uses these estimates to adjust the learning rate. It should be understood that the above-mentioned preset classical optimizers are only exemplary and not exhaustive, and other classical optimizers that can be used to optimize machine learning model parameters can also be added to the classical optimizer configuration module.

[0064] According to one embodiment of the present invention, the classic schedulers preset in the classic scheduler configuration module include: (1) Constant Scheduler, a simple scheduler that always applies a constant learning rate to the training of the model. Regardless of the stage of training, the learning rate remains unchanged. (2) Exponential Scheduler, which adjusts the learning rate according to an exponential function, that is, the learning rate decreases exponentially with the increase of training steps. It is usually used in the early stage of training when a higher learning rate is required for rapid convergence, and the learning rate is gradually reduced in the later stage to fine-tune the model parameters. (3) Noam Scheduler, which adjusts the learning rate according to the increase of training steps and some pre-set hyperparameters. (4) King Scheduler, an adaptive learning rate scheduler that automatically adjusts the learning rate according to the performance of the model during training. The King Scheduler has good robustness and adaptability, and can more flexibly adjust the learning rate to adapt to different training scenarios. It should be understood that the above-mentioned preset classic scheduler is only exemplary and not exhaustive, and other classic schedulers that can be used to adjust the learning rate of the machine learning model can also be added to the classic scheduler configuration module.

[0065] According to one embodiment of the present invention, each round of iterative training in the multiple rounds of iterative training includes a forward propagation process and a back propagation process, wherein, in the back propagation process, the gradient information of the classical computing layer is updated based on the classical differentiator selected in the classical differentiator configuration module; in the forward propagation process, the gradient information in each quantum computing layer is automatically updated in the following manner: a parameter identifier is configured for each adjustable parameter in the quantum computing layer, and each parameter identifier is bound to the gradient of the corresponding adjustable parameter; in the forward propagation process of the iterative training, the parameter identifier is used to access the adjustable parameter and its gradient, and the gradient of each adjustable parameter is calculated based on the quantum differentiator selected in the quantum differentiator configuration module to update the gradient information in the quantum computing layer. By using the above steps to update the gradient information of the quantum computing layer, the gradient calculation can be performed directly on the parameters of the network layer during the forward propagation process, avoiding the lengthy gradient data being repeatedly transferred back and forth between layers and functions, saving a lot of computing resources and training time. The same parameter identifier will be regarded as the same parameter, and the assignment and gradient value are shared. At the same time, the parameter identifier supports operations, and the final calculated gradient is still the gradient of the adjustable parameter. This gradient update method realizes the gradient propagation between the quantum and classical computing layers, and compared with the prior art, the present invention does not rely on other machine learning libraries, which makes the entire gradient calculation and propagation process very lightweight. This innovation breaks through the situation where traditional quantum classical hybrid machine learning models are often dependent on other machine learning libraries when constructed, greatly reducing the burden of additional dependencies and making the deployment and application of the model simpler and more efficient. In practical applications, this lightweight feature makes the present invention easier to deploy and run in resource-constrained environments, and also provides broader possibilities for applications in scenarios such as mobile terminals and edge computing.

[0066] The classical quantum hybrid machine learning construction system proposed in the present invention has built-in multiple modules to provide a variety of configuration services for users to choose from. The options included in these services cover the data sets, machine learning models, differentiators, model training methods, optimizers, schedulers, etc. required for various machine learning tasks. The machine learning models include but are not limited to classical machine learning models, quantum machine learning models, and users can flexibly select, combine and edit these built-in options according to the needs of specific tasks to build network models suitable for different scenarios. Such a design not only enriches the user's choice space, but also can meet the needs of various complex tasks, and improves the applicability and flexibility of the model. The problem of high threshold for use of existing technologies is solved. At the same time, the present invention provides multiple custom interfaces so that users can also customize the configuration data sets, machine learning models, differentiators, model training methods, optimizers, schedulers, etc. according to their needs.

[0067] According to one embodiment of the present invention, a method for building a target machine learning model based on a classical quantum hybrid machine learning model construction system is proposed, the method comprising: the user selects a data set loading service, a data set preprocessing service, and a data set encoding service according to demand and loads the corresponding data set based on the user's selection, performs corresponding data preprocessing, and performs corresponding data set encoding to obtain the target training set required by the user; the user selects an initial machine learning model construction service according to demand to build the initial machine learning model required by the user; the user selects a loss function configuration service, a quantum differentiator configuration service, and a classical differentiator automatic configuration service according to demand to configure the loss function and quantum differentiator required by the user, and automatically configures classical differentiation according to the initial machine learning model constructed according to the computing layer unit; the user selects a classical optimizer configuration service, a classical scheduler configuration service, and a training method configuration service according to demand to configure the classical optimizer, classical scheduler, and training method required by the user, and trains the initial machine learning model based on the configured loss function, classical differentiator, quantum differentiator, classical optimizer, classical scheduler, training method, and constructed training set to obtain the target machine learning model required by the user.

[0068] In order to more clearly describe the process of building a target machine learning model using the quantum classical hybrid machine learning model construction system proposed in the present invention, a detailed description will be given below with examples.

[0069] According to one embodiment of the present invention, the steps of using the sub-classical hybrid machine learning model construction system to construct a target machine learning model are as follows: Fig.10 As shown, including:

[0070] Step S1, determine whether the data set preset in the data set loading module contains the required data set, if so, execute step S2, otherwise execute step S3.

[0071] Step S2: Obtain the required data set from the data set loading module and execute step S4.

[0072] Step S3: Input a custom data set, convert the input data set into a data type supported by the system and store the converted data set.

[0073] Step S4: The user sets the hyperparameters of the dataset, such as random seed, specified labels, resolution, grayscale, number of samples used in one iteration, whether to discard redundant data, whether to shuffle the data before each round of training, etc.

[0074] Step S5: The user determines whether the data set processing module contains all the required preprocessing methods. If so, execute step S6; otherwise, execute step S7.

[0075] Step S6: Call the preprocessing module, and the user selects the preprocessing method, preprocessing steps, and preprocessing order according to the hyperparameters set in step S4 to preprocess the data set, and execute step S8.

[0076] Step S7: The user writes the required preprocessing method in the custom interface of the preprocessing module, and the user selects the preprocessing method, preprocessing steps, and preprocessing order according to the hyperparameters set in step S4 to preprocess the data set.

[0077] Step S8: Encapsulate the preprocessed data set into the system's built-in Dataset class.

[0078] Step S9: The user packages the encapsulated Dataset class into a system-built-in data loader according to the hyperparameters set in step S4.

[0079] Step S10: The user determines whether the encoding module includes the required encoder, if so, execute step S11, otherwise execute step S12.

[0080] Step S11: The user selects a desired encoder from a variety of encoders preset in the encoding module, and defines the encoder to be used according to the hyperparameters set in step S4, and executes step S13.

[0081] Step S12: The user writes a custom encoder in the custom interface of the encoding module and defines the encoder to be used according to the hyperparameters set in step S4.

[0082] Step S13: The user sets training-related hyperparameters, such as random seed, learning rate, total number of training rounds, etc.

[0083] Step S14: The user selects and defines the classic optimizer and scheduler to be used according to the hyperparameters set in step S13.

[0084] Step S15: The user selects and defines the loss function to be used based on the hyperparameters set in step S13.

[0085] Step S16: The user determines whether to use the preset pure quantum machine learning model or the preset quantum-classical hybrid machine learning model in the system. If the preset pure quantum machine learning model or the preset quantum-classical hybrid machine learning model is used, execute step S17; if complete customization is required, execute step S20.

[0086] Step S17: The user selects in the system preset quantum computing layer, configures the parameters of the quantum computing layer, and sets the quantum measurement bit for the quantum computing layer. If the user chooses to use the preset pure quantum machine learning model in step S16, step S18 is executed; if the user chooses to use the preset quantum classical hybrid machine learning model in step S16, step S19 is executed.

[0087] Step S18: Call the system's built-in QuantumNet module to build an initial machine learning model, and then execute step S30.

[0088] The QuantumNet module is a pre-set single-layer pure quantum machine learning model building module that can be automatically differentiated. Users can select one of the pre-set quantum computing layers and directly enter the specified settings, such as optimizer, differentiator, measurement method, etc., to form a trainable initial pure quantum machine learning model with one click.

[0089] Step S19: directly call the built-in HybridNet module of the system to build an initial machine learning model. Then execute step S30.

[0090] The HybridNet module is a pre-set quantum-classical hybrid machine learning model module that can be automatically differentiated. It consists of a quantum computing layer and a linear fully connected layer. Users can select one of the preset quantum computing layers and activation layers, and directly enter the specified settings, such as optimizer, differentiator, measurement method, etc., to form a trainable initial quantum-classical hybrid machine learning model with one click.

[0091] Step S20: The user determines whether the quantum computing layer module contains the required quantum computing layer. If so, execute step S21; otherwise, execute step S22.

[0092] Step S21: The user selects a quantum computing layer in the quantum computing layer module and configures the parameters of the selected quantum computing layer, and sets quantum measurement bits for the quantum computing layer, and executes step S23.

[0093] Step S22: Write the quantum computing layer by yourself in the custom interface provided by the quantum computing layer module and configure the parameters of the custom quantum computing layer according to the requirements, and set the quantum measurement bit for the custom-written quantum computing layer.

[0094] Step S23: Does the user need multiple quantum computing layers with different structures? If so, repeat steps S20-S22; otherwise, proceed to step S24.

[0095] Step S24: The user determines whether the classic computing layer needs to be used. If so, execute step S25; otherwise, execute step S29.

[0096] Step S25: The user determines whether the classic computing layer module contains the required classic computing layer. If so, execute step S26; otherwise, execute step S27.

[0097] Step S26: The user selects from among the various classic computing layers preset in the classic computing layer module and configures the parameters of the selected classic computing layer according to the requirements. Then, step S28 is executed.

[0098] Step S27: Write the classic computing layer yourself in the custom interface provided by the classic computing layer module, and define the classic computing layer to be used according to specific needs.

[0099] Step S28: If the user needs multiple classical computing layers with different structures, repeat steps S25 to S27; otherwise, proceed to step S29.

[0100] Step S29: The user arranges the various computing layers constructed in steps S20-S28 as required, and encapsulates them into the system's built-in Module module as the initial machine learning model to be trained later.

[0101] The Module module is a comprehensive custom network module that can be automatically differentiated and constructed by the present invention. Its initial state does not contain any network layer, and the user needs to add each custom network layer to it in order. The Module module will determine the order of connection of the computing layer type and the computing layer, and automatically connect each computing layer according to certain connection rules and requirements. Then, the user can set the optimizer, differentiator, measurement method and other parameters by himself, and build a trainable custom initial quantum classical hybrid machine learning model with one click.

[0102] Step S30: The user determines whether it is necessary to use the system preset training method (ie, the general training function and the general verification function). If so, execute step S31; otherwise, execute step S32.

[0103] The general function includes the network's forward propagation, loss calculation, and back-propagation processes. The function also records and displays training-related information, including training loss and training accuracy.

[0104] The general validation function includes the network testing and loss calculation process. At the same time, the function also records and displays validation related information, including validation loss and validation accuracy.

[0105] Step S31: Train the model using the system preset training method until the training is completed.

[0106] Step S32: The user writes relevant codes to construct a custom training method to train the model until the training is completed.

[0107] According to one embodiment of the present invention, it can be seen from the above-mentioned model building steps that the use of the quantum classical hybrid machine learning model building system proposed in the present invention to build a machine learning model greatly simplifies the model building process compared to the prior art. Users do not need to have an in-depth understanding of the complex principles of quantum computing, nor do they need to manually build the various components of the model. They only need to follow the instructions to quickly build the required quantum classical hybrid machine learning model. This simple model building process reduces the user's learning cost, improves the efficiency of model building, and enables more people to participate in the research and application of the field of quantum machine learning. It further solves the problem that the prior art requires users to have both quantum computing and machine learning foundations, and the high threshold for use.

[0108] It should be noted that although the above describes the various steps in a specific order, it does not mean that the various steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even in a different order as long as the required functions can be achieved.

[0109] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.

[0110] A computer-readable storage medium may be a tangible device that holds and stores instructions used by an instruction execution device. Computer-readable storage media may include, for example, but are not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a protruding structure in a groove on which instructions are stored, and any suitable combination thereof.

[0111] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A quantum classical hybrid machine learning model construction system, characterized in that: The system comprises: The data set unit is used to provide a variety of optional data set loading services, a variety of optional data set preprocessing services, and a variety of optional data set encoding services, and load the corresponding data set for the user, perform the corresponding data preprocessing, and perform the corresponding data set encoding to obtain the target training set required by the user based on the data set loading service, data set preprocessing service, and data set encoding service selected by the user according to the needs; The computing layer unit is used to provide a variety of optional initial machine learning model construction services, and to build an initial machine learning model for the user based on the initial machine learning model construction service selected by the user according to the needs, wherein the computing layer unit includes: The classic computing layer module is used to provide a variety of optional classic computing layers, a variety of optional activation functions, a classic computing layer custom interface, and an activation function custom interface so that users can select classic computing layers and activation functions according to their needs or define classic computing layers and activation functions through custom interfaces; A quantum computing layer module is used to provide a variety of optional quantum computing layers and quantum computing layer custom interfaces so that users can select quantum computing layers according to their needs or define quantum computing layers through custom interfaces, wherein each quantum computing layer includes: a quantum bit sequence composed of multiple quantum bits, multiple parameterized single-bit quantum gates, and multiple parameterized two-bit quantum gates, and each parameterized single-bit quantum gate and parameterized two-bit quantum gate contains a fixed parameter or an adjustable parameter; Furthermore, the computing layer unit is configured as follows: An initial machine learning model consisting of only the quantum computing layer is constructed in the following way: The user selects or customizes one or more quantum computing layers in the quantum computing layer module according to needs and configures one or more quantum measurement bits for each quantum computing layer; Connect all selected or customized quantum computing layers based on the connection order configured by the user according to the requirements to obtain the initial machine learning model; The initial machine learning model consisting of quantum computing layer and classical computing layer is constructed in the following way: The user selects or customizes one or more quantum computing layers in the quantum computing layer module according to needs and configures one or more quantum measurement bits for each quantum computing layer; Users select or customize one or more classic computing layers and activation functions in the classic computing layer module according to their needs; Connect all selected or customized quantum computing layers and classical computing layers based on the connection order configured by the user according to the requirements to obtain an initial machine learning model; The automatic differentiation unit is used to provide a variety of optional loss function configuration services, a variety of optional quantum differentiator configuration services, and classical differentiator automatic configuration services, and configure the loss function and quantum differentiator required by the user based on the loss function configuration service and classical differentiator configuration service selected by the user according to the needs, and automatically configure the classical differentiator according to the initial machine learning model constructed by the computing layer unit; The model training unit is used to provide a variety of optional classical optimizer configuration services, a variety of optional classical scheduler configuration services, a variety of optional training method configuration services, and quantum-classical hybrid machine learning model training services. It is configured to: train the initial machine learning model constructed by the computing layer unit based on the configured classical optimizer, classical scheduler, training method and the training set constructed in the data set unit and the loss function, classical differentiator, and quantum differentiator configured in the automatic differentiation unit to obtain the target machine learning model required by the user.

2. The system according to claim 1, characterized in that The data set unit includes: The dataset loading module is used to provide a variety of optional dataset loading services. It has a variety of optional datasets and a dataset custom loading interface preset so that users can select a dataset according to their needs or load a dataset defined by a custom interface; A preprocessing module, which is used to provide a variety of optional data set preprocessing services, which is preset with a variety of optional data set preprocessing methods and data set preprocessing method custom interfaces, and is configured to preprocess the data set based on the preprocessing method selected by the user and / or the preprocessing method defined through the custom interface; The encoding module is used to provide a variety of optional dataset encoding services. It presets a variety of optional encoders and encoder custom interfaces, and is configured to encode the preprocessed dataset based on the encoder selected by the user or the encoder defined by the custom interface to obtain the target training set.

3. The system according to claim 1, characterized in that In the quantum computing layer module, the preset multiple quantum computing layers at least include a hardware efficient simulated quantum circuit, and the hardware efficient simulated quantum circuit is composed of multiple parameter layers and entanglement layers alternately, wherein each parameter layer is composed of multiple parameterized single-bit quantum gates, each entanglement layer is composed of multiple parameterized two-bit quantum gates, each parameterized two-bit quantum gate includes a control bit and a target bit, and each entanglement layer is constructed using any of the following entanglement structures: The lower ladder entanglement structure is that the control bit and the target bit of each parameterized two-bit quantum gate act on two consecutive quantum bits from the head of the quantum bit sequence, and finally act on the two quantum bits at the beginning and end of the quantum bit sequence; A fully connected entangled structure, in which the control bit and the target bit of each parameterized two-bit quantum gate act on all quantum bit pairs in the quantum bit sequence in sequence, wherein the quantum bit pair consists of any two quantum bits in the quantum bit sequence; A control bit entanglement structure, in which the control bits of all parameterized two-bit quantum gates act only on one specific qubit and the target bits act on other qubits except the specific qubit in turn; The target bit entanglement structure is that the target bit of all parameterized two-bit quantum gates acts only on a specific quantum bit and the control bit acts on other quantum bits except the specific quantum bit in turn.

4. The system according to claim 1, characterized in that When building your initial machine learning model, When the output end of the quantum computing layer needs to be connected to the input end of the classical computing layer, the output data obtained by measuring the quantum measurement bit of the quantum computing layer is used as the input data of the classical computing layer connected thereto, wherein the dimension of the output data of the quantum computing layer is consistent with the dimension of the input data of the classical computing layer; If the output end of the classical computing layer needs to be connected to the input end of the quantum computing layer, the output data of the classical computing layer is directly used as the adjustable parameter of the quantum computing layer connected thereto, wherein the dimension of the output data of the classical computing layer is consistent with the number of the adjustable parameters of the quantum computing layer; If a classic computing layer needs to be connected to another classic computing layer, the output data of the previous classic computing layer is used as the input data of the next classic computing layer, where the output data of the previous classic computing layer has the same dimension as the input data of the next classic computing layer; If a quantum computing layer needs to be connected to another quantum computing layer, the two quantum computing layers are combined into one quantum computing layer.

5. The system according to claim 1, characterized in that The automatic differentiation unit comprises: A loss function construction module is used to provide a variety of optional loss function construction services. The loss function construction module presets a variety of optional loss functions and loss function custom interfaces so that users can select a preset loss function according to their needs or define a loss function through a custom interface; A classic differentiator automatic configuration module, used to provide a classic differentiator automatic configuration service, wherein the classic differentiator configuration module provides a preset classic differentiator and is configured to automatically configure the classic differentiator based on the initial machine learning model constructed by the computing layer unit including the classic computing layer; The quantum differentiator configuration module is used to provide a variety of optional quantum differentiator construction services. The quantum differentiator configuration module presets a variety of quantum differentiators so that users can select quantum differentiators according to their needs.

6. The system according to claim 1, characterized in that The training unit comprises: A classic optimizer configuration module is used to provide a variety of optional classic optimizer configuration services. The classic optimizer configuration module presets a variety of optional classic optimizers and classic optimizer custom interfaces so that users can select or define classic optimizers through custom interfaces according to their needs; A classic scheduler configuration module is used to provide a variety of optional classic scheduler configuration services. The classic scheduler configuration module presets a variety of optional classic schedulers and classic scheduler custom interfaces so that users can select a classic differentiator according to their needs or define a classic scheduler through a custom interface; A training method configuration module is used to provide a variety of optional training method configuration services. The training method configuration module presets a default training method and a training method customization interface so that users can select a default training method according to their needs or define a training method through a custom interface; A model training module is used to perform multiple rounds of iterative training on the initial machine learning model based on the training set constructed in the data set unit and the training method configured in the training method configuration module to obtain a target machine learning model, wherein during the training process, the parameters of the machine learning model are optimized based on the loss function configured in the automatic differentiation unit, the classical differentiator, the quantum differentiator, the optimizer configured in the optimizer module, and the scheduler configured in the scheduler module.

7. The system according to claim 6, characterized in that In the multiple rounds of iterative training, each round of iterative training includes a forward propagation process and a back propagation process, wherein: During the back-propagation process, the gradient information of the classical computation layer is updated based on the classical differentiator selected in the classical differentiator configuration module; During the forward propagation process, the gradient information in each quantum computing layer is automatically updated in the following way: Pre-configure a parameter identifier for each adjustable parameter in the quantum computing layer, and bind each parameter identifier to the gradient of its corresponding adjustable parameter; During the forward propagation process of iterative training, the parameter identifier is used to access the gradient of the adjustable parameter and its gradient, and the gradient of each adjustable parameter is calculated based on the quantum differentiator selected in the quantum differentiator configuration module to update the gradient information in the quantum computing layer.

8. A method for constructing a machine learning model using the quantum classical hybrid machine learning model construction system as described in any one of claims 1 to 7, characterized in that: The method comprises: The user selects the dataset loading service, dataset preprocessing service, and dataset encoding service according to the user's needs, and based on the user's selection, loads the corresponding dataset, performs the corresponding data preprocessing, and performs the corresponding dataset encoding to obtain the target training set required by the user; The user selects the initial machine learning model building service according to the needs to build the initial machine learning model required by the user; Users select loss function configuration service, quantum differentiator configuration service, and classical differentiator automatic configuration service according to their needs to configure the loss function and quantum differentiator required by the user, and automatically configure classical differentiation based on the initial machine learning model built by the computing layer unit; Users select the classic optimizer configuration service, classic scheduler configuration service, and training method configuration service according to their needs to configure the classic optimizer, classic scheduler, and training method required by the user, and train the initial machine learning model based on the configured loss function, classic differentiator, quantum differentiator, classic optimizer, classic scheduler, training method, and constructed training set to obtain the target machine learning model required by the user.

Citation Information

Patent Citations

  • Machine learning framework-based model training method and related equipment

    CN116432691A