Supervised contrast learning image feature extraction method based on dynamic hybrid updating strategy

By dynamically mixing the update strategy and the category prototype loss function, the problem of a single parameter update strategy in supervised contrastive learning is solved, the training efficiency and feature extraction performance of the model are improved, and more stable image feature extraction is achieved.

CN120673082APending Publication Date: 2025-09-19NANJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510813668.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-18
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

In existing supervised contrastive learning methods, the model parameter update strategy is single, resulting in high computational overhead, slow convergence and insufficient performance. The asynchronous update method is slow, affecting the model's training efficiency and discrimination effect.

Method used

A dynamic hybrid update strategy is adopted, combining gradient descent and momentum update mechanisms, to train the supervised contrastive learning network model. The supervised contrastive loss function is determined by category prototypes, and the model parameters are dynamically adjusted to achieve branch differentiation updates.

Benefits of technology

It improves the training stability and convergence speed of the model, optimizes the feature space distribution, improves the performance of image feature extraction and training efficiency, and reduces the sensitivity to small sample categories.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673082A_ABST
    Figure CN120673082A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of comparative learning, in particular to a supervised comparative learning image feature extraction method based on a dynamic hybrid updating strategy, which comprises the following steps: acquiring an image data set, and establishing a supervised comparative learning network model; obtaining a first enhanced view and a second enhanced view corresponding to the first branch and the second branch after enhancement processing, and establishing an enhanced data set; determining feature embedding corresponding to the first branch and the second branch, and calculating a prototype of each category; training by adopting a dynamic hybrid updating strategy, determining a supervision and comparison loss function, and updating the first branch and the second branch; according to the current training round number, judging whether the current training round number is smaller than a preset total training round number, and if not, outputting a trained supervised contrast learning network model; inputting a to-be-detected image sample into the trained supervised contrast learning network model to obtain a feature vector; a branch-differentiated dynamic hybrid updating strategy is realized, gradient descent and momentum updating mechanisms are integrated, and an image feature extractor with better performance is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of contrastive learning, and in particular to a supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy. Background Art

[0002] With the application of deep learning in computer vision, image feature extraction has shifted from manual labeling to automated learning. Traditional methods rely on experts to construct features, which not only consumes a lot of manpower but also has difficulty adapting to the diverse needs of image features in complex scenarios. Feature extraction models based on deep learning automatically learn efficient and abstract representations of data, so that similar samples are close together in the representation space and dissimilar samples are separated, thereby improving the performance of downstream tasks and reducing dependence on manual feature engineering. Contrastive Learning (CL), as an unsupervised feature learning paradigm, has attracted attention for its excellent feature extraction capabilities. Supervised Contrastive Learning (SCL) introduces label information to guide the contrastive learning process on the basis of contrastive learning, improving the model's discriminability for features.

[0003] Contrastive learning network models typically consist of two branches that share the same architecture. Model parameter update mechanisms are divided into synchronous and asynchronous modes. The SimCLR (Simple Contrastive Learning of Representations) model uses synchronous updates, utilizing gradient descent to symmetrically update the parameters of the two branches. The Moco (Momentum Contrast) model employs asynchronous updates, employing gradient descent for the main branch and momentum updates for the auxiliary branch to preserve historical gradient information for enhanced training stability.

[0004] Despite progress in feature learning methods, practical applications still face challenges. For example, the single model parameter update strategy cannot achieve optimal training results. Synchronous updates lead to high gradient calculation overhead and slow early model convergence. In asynchronous updates, the momentum parameters of the auxiliary branches are updated slowly, which in turn reduces the final performance of the model. In addition, traditional supervised contrastive learning uses direct comparison between sample pairs, which is computationally complex, inefficient for training large batches of data, and sensitive to uneven category distribution, resulting in unstable loss calculation. Summary of the Invention

