A quantum image feature extraction method for an image similarity task, a computer program product and a terminal
Patent Information
- Application Number
- CN202411191185.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2044-08-28
AI Technical Summary
无监督对比学习方法依赖于大量的正负样本对,利用最新负样本进行学习能够保证对比学习效果,目前负样本管理的挑战限制了无监督对比学习方法的广泛应用,图像特征提取的准确性有待进一步提升
[0032]1.在一示例中,双参数化量子电路(Parameterized Quantum Circuit,PQC)能够有效利用量子叠加和量子纠缠的特性,在更深层次上高效捕捉图像特征之间的复杂关系,显著提升了特征提取的精度和鲁棒性,以及数据处理效率;动量编码器通过动量更新机制保持与主编码器相似但略有不同的参数设置,实现更高效的对比学习;同时,通过不同类型的观测获得原始数据的不同类型观测信息,进一步对原始数据进行数据增强,从而获得更多负样本,通过逐步更新负样本集合中的样本,能够确保每个训练周期中都能利用最新的负样本,以此提升对比学习的效率和准确性。
Smart Images

Figure CN119169306B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantum image feature extraction technology, and in particular to a quantum image feature extraction method, computer program product and terminal for image similarity tasks. Background Technology
[0002] With the rapid development of computer vision technology, image similarity detection plays an increasingly important role in various fields such as image classification, object detection, and image segmentation. Traditional image feature extraction methods, mainly based on classic machine learning and deep learning techniques such as Convolutional Neural Networks (CNNs), have made significant progress in image feature representation. However, faced with the dramatic increase in data scale and the continuous increase in image data dimensionality, these classic methods have encountered bottlenecks when processing high-dimensional data, making it difficult to efficiently and accurately capture the complex relationships between image features.
[0003] Unsupervised learning learns effective feature representations by maximizing the similarity between positive sample pairs and minimizing the similarity between negative sample pairs. Positive sample pairs are similar or related sample pairs in the feature space, while negative sample pairs are dissimilar or unrelated sample pairs. This method does not rely on predefined class labels but learns through the relative similarity between samples. In this way, the model can learn features that distinguish different instances, which can then be used for various downstream tasks. Unsupervised contrastive learning methods rely on a large number of positive and negative sample pairs. Learning using the latest negative samples ensures the effectiveness of contrastive learning. Currently, the challenge of negative sample management limits the widespread application of unsupervised contrastive learning methods, and the accuracy of image feature extraction needs further improvement. Summary of the Invention
[0004] The purpose of this invention is to overcome the problems of the prior art and provide a quantum image feature extraction method, computer program product and terminal for image similarity tasks.
[0005] The objective of this invention is achieved through the following technical solution: a quantum image feature extraction method for image similarity tasks, comprising the following steps:
[0006] Construct positive and negative sample pairs;
[0007] By using amplitude encoding technology, positive and negative sample pairs are mapped to the quantum state space to obtain the quantum state representation of the positive and negative sample pairs;
[0008] The quantum state representation of positive and negative sample pairs is converted into the feature representation of quantum states through a dual-parameter quantum circuit. The dual-parameter quantum circuit includes a master encoder and a momentum encoder. The master encoder is used to extract the features of positive samples, and the momentum encoder is used to extract the features of negative samples. The parameters of the momentum encoder are the exponential moving average of the parameters of the master encoder.
[0009] By selecting different measurement basis vectors to measure the characteristic representation of the quantum state, image features are obtained.
[0010] In one example, constructing positive and negative sample pairs includes:
[0011] Positive sample pairs of the input image are generated through data augmentation operations, including flipping, rotating, color distortion, adding noise, scaling, translation, shearing transformation, perspective transformation, brightness and contrast adjustment, saturation and hue adjustment, gamma correction, random erasure, affine transformation, filtering, random color space transformation, occlusion and masking, or one or more of these operations.
[0012] Any image in the dataset that is different from the input image is used as a negative sample of the input image.
[0013] In one example, the structure of the dual-parameter quantum circuit is represented as follows:
[0014]
[0015] Where U(θ) represents the unit operator of the two-parameter quantum circuit; θ represents the adjustable parameter of the two-parameter quantum circuit; L represents the number of layers; and Q represents the number of qubits. and RZ and RY represent the rotation gates RZ and RY respectively, which operate on the q-th qubit in the l-th layer; CNOT(p,q) represents the CNOT gates operating on the p-th and q-th qubits.
[0016] In one example, the update expression for the parameters of the momentum encoder is:
[0017] θ momentum =α·θ momentum +(1-α)·θ;
[0018] Where θ represents the parameters of the main encoder; θ momentum This represents the parameters of the momentum encoder; α is the momentum factor, used to control the update rate of the momentum encoder parameters.
[0019] In one example, the dual-parameter quantum circuit is trained using a contrastive learning loss function. The expression is:
[0020]
[0021] Where f(|x>) represents the characteristic representation of the input quantum state |x>; Indicates negative sample pair data quantum state representation Feature representation; y i,k These are labels, representing sample pairs. Are they positive sample pairs if |x> and If they are similar, then y i,k =1; otherwise y i,k =0; m represents the margin, used to ensure that the distance between the target sample and the negative sample is at least m greater than the distance between the anchor point and the positive sample; This represents the distance metric between feature representations.
[0022] In one example, the parameters of a two-parameter quantum circuit are adjusted using differential gradient descent, including:
[0023] (1) Initialize the parameters of the dual-parameter quantum circuit;
[0024] (2) Execute the dual-parameter quantum circuit, measure the quantum state to obtain the measurement result, and calculate the loss function value under the current parameters;
[0025] (3) Calculate the positive and negative perturbation loss functions for each parameter, and use numerical approximation formulas to calculate the gradient;
[0026] (4) Update the parameters using gradient descent;
[0027] (5) Repeat steps (2)-(4) until the loss function converges or the predetermined number of iterations is reached.
[0028] It should be further noted that the technical features corresponding to the above examples can be combined or replaced to form new technical solutions.
[0029] The present invention also includes a computer program product comprising a computer program that, when executed by a processor, implements the steps of the quantum image feature extraction method for image similarity tasks formed by any or a combination of the above examples.
[0030] The present invention also includes a terminal comprising a memory and a processor, wherein the memory stores computer instructions executable on the processor, and the processor executes the steps of the quantum image feature extraction method for image similarity tasks formed by any or more of the above examples when executing the computer instructions.
[0031] Compared with the prior art, the beneficial effects of the present invention are:
[0032] 1. In one example, the Parameterized Quantum Circuit (PQC) can effectively utilize the properties of quantum superposition and quantum entanglement to efficiently capture the complex relationships between image features at a deeper level, significantly improving the accuracy and robustness of feature extraction, as well as data processing efficiency. The momentum encoder maintains parameter settings similar to but slightly different from the main encoder through a momentum update mechanism, achieving more efficient contrastive learning. At the same time, by obtaining different types of observation information from the original data through different types of observations, the original data is further augmented to obtain more negative samples. By gradually updating the samples in the negative sample set, it can be ensured that the latest negative samples can be used in each training cycle, thereby improving the efficiency and accuracy of contrastive learning.
[0033] 2. In one example, the input image is processed using data augmentation techniques to generate high-quality similar image pairs (positive samples) and different image pairs (negative samples), providing a basis for contrastive learning.
[0034] 3. In one example, the design of a dual-parameter quantum circuit allows for flexible adjustment of parameters during image feature extraction. By optimizing these parameters, the accuracy and robustness of image similarity detection can be further improved. Simultaneously, by introducing the parameters of the momentum encoder, the dual-parameter quantum circuit is effectively regularized, preventing overfitting and optimizing the processing of high-dimensional data. Furthermore, a dynamic dictionary based on momentum updates is introduced using the dual-parameter quantum circuit to store and manage a large number of negative samples. By gradually updating the samples in the negative sample set, a stable and rich negative sample set is maintained, improving the effect of contrastive learning.
[0035] 4. In one example, measurements are performed using different basis vector combinations of quantum measurement to achieve multi-dimensional and multi-level image feature extraction, construct diverse feature representations, and thus obtain more negative samples. During the training process, a large number of positive and negative sample pairs are constructed, and a contrastive learning strategy is used for training to optimize the parameter settings of PQC, so that the feature representations of similar images are closer and the feature representations of different images are more separated. Attached Figure Description
[0036] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. The accompanying drawings are provided to provide a further understanding of the present application and constitute a part of the present application. The same reference numerals are used in these drawings to denote the same or similar parts. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application.
[0037] Figure 1 A flowchart illustrating a method provided as an example of the present invention;
[0038] Figure 2 This is a schematic diagram of a dual-parameterized quantum circuit provided as an example of the present invention;
[0039] Figure 3 This is a schematic diagram of a feature extractor provided as an example of the present invention. Detailed Implementation
[0040] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] In the description of this invention, it should be noted that the directions or positional relationships indicated by terms such as "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer" are based on the directions or positional relationships shown in the accompanying drawings. They are used only for the convenience of describing this invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention. Furthermore, the use of ordinal numbers (e.g., "first and second," "first to fourth," etc.) is for distinguishing objects and is not limited to this order, and should not be construed as indicating or implying relative importance.
[0042] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "joining" should be interpreted broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to the internal communication between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0043] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0044] In one example, such as Figure 1 As shown, a quantum image feature extraction method for image similarity tasks includes the following steps:
[0045] S1: Construct positive and negative sample pairs.
[0046] Specifically, contrastive learning aims to learn data representations that bring similar data points closer together in the feature space, while dissimilar data points are further apart. By training the model with positive and negative sample pairs, the goal is to enable the model to distinguish subtle differences between data points, thereby obtaining better feature representations. Positive sample pairs consist of two similar data points, such as different enhanced versions of the same image or different views of the same object. Negative sample pairs consist of two dissimilar data points, such as enhanced versions of different images or different views of different objects.
[0047] S2: The positive and negative sample pairs are mapped to the quantum state space by amplitude encoding technology to obtain the quantum state representation of the positive and negative sample pairs.
[0048] Specifically, amplitude coding technology is used to map the image pixel matrix to Hilbert space to achieve quantum state embedding of image data; by utilizing the properties of quantum superposition and quantum entanglement, the relationship between image features can be captured more deeply, overcoming the bottleneck of classical methods when processing high-dimensional data.
[0049] S3: The quantum state representation of positive and negative sample pairs is converted into the feature representation of quantum states through a dual-parameter quantum circuit. The dual-parameter quantum circuit includes a master encoder and a momentum encoder. The master encoder is used to extract the features of positive samples, and the momentum encoder is used to extract the features of negative samples. The parameters of the momentum encoder are the exponential moving average of the parameters of the master encoder.
[0050] In this example, a trained dual PQC encoder structure is used to convert the quantum state representation into a feature representation. The dual PQC encoder structure includes a master encoder and a momentum encoder, which respectively process the current batch of image data and maintain the similarity of parameter settings through a momentum update mechanism, thereby evolving the encoded quantum state representation to achieve further feature extraction.
[0051] S4: Select different combinations of measurement basis vectors to measure the characteristic representation of the quantum state and obtain the quantum image features.
[0052] Among them, the measurement basis vectors are standard basis (quantum state |0> and quantum state |1>), X basis, Y basis, Z basis, and Hadamard basis, etc. Different types of observation information of the original data are obtained through different types of observations, and the original data is further augmented to obtain more negative samples.
[0053] In one example, constructing positive and negative sample pairs includes:
[0054] S11: Generate positive sample pairs of the input image through data augmentation operations, including one or more of the following: flipping, rotating, color distortion, adding noise, scaling, translation, shearing transformation, perspective transformation, brightness and contrast adjustment, saturation and hue adjustment, gamma correction, random erasure, affine transformation, filtering, random color space transformation, occlusion and masking.
[0055] S12: Take any image in the dataset that is different from the input image as a negative sample of the input image.
[0056] Steps S11 and S12 can be executed simultaneously or in reverse order.
[0057] Specifically, let x i Let x' be the positive sample pair generated from the u-th input image through data augmentation operations. i :
[0058] x′ i =Augment(x i );
[0059] Here, Augment represents data augmentation operations, including one or more of the following: flipping, rotating, color distortion, adding noise, scaling, translation, shearing transformation, perspective transformation, brightness and contrast adjustment, saturation and hue adjustment, gamma correction, random erasure, affine transformation, filtering, random color space transformation, occlusion, and masking. For example, by adding noise and scaling the image, the following augmented sample can be generated:
[0060] x′ i =Scale(AddNoise(x i ));
[0061] Here, Scale represents the image scaling operation; AddNoise represents the noise addition operation.
[0062] Let x i There are K negative samples These negative samples can be those in the dataset that are the same as x. i For any two different images, then each image x i Having a positive sample pair (x) i ,x' i ) and a large number of negative sample pairs These sample pairs will serve as the basis for comparative learning, used to train and optimize dual-parameter quantum circuits.
[0063] This invention combines classical data augmentation techniques with quantum circuit processing to efficiently construct positive and negative sample pairs that meet the requirements of quantum computing, effectively addressing the challenges of high-dimensional data processing.
[0064] Optionally, depending on the width of the quantum circuit, the positive and negative sample pairs can also be reduced in dimension or cropped to ensure that the sample pairs are adapted to the computational power of the quantum circuit while preserving the key features of the image.
[0065] In one example, mapping positive and negative sample pairs to quantum state space includes:
[0066] Each sample x is represented as an n-dimensional vector (x1, x2, ..., xn). The amplitude encoding process creates a quantum state |x>, whose expression is:
[0067]
[0068] Where, x i Let |i> be the i-th component of data x, and |i> be the standard computational basis vector. For data x' in the enhanced positive sample, its quantum state is represented as:
[0069]
[0070] For data in a large number of negative sample pairs Their quantum state representations are as follows:
[0071]
[0072] By using amplitude encoding technology to map positive and negative sample pairs to the quantum state space, the following quantum state representation can be obtained:
[0073]
[0074] in, This represents the set of quantum states for positive and negative samples.
[0075] In one example, the structure of a two-parameter quantum circuit is as follows: Figure 2 As shown, it consists of several single-qubit rotation gates and several multi-qubit entanglement gates. The single-qubit rotation gates include RZ gates and RY gates, which can precisely manipulate quantum states and achieve pure-state vector manipulation at arbitrary angles. The multi-qubit entanglement gates are CNOT gates, used to construct strong entanglement layers and enhance the correlation between qubits. The main encoder has the same structure as the momentum encoder, as shown... Figure 2 As shown, each sub-layer includes several sub-layers. The first sub-layer includes sequentially connected RZ gates, RY gates, and RZ gates. Other sub-layers include sequentially connected RZ gates, RY gates, RZ gates, and CNOT gates. The second RZ gate of the first sub-layer is connected to the CNOT gate of the next sub-layer. In other adjacent sub-layers, the CNOT gate of the preceding sub-layer is connected to the CNOT gate of the following sub-layer. The main encoder and each sub-layer of the momentum encoder are correspondingly connected. Specifically, the structure of this example dual-parameter quantum circuit is represented as follows:
[0076]
[0077] Where U(θ) represents the unit operator of the two-parameter quantum circuit; θ represents the adjustable parameter of the two-parameter quantum circuit; L represents the number of layers; and Q represents the number of qubits. and RZ and RY represent the rotation gates RZ and RY respectively, which operate on the q-th qubit in the l-th layer; CNOT(p,q) represents the CNOT gates operating on the p-th and q-th qubits.
[0078] Using the PQC encoder structure described above, the input quantum state |x> is converted into a feature representation f, as shown in the following expression:
[0079] f(|x>) = U(θ)|x>;
[0080] For positive sample pairs (|x>,|x'>) and negative sample pairs The feature representation calculation expression is:
[0081] f(|x>) = U(θ)|x>;
[0082] f(|x'>)=U(θ)|x'>;
[0083]
[0084] In one example, the update expression for the momentum encoder parameters is:
[0085] θ momentum =α·θ momentum +(1-α)·θ;
[0086] Where θ represents the parameters of the main encoder; θ momentum This represents the parameters of the momentum encoder; α is the momentum factor, used to control the update rate of the momentum encoder parameters. During training, only the master encoder is trained, and the parameters of the momentum encoder are the exponential moving average (EMA) of the master encoder parameters. This helps to smooth the learning process and improve the consistency of features.
[0087] In one example, the encoding circuit, the dual-parameter quantum circuit (ansatz), and the measurement circuit corresponding to amplitude encoding are sequentially connected to form a feature extractor. The feature extractor is trained using a contrastive learning loss function, aiming to maximize the similarity of positive sample pairs while minimizing the similarity of negative sample pairs. (Contrastive learning loss function) The expression is:
[0088]
[0089] Where f(|x>) represents the characteristic representation of the input quantum state |x>; Indicates negative sample pair data quantum state representation Feature representation; y i,k These are labels, representing sample pairs. Are they positive sample pairs if |x> and If they are similar, then y i,k =1; otherwise y i,k =0; m represents the margin, used to ensure that the distance between the target sample and the negative sample is at least m greater than the distance between the anchor point and the positive sample; This represents a distance metric between feature representations, such as Euclidean distance.
[0090]
[0091] By maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs The contrastive learning loss function guides the model to learn effective feature representations.
[0092] In one example, differential gradient descent is used to adjust the parameters of a two-parameter quantum circuit in quantum circuit optimization. Differential gradient descent is based on the differentiability of quantum circuits and updates the parameters by calculating their gradients, thus gradually reducing the loss function. The formula for calculating the gradient is as follows:
[0093]
[0094] Here, ∈ is a small perturbation, which is approximated by calculating the loss function values before and after the perturbation. Then, the parameters are updated using gradient descent.
[0095]
[0096] Where η represents the learning rate.
[0097] More specifically, the specific steps of the differential gradient descent method include:
[0098] (1) Initialize parameters: Randomly initialize the parameters θ of the quantum circuit;
[0099] (2) Calculate the loss function: Execute the dual-parameter quantum circuit, measure the quantum state to obtain the measurement result, and calculate the loss function value under the current parameters;
[0100] (3) Calculate the numerical gradient: for each parameter θ i ,calculate and Then use the numerical approximation formula to calculate the gradient.
[0101] (4) Update parameters: Update parameters θ using the gradient descent formula;
[0102] (5) Repeat steps (2)-(4) until the loss function converges or the predetermined number of iterations is reached. Through repeated iterations, the differential gradient descent method gradually optimizes the parameters of the dual-parameter quantum circuit, thereby continuously improving the model performance.
[0103] Combining the above examples yields a preferred embodiment of the present invention, where the feature extractor structure corresponding to this method is as follows: Figure 3 As shown, the method includes the following steps:
[0104] S10: Construct positive and negative sample pairs;
[0105] S20: The positive and negative sample pairs are mapped to the quantum state space through amplitude encoding technology to obtain the quantum state representation of the positive and negative sample pairs;
[0106] S30: Convert the quantum state representation of positive and negative sample pairs into the characteristic representation of quantum states through a dual-parameter quantum circuit;
[0107] S40: Select different measurement basis vectors to measure the characteristic representation of the quantum state and obtain the image features;
[0108] S50: Based on the measurement results, the contrastive learning loss function is used to train and optimize the dual-parameter quantum circuit, maximizing the similarity of positive samples and minimizing the similarity of negative samples.
[0109] S60: The parameters of the dual-parameter quantum circuit are adjusted using the differential gradient descent method to complete the training of the dual-parameter quantum circuit. Based on the optimized dual-parameter quantum circuit, efficient and accurate image feature extraction is achieved.
[0110] This invention, by introducing quantum contrastive learning and dual-parameter quantum circuits, enables the learning of useful feature representations from unlabeled image data without requiring large amounts of labeled data. This reduces reliance on labeled data and provides high-quality features for downstream computer vision tasks. This novel method is expected to overcome the shortcomings of existing technologies, improve the efficiency and accuracy of image similarity detection, and enable wider application of quantum computing technology in image processing, providing a new perspective and possibilities for its application.
[0111] Meanwhile, this invention achieves deep feature extraction from image data through quantum contrastive learning and dual-parameter quantum circuits, providing high-quality feature representations for image similarity detection. This method not only overcomes the bottleneck of traditional methods when processing high-dimensional data, but also effectively improves the accuracy and robustness of detection. By introducing a dynamic dictionary with momentum updates and an efficient contrastive learning mechanism, this invention not only solves the challenge of negative sample management, but also reduces the dependence on labeled data, providing new ideas and technical means for the application of quantum computing in the field of image similarity detection.
[0112] An example of the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the quantum image feature extraction method for image similarity tasks formed by any or a combination of the above examples. The processor may be a single-core or multi-core central processing unit or a specific integrated circuit, or one or more integrated circuits configured to implement the present invention.
[0113] An example of the present invention also provides a storage medium having the same inventive concept as the quantum image feature extraction method for image similarity tasks formed by any or more of the above examples, wherein computer instructions are stored thereon, and the computer instructions, when executed, perform the steps of the quantum image feature extraction method for image similarity tasks formed by any or more of the above examples.
[0114] Based on this understanding, the technical solution of this embodiment, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0115] An example of this invention also provides a terminal that shares the same inventive concept as any or a combination of examples corresponding to the aforementioned quantum image feature extraction method for image similarity tasks. The terminal includes a memory and a processor. The memory stores computer instructions executable on the processor. When the processor executes the computer instructions, it performs the steps of the aforementioned quantum image feature extraction method for image similarity tasks. The processor may be a single-core or multi-core central processing unit or a specific integrated circuit, or one or more integrated circuits configured to implement this invention.
[0116] In one example, the terminal, i.e., the electronic device, is represented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: at least one processing unit (processor) mentioned above, at least one storage unit mentioned above, and a bus connecting different system components (including storage units and processing units).
[0117] The storage unit stores program code that can be executed by the processing unit, causing the processing unit to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit can perform the aforementioned quantum image feature extraction method for image similarity tasks.
[0118] The storage unit may include a readable medium in the form of a volatile storage unit, such as a random access memory (RAM) 3201 and / or a cache storage unit, and may further include a read-only memory (ROM).
[0119] The storage unit may also include a program / utility having a set (at least one) of program modules, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0120] A bus can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus that uses any of the various bus structures.
[0121] The electronic device can also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., routers, modems, etc.). This communication can be performed via input / output (I / O) interfaces. Furthermore, the electronic device can communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter. The network adapter communicates with other modules of the electronic device via a bus. It should be understood that other hardware and / or software modules can be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0122] Through the above description, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to this exemplary embodiment can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the method of the exemplary embodiment of this application.
[0123] The above detailed embodiments are a description of the present invention. It should not be considered that the specific embodiments of the present invention are limited to these descriptions. For those skilled in the art, several simple deductions and substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the protection scope of the present invention.
Claims
1. A quantum image feature extraction method for image similarity tasks, characterized in that, Includes the following steps: Construct positive and negative sample pairs; By using amplitude encoding technology, positive and negative sample pairs are mapped to the quantum state space to obtain the quantum state representation of the positive and negative sample pairs; The quantum state representation of positive and negative sample pairs is converted into the feature representation of quantum states through a dual-parameter quantum circuit. The dual-parameter quantum circuit includes a master encoder and a momentum encoder. The master encoder is used to extract the features of positive samples, and the momentum encoder is used to extract the features of negative samples. The parameters of the momentum encoder are the exponential moving average of the parameters of the master encoder. By selecting different measurement basis vectors to measure the characteristic representation of the quantum state, image features are obtained. The structure of the dual-parameter quantum circuit is represented as follows: ; in, The unit operator representing a two-parameter quantum circuit; Represents the adjustable parameters of a two-parameter quantum circuit; Indicates the number of layers; Q represents the number of qubits; and They represent the first The effect in the layer is at the first Rotation gates RZ and RY on qubits; This represents the CNOT gate acting on the p-th and q-th qubits.
2. The quantum image feature extraction method for image similarity tasks according to claim 1, characterized in that, Constructing positive and negative sample pairs includes: Positive sample pairs of the input image are generated through data augmentation operations, including flipping, rotating, color distortion, adding noise, scaling, translation, shearing transformation, perspective transformation, brightness and contrast adjustment, saturation and hue adjustment, gamma correction, random erasure, affine transformation, filtering, random color space transformation, occlusion and masking, or one or more of these operations. Any image in the dataset that is different from the input image is used as a negative sample of the input image.
3. The quantum image feature extraction method for image similarity tasks according to claim 1, characterized in that, The update expression for the parameters of the momentum encoder is: ; in, Indicates the parameters of the main encoder; These represent the parameters of the momentum encoder; It is the momentum factor, used to control the update rate of the momentum encoder parameters.
4. The quantum image feature extraction method for image similarity tasks according to claim 1, characterized in that, The dual-parameter quantum circuit is trained using a contrastive learning loss function. The expression is: ; in, Represents the quantum state of the input Feature representation; Indicates negative sample pair data quantum state representation Feature representation; These are labels, representing sample pairs. Are they positive sample pairs? and Similar, then ;otherwise ; This represents the margin, used to ensure that the distance between the target sample and the negative sample is at least greater than the distance between the anchor point and the positive sample. ; This represents the distance metric between feature representations.
5. The quantum image feature extraction method for image similarity tasks according to claim 1, characterized in that, The parameters of a two-parameter quantum circuit are adjusted using the differential gradient descent method, including: (1) Initialize the parameters of the dual-parameter quantum circuit; (2) Execute the dual-parameter quantum circuit, measure the quantum state to obtain the measurement result, and calculate the loss function value under the current parameters; (3) Calculate the positive and negative perturbation loss functions for each parameter, and use the numerical approximation formula to calculate the gradient; (4) Update the parameters using gradient descent; (5) Repeat steps (2)-(4) until the loss function converges or the predetermined number of iterations is reached.
6. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the quantum image feature extraction method for image similarity tasks as described in any one of claims 1-5.
7. A terminal comprising a memory and a processor, wherein the memory stores computer instructions executable on the processor, characterized in that, When the processor executes the computer instructions, it performs the steps of the quantum image feature extraction method for image similarity tasks as described in any one of claims 1-5.
Citation Information
Patent Citations
Model training method and device, image processing method and device, medium and electronic equipment
CN116258657A
Content resource detection model training method, content resource detection method and device
CN116933069A