[0005] In order to solve the technical problems that the existing supervised contrastive learning method is based on a single update strategy and cannot achieve the best training effect, the synchronous update method has a high computational overhead, and the asynchronous update method is slow, affecting model performance, and cannot achieve a balance between computational efficiency and discrimination effect, the purpose of the present invention is to provide a supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy. The technical solutions adopted are as follows:

[0006] Acquire an image dataset, the image dataset including image samples and corresponding category labels, and establish a supervised contrastive learning network model, including a first branch and a second branch established in parallel;

[0007] Performing enhancement processing on each image sample in the image data set to obtain a first enhanced view and a second enhanced view corresponding to the first branch and the second branch, respectively, and establishing an enhanced data set;

[0008] Determine the feature embeddings corresponding to the first branch and the second branch based on the enhanced dataset, and calculate the prototype of each category;

[0009] A dynamic hybrid update strategy is used to train the supervised contrastive learning network model. The supervised contrastive loss function is determined by combining the category prototypes, and the first and second branches are updated sequentially.

[0010] Determine whether the current number of training rounds is less than the preset total number of training rounds. If not, output the trained supervised contrastive learning network model.

[0011] Obtain an image sample to be detected, input the image sample to be detected into the trained supervised contrastive learning network model, and obtain a feature vector.

[0012] Preferably, obtaining an image dataset and establishing a supervised contrastive learning network model include:

[0013] The image dataset is ,in, Represents the total number of image datasets; Indicates the image dataset image samples; Indicates the corresponding The category labels of image samples, , Indicates the total number of categories; Indicates that the corresponding image sample belongs to categories;

[0014] The first branch and the second branch are established in parallel, and the first branch is defined as , the second branch is , the corresponding branch parameters are and , both include image feature extractor and projection head, denoted as , ; , ;in, Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head.

[0015] Preferably, performing enhancement processing on each image sample in the image dataset to obtain a first enhanced view and a second enhanced view corresponding to the first branch and the second branch respectively, and establishing the enhanced dataset includes:

[0016] Each image sample in the image dataset is subjected to enhancement processing by random cropping and scaling, random horizontal flipping, color jittering, random grayscale conversion, and standardization operations to obtain the first enhanced view and the second enhanced view corresponding to the first branch and the second branch respectively, and are recorded as and ;

[0017] Create an enhanced dataset, denoted as , the corresponding calculation formula is:

[0018]

[0019] in, Represents the first enhanced views and corresponding category labels; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Indicates the image dataset image samples.

[0020] Preferably, determining the feature embeddings corresponding to the first branch and the second branch based on the enhanced dataset and calculating the prototype of each category includes:

[0021] Determine the feature embeddings corresponding to the first branch and the second branch through the enhanced dataset and perform normalization;

[0022] Based on the category labels and the normalized feature embedding, the prototype of each category is determined.

[0023] Preferably, the feature embedding corresponding to the first branch and the second branch is determined by enhancing the data set and normalized. The corresponding calculation formula is:

[0024]

[0025]

[0026] in, Indicates the first Feature embedding of enhanced views; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; express , represents the augmented dataset; Indicates the image dataset image samples; Represents the normalized feature embedding.

[0027] Preferably, the corresponding calculation formula for determining each category prototype is:

[0028]

[0029] in, Indicates the The category prototype of each category, , Indicates the total number of categories; Represents an augmented dataset Belong to the A collection of sample indexes of categories; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Represents the first Feature embedding of an enhanced view.

[0030] Preferably, a dynamic hybrid update strategy is adopted to train the supervised contrastive learning network model, the supervised contrastive loss function is determined in combination with the category prototype, and the first branch and the second branch are updated in sequence, including:

[0031] Calculate the dynamic hybrid update weight parameters and determine the supervised contrast loss function through the category prototype;

[0032] The gradient descent method is used to update the model parameters of the first branch, and the updated model parameters of the first branch are combined with the dynamic hybrid update weight parameters and the supervised contrast loss function to update the model parameters of the second branch using the gradient-momentum hybrid method.

[0033] Preferably, calculating the dynamic hybrid update weight parameters and determining the supervised contrast loss function through the category prototypes includes:

[0034] Calculate the dynamic hybrid update weight parameter, the corresponding calculation formula is:

[0035]

[0036] in, Represents dynamic hybrid update weight parameters; Indicates the current training round number; Indicates the starting training round number of dynamic hybrid update; Indicates the number of training rounds required to complete the dynamic hybrid update;

[0037] Determine the supervised contrast loss function, and the corresponding calculation formula is:

[0038]

[0039] in, represents the supervised contrast loss function; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Indicates the total number of categories; Represents the first Feature embedding of enhanced views; Indicates the first Enhanced View Category Representation category The corresponding category prototype; Indicates the first Category prototypes of categories; Indicates belonging to a category The sample index set of ; represents the category indicator function, when hour, ; represents the temperature hyperparameter.

[0040] Preferably, the model parameters of the first branch are updated using the gradient descent method, and the updated model parameters of the first branch are combined with the dynamic hybrid update weight parameters and the supervised contrast loss function to update the model parameters of the second branch using the gradient-momentum hybrid method, including:

[0041] Update the model parameters of the first branch. The corresponding calculation formula is:

[0042]

[0043] in, represents the updated model parameters of the first branch; represents the model parameters of the first branch; represents the learning rate, ; represents the supervised contrast loss function; represents the gradient operation;

[0044] Update the model parameters of the second branch. The corresponding calculation formula is:

[0045]

[0046] in, represents the updated model parameters of the second branch; Represents dynamic hybrid update weight parameters; represents the model parameters of the second branch; represents the momentum coefficient, .

[0047] Preferably, judging whether the current number of training rounds is less than the preset total number of training rounds, and if not, outputting the trained supervised contrastive learning network model, including:

[0048] Define the current number of training rounds as , the preset total number of training rounds is ;when When , the trained supervised contrastive learning network model is output; when When, based on , redetermine the feature embedding and category prototype, iteratively train the first branch and the second branch until the current number of training rounds is greater than the preset total number of training rounds, and obtain the supervised contrastive learning network model.

[0049] The present invention has the following beneficial effects:

[0050] A dynamic hybrid update strategy with branch differentiation is implemented through the first branch and the second branch. The gradient descent and momentum update mechanisms are integrated to prevent the model parameter update strategy from being single, which not only ensures the stability of training, but also effectively improves the convergence speed and final performance of the supervised contrastive learning network model. The model parameters of each branch are dynamically adjusted and updated during the training process. At the same time, a supervised contrast loss function based on category prototype is introduced, and the feature space distribution is optimized using label information to obtain the trained supervised contrastive learning network model and obtain a better-performing image feature extractor. This avoids intensive calculations between direct sample pairs, reduces the sensitivity of the supervised contrastive learning network model to small sample categories, and improves the efficiency of large-scale training and the stability of loss calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0052] Figure 1 A flowchart of a method for extracting image features through supervised contrastive learning based on a dynamic hybrid update strategy provided by one embodiment of the present invention;

[0053] Figure 2 A schematic diagram of the network structure of a supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] To further illustrate the technical means and effects employed by the present invention to achieve the intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail the specific implementation, structure, features, and effects of a supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy proposed by the present invention. In the following description, different references to "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.

[0055] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0056] The following describes in detail a specific solution of a supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy provided by the present invention in conjunction with the accompanying drawings.

[0057] Please combine Figure 1 and Figure 2 , which shows a flowchart and a network structure diagram of a supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy provided by an embodiment of the present invention, the method comprising:

[0058] Step S1: Acquire an image dataset, which includes image samples and corresponding category labels, and establish a supervised contrastive learning network model, including a first branch and a second branch established in parallel;

[0059] Step S2: performing enhancement processing on each image sample in the image dataset to obtain a first enhanced view and a second enhanced view corresponding to the first branch and the second branch respectively, and establishing an enhanced dataset;

[0060] Step S3: Determine the feature embeddings corresponding to the first branch and the second branch based on the enhanced dataset, and calculate the prototype of each category;

[0061] Step S4: adopting a dynamic hybrid update strategy to train the supervised contrastive learning network model, combining the category prototype to determine the supervised contrastive loss function, and updating the first branch and the second branch in sequence;

[0062] Step S5: judging whether the current number of training rounds is less than the preset total number of training rounds, and if not, outputting the trained supervised contrastive learning network model;

[0063] Step S6: Obtain a sample of the image to be detected, and input the sample of the image to be detected into the trained supervised contrastive learning network model to obtain a feature vector.

[0064] To better illustrate, the model parameter update strategy of the traditional supervised contrastive learning method is relatively simple, usually using synchronous gradient update or asynchronous momentum update; among them, although the synchronous gradient update can ensure that each parameter is updated at the same time point, it leads to high gradient calculation overhead, especially for large-scale data sets, which increases the training time, and when synchronously updating, all parameters need to reach the optimal state at the same time in each iterative step, resulting in slow convergence of the early model; on the other hand, asynchronous momentum update can alleviate the computational overhead problem of synchronous update to a certain extent, but it also has certain limitations. The momentum parameter update speed of its auxiliary branch is slow, and it is difficult to quickly adapt to data changes in practical applications, resulting in reduced model performance, and the slow update of the momentum parameter causes the model to fall into a local optimal solution during the optimization process, making it difficult to reach the global optimal state; therefore, by introducing a dynamic hybrid update mechanism and a supervised contrast loss function based on category prototypes, while retaining the advantages of supervised contrastive learning, the discrimination ability and training efficiency of the supervised contrastive learning network model are improved.

[0065] Furthermore, in step S1, an image dataset is obtained and a supervised contrastive learning network model is established, including:

[0066] The image dataset is ,in, Represents the total number of image datasets; Indicates the image dataset image samples; Indicates the corresponding The category labels of image samples, , Indicates the total number of categories; Indicates that the corresponding image sample belongs to categories;

[0067] The first branch and the second branch are established in parallel, and the first branch is defined as , the second branch is , the corresponding branch parameters are and , both include image feature extractor and projection head, denoted as , ; , ;in, Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head.

[0068] It is explained that the supervised contrastive learning network model consists of two parallel branches, the first branch and the second branch, where the first branch is denoted as A and the second branch is denoted as B. For practical applications, each branch consists of two sub-networks, an image feature extractor and a camera, and the two branches are the same but the model parameters are independent, that is, the features in the image samples are processed in parallel by the image feature extractors of two independent branches, and the dimensionality reduction and optimization of the features are achieved through the camera to analyze the image samples; and in the image dataset, Indicates the corresponding The category label of the image sample can be explained as follows: The one-hot encoded true label, in this example, , represents the image sample Belong to categories, while all other ,and .

[0069] Furthermore, step S2 includes:

[0070] Step S21: Perform enhancement processing of random cropping and scaling, random horizontal flipping, color jittering, random grayscale conversion, and normalization operations on each image sample in the image dataset to obtain the first enhanced view and the second enhanced view corresponding to the first branch and the second branch respectively, and record them as and .

[0071] To explain, the random cropping and scaling operations are to randomly crop a part of the area of ​​each image sample and scale the area to a fixed size; random horizontal flipping is to randomly flip each image sample left and right to increase the diversity of the image samples; color jittering is to change the color of the image samples by adding color channels of the image samples, thereby further increasing the diversity of the image samples; random grayscale is to convert the image samples into grayscale images to simulate different lighting conditions; standardization operation is to subtract the mean and divide by the standard deviation so that the image samples have zero mean and unit variance, which is convenient for model learning; that is, each image sample is enhanced for the image data set, and both branches are enhanced, and the corresponding enhanced views are obtained for the subsequent enhancement of the generalization ability and robustness of the model.

[0072] Step S22: Create an enhanced data set, denoted as , the corresponding calculation formula is:

[0073]

[0074] in, Represents the first enhanced views and corresponding category labels; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Indicates the image dataset image samples.

[0075] It can be understood that each image sample in the image data set obtains two corresponding enhanced views after the enhancement operation of the first branch and the second branch. For example, assuming the first image sample in the image data set, that is, In the augmented dataset, and These two corresponding enhanced views; then for the second image sample, that is, , which corresponds to the 3rd and 4th enhanced views, and so on, to obtain the enhanced views corresponding to all image samples in the image dataset.

[0076] Furthermore, step S3 includes:

[0077] Step S31: Determine the feature embedding corresponding to the first branch and the second branch through the enhanced data set and perform normalization.

[0078] It can be understood that the enhanced dataset can better capture the key features in the image samples, and the feature embedding representation embeds the corresponding key features into a high-dimensional space, so as to facilitate the fine representation of the feature information of each image sample; and the normalization processing of the feature embedding is to adjust it to the same range to eliminate the dimensional differences between different features, so that it can be analyzed and calculated on the same scale, so that useful feature representations can be learned more stably and efficiently in the subsequent training process.

[0079] Furthermore, in step S31, the corresponding calculation formula is:

[0080]

[0081]

[0082] in, Indicates the first Feature embedding of enhanced views; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; express , represents the augmented dataset; Indicates the image dataset image samples; Represents the normalized feature embedding.

[0083] Step S32: Based on the category labels and the normalized feature embedding, determine the prototype of each category.

[0084] It can be understood that the category prototype refers to the typical or central point corresponding to any category in the feature space, that is, the comprehensive representation obtained by aggregating the feature embeddings of all image samples in the category, which is used to capture the common features and attributes of the image samples in the category, which is conducive to subsequent feature recognition and feature extraction.

[0085] Furthermore, in step S32, each category prototype is determined, and the corresponding calculation formula is:

[0086]

[0087] in, Indicates the The category prototype of each category, , Indicates the total number of categories; Represents an augmented dataset Belong to the A collection of sample indexes of categories; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Represents the first Feature embedding of an enhanced view.

[0088] Furthermore, step S4 includes:

[0089] Step S41: Calculate the dynamic hybrid update weight parameters and determine the supervised contrast loss function through the category prototype.

[0090] Furthermore, step S41 includes:

[0091] Step S411: Calculate the dynamic hybrid update weight parameter, the corresponding calculation formula is:

[0092]

[0093] in, Represents dynamic hybrid update weight parameters; Indicates the current training round number; Indicates the starting training round number of dynamic hybrid update; Indicates the number of training rounds required to complete the dynamic hybrid update;

[0094] Step S412: Determine the supervised contrast loss function, the corresponding calculation formula is:

[0095]

[0096] in, represents the supervised contrast loss function; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Indicates the total number of categories; Represents the first Feature embedding of enhanced views; Indicates the first Enhanced View Category Representation category The corresponding category prototype; Indicates the first Category prototypes of categories; Indicates belonging to a category The sample index set of ; represents the category indicator function, when hour, ; represents the temperature hyperparameter.

[0097] Explanation is given to calculating the dynamic hybrid update weight parameters to ensure that the model can better adapt to changes in image samples; and the supervised contrast loss function is determined through category prototypes, so that the model can more accurately identify and distinguish different categories during the learning process, thereby improving the generalization ability of the model and enhancing its performance in classification tasks.

[0098] Preferably, the preset total number of training rounds is , Indicates the number of training rounds to start with dynamic hybrid update, which is the total number of training rounds 30%; Indicates the number of training rounds required to complete the dynamic hybrid update, which is the total number of training rounds 20%; represents the category indicator function, when hour, , on the contrary, when hour, .

[0099] Step S42: Use the gradient descent method to update the model parameters of the first branch, and combine the updated model parameters of the first branch with the dynamic hybrid update weight parameters and the supervised contrast loss function to update the model parameters of the second branch using the gradient-momentum hybrid method.

[0100] It can be explained that by calculating the gradient of the loss function relative to the model parameters, and then dynamically adjusting the learning rate in the opposite direction of the gradient, it can converge quickly and avoid falling into the local optimal solution to update the model parameters of the first branch; that is, using dynamic hybrid update weight parameters to adjust the balance between the various parameters, determine the update speed and direction, and then use the supervised contrast loss function to ensure that the model can better capture the similarities and differences between image samples during the training process. Combined with the hybrid method of gradient descent and momentum optimization, the model parameters are updated in the direction of reducing the loss function during training, and the momentum coefficient assists the accumulation of a certain inertia in the process of model parameter update, which can accelerate the convergence speed during the optimization process and avoid falling into the local optimal solution, thereby achieving a more stable and efficient update of the model parameters of the second branch.

[0101] Furthermore, step S42 includes:

[0102] Step S421: Update the model parameters of the first branch. The corresponding calculation formula is:

[0103]

[0104] in, represents the updated model parameters of the first branch; represents the model parameters of the first branch; represents the learning rate, ; represents the supervised contrast loss function; represents the gradient operation;

[0105] Step S422: Update the model parameters of the second branch. The corresponding calculation formula is:

[0106]

[0107] in, represents the updated model parameters of the second branch; Represents dynamic hybrid update weight parameters; represents the model parameters of the second branch; represents the momentum coefficient, .

[0108] Furthermore, step S5 includes:

[0109] Define the current number of training rounds as , the preset total number of training rounds is ;when When , the trained supervised contrastive learning network model is output; when When, based on , redetermine the feature embedding and category prototype, iteratively train the first branch and the second branch until the current number of training rounds is greater than the preset total number of training rounds, and obtain the supervised contrastive learning network model.

[0110] Make an explanation when When , the trained supervised contrast learning network model is output, that is, the final image feature extractor is obtained or ;when When, based on , redetermine the feature embedding and category prototype, iteratively train the first branch and the second branch, that is, return to step S3, and adjust the current number of training rounds to determine , re-execute steps S3-S5 until , and obtain the corresponding image feature extractor.

[0111] It can be explained that in step S6, the image sample to be detected is obtained, and the image sample to be detected is input into the trained supervised contrast learning network model to obtain a feature vector; that is, the image sample to be detected is input into the image feature extractor obtained in step S5, and the feature vector corresponding to the image sample is output.

[0112] For better explanation, in order to verify the effectiveness of the supervised contrastive learning image feature extraction method based on the dynamic hybrid update strategy proposed in this application, in this embodiment, the parameters of the image feature extractor of the first branch in the supervised contrastive learning model are initialized. , parameters of projection head , so the model parameters of the first branch are determined ; Parameters of the image feature extractor of the second branch B , parameters of projection head , determine the model parameters of the second branch .

[0113] Assume that the image dataset , which means that there is a total Image samples are divided into 3 categories, each category includes 10 image samples, and the corresponding category labels is a one-hot encoding, where 、 、 Represents the 1st, 2nd, and 3rd category image samples respectively; then, each original image sample in the image dataset is enhanced to obtain the enhanced view of each branch and , establish an enhanced dataset as .

[0114] Then define the preset total number of training rounds as , temperature coefficient , momentum coefficient , determine the number of training rounds to start when using the dynamic hybrid update strategy , the number of training rounds required to complete the hybrid update , learning rate ; In the current training round hour, , respectively, through the first branch A and the second branch B to obtain feature embedding , the corresponding calculation formula is:

[0115]

[0116]

[0117]

[0118]

[0119] Then the corresponding feature embedding Perform normalization to obtain normalized feature embedding. The corresponding calculation formula is:

[0120]

[0121]

[0122]

[0123]

[0124] Determine the index set of image samples of category 1 as , the index set of the second type of image samples is , the index set of the third type of image samples is ; Calculate the category prototype of the first category image sample: ; Similarly, determine the category prototypes of the second and third category image samples:

[0125]

[0126]

[0127] Calculate dynamic mixing update weight parameters , the current number of training rounds ,but ; According to the calculation , use gradient descent method to update the model parameters of the first branch A , the corresponding calculation formula is:

[0128]

[0129] Because the currently determined dynamic hybrid update weight parameters , so the model parameters of the current second branch B are completely updated using momentum, and the corresponding calculation formula is:

[0130]

[0131] Due to the current number of training rounds , is less than the preset total number of training rounds, then , return to step S3, and , repeat steps S3-S5 until When the current number of training rounds reaches the preset total number of training rounds, the final image feature extractor is output or .

[0132] It can be understood that the dynamic hybrid update strategy of branch differentiation is realized through the first branch and the second branch, and the gradient descent and momentum update mechanisms are integrated to prevent the model parameter update strategy from being single, which not only ensures the stability of training, but also effectively improves the convergence speed and final performance of the supervised contrastive learning network model; and dynamically adjusts the model parameters of each branch of the hybrid update during the training process. At the same time, a supervised contrast loss function based on category prototype is introduced, and the feature space distribution is optimized using label information to obtain the trained supervised contrastive learning network model, thereby obtaining an image feature extractor with better performance, avoiding intensive calculations between direct sample pairs, reducing the sensitivity of the supervised contrastive learning network model to small sample categories, and improving the efficiency of large-scale training and the stability of loss calculation.

[0133] It should be noted that the order in which the embodiments of the present invention are described above is for illustrative purposes only and does not necessarily represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0134] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.

Claims

1. A supervised contrastive learning image feature extraction method based on a dynamic hybrid update strategy, characterized in that: The method comprises: Acquire an image dataset, the image dataset including image samples and corresponding category labels, and establish a supervised contrastive learning network model, including a first branch and a second branch established in parallel; Performing enhancement processing on each image sample in the image data set to obtain a first enhanced view and a second enhanced view corresponding to the first branch and the second branch, respectively, and establishing an enhanced data set; Determine the feature embeddings corresponding to the first branch and the second branch based on the enhanced dataset, and calculate the prototype of each category; A dynamic hybrid update strategy is used to train the supervised contrastive learning network model. The supervised contrastive loss function is determined by combining the category prototypes, and the first and second branches are updated sequentially. Determine whether the current number of training rounds is less than the preset total number of training rounds. If not, output the trained supervised contrastive learning network model. Obtain an image sample to be detected, input the image sample to be detected into the trained supervised contrastive learning network model, and obtain a feature vector.

2. The supervised contrast learning image feature extraction method based on dynamic hybrid update strategy according to claim 1 is characterized in that: Obtain an image dataset and build a supervised contrastive learning network model, including: The image dataset is ,in, Represents the total number of image datasets; Indicates the image dataset image samples; Indicates the corresponding The category labels of image samples, , Indicates the total number of categories; Indicates that the corresponding image sample belongs to categories; The first branch and the second branch are established in parallel, and the first branch is defined as , the second branch is , the corresponding branch parameters are and , both include image feature extractor and projection head, denoted as , ; , ;in, Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head.

3. The supervised contrastive learning image feature extraction method based on dynamic hybrid update strategy according to claim 1 is characterized in that: Performing enhancement processing on each image sample in the image data set to obtain a first enhanced view and a second enhanced view corresponding to the first branch and the second branch respectively, and establishing an enhanced data set, including: Each image sample in the image dataset is subjected to enhancement processing by random cropping and scaling, random horizontal flipping, color jittering, random grayscale conversion, and standardization operations to obtain the first enhanced view and the second enhanced view corresponding to the first branch and the second branch respectively, and are recorded as and ; Create an enhanced dataset, denoted as , the corresponding calculation formula is: ; in, Represents the first enhanced views and corresponding category labels; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Indicates the image dataset image samples.

4. The supervised contrastive learning image feature extraction method based on dynamic hybrid update strategy according to claim 1 is characterized in that: Determine the feature embeddings corresponding to the first and second branches based on the augmented dataset, and calculate the prototype of each category, including: Determine the feature embeddings corresponding to the first branch and the second branch through the enhanced dataset and perform normalization; Based on the category labels and the normalized feature embedding, the prototype of each category is determined.

5. The supervised contrastive learning image feature extraction method based on dynamic hybrid update strategy according to claim 4 is characterized in that: The feature embeddings corresponding to the first and second branches are determined by enhancing the data set and normalized. The corresponding calculation formula is: ; ; in, Indicates the first Feature embedding of enhanced views; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; Indicates that the parameter is Image feature extractor; Indicates that the parameter is projection head; express , represents the augmented dataset; Indicates the image dataset image samples; Represents the normalized feature embedding.

6. The supervised contrast learning image feature extraction method based on dynamic hybrid update strategy according to claim 4 is characterized in that: Determine the prototype of each category, and the corresponding calculation formula is: ; in, Indicates the The category prototype of each category, , Indicates the total number of categories; Represents an augmented dataset Belong to the A collection of sample indexes of categories; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Represents the first Feature embedding of an enhanced view.

7. The supervised contrastive learning image feature extraction method based on dynamic hybrid update strategy according to claim 1 is characterized in that: A dynamic hybrid update strategy is used to train the supervised contrastive learning network model. The supervised contrastive loss function is determined in combination with the category prototype. The first branch and the second branch are updated sequentially, including: Calculate the dynamic hybrid update weight parameters and determine the supervised contrast loss function through the category prototype; The gradient descent method is used to update the model parameters of the first branch, and the updated model parameters of the first branch are combined with the dynamic hybrid update weight parameters and the supervised contrast loss function to update the model parameters of the second branch using the gradient-momentum hybrid method.

8. The supervised contrast learning image feature extraction method based on dynamic hybrid update strategy according to claim 7 is characterized in that: Calculate the dynamic hybrid update weight parameters and determine the supervised contrast loss function through the category prototype, including: Calculate the dynamic hybrid update weight parameter, the corresponding calculation formula is: ; in, Represents dynamic hybrid update weight parameters; Indicates the current training round number; Indicates the starting training round number of dynamic hybrid update; Indicates the number of training rounds required to complete the dynamic hybrid update; Determine the supervised contrast loss function, and the corresponding calculation formula is: ; in, represents the supervised contrast loss function; represents the total number of image datasets, that is, the total number of all first enhanced views or second enhanced views; Indicates the total number of categories; Represents the first Feature embedding of enhanced views; Indicates the first Enhanced View Category Representation category The corresponding category prototype; Indicates the first Category prototypes of categories; Indicates belonging to a category The sample index set of ; represents the category indicator function, when hour, ; represents the temperature hyperparameter.

9. The supervised contrastive learning image feature extraction method based on dynamic hybrid update strategy according to claim 7, characterized in that: The model parameters of the first branch are updated using the gradient descent method. The updated model parameters of the first branch are combined with the dynamic hybrid update weight parameters and the supervised contrast loss function to update the model parameters of the second branch using the gradient-momentum hybrid method, including: Update the model parameters of the first branch. The corresponding calculation formula is: ; in, represents the updated model parameters of the first branch; represents the model parameters of the first branch; represents the learning rate, ; represents the supervised contrast loss function; represents the gradient operation; Update the model parameters of the second branch. The corresponding calculation formula is: ; in, represents the updated model parameters of the second branch; Represents dynamic hybrid update weight parameters; represents the model parameters of the second branch; represents the momentum coefficient, .

10. The supervised contrast learning image feature extraction method based on dynamic hybrid update strategy according to claim 1, characterized in that: Determine whether the current number of training rounds is less than the preset total number of training rounds. If not, output the trained supervised contrastive learning network model, including: Define the current number of training rounds as , the preset total number of training rounds is ;when When , the trained supervised contrastive learning network model is output; when When, based on , redetermine the feature embedding and category prototype, iteratively train the first branch and the second branch until the current number of training rounds is greater than the preset total number of training rounds, and obtain the supervised contrastive learning network model.

Citation Information

Cited By

  • Deformation field prediction method based on image quality evaluation and adaptive pre-training

    CN121811183A