Method for classifying data based on model of few-sample learning and related equipment
Through a model based on few-shot learning, feature templates and similarity matrices are used for action recognition, which solves the problems of high sample data dependence and low classification accuracy in the existing technology, and achieves efficient and accurate action recognition effects.
Patent Information
- Application Number
- CN202410839213.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-26
AI Technical Summary
Existing action recognition methods based on Wi-Fi technology require a large amount of labeled sample data for training, resulting in high costs and poor classification performance and generalization performance, especially low accuracy in action recognition in different domains.
A model based on few-shot learning is proposed. By obtaining multiple feature templates of the data to be classified and the preset target model, the feature similarity matrix is used to perform feature weighting calculations to determine the target feature template and category to achieve data classification.
It reduces the cost of model training, improves the accuracy and generalization ability of data classification, and can achieve efficient learning and accurate classification with a small number of samples.
Smart Images

Figure CN118690232A
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data classification, and in particular to a method for classifying data based on a few-sample learning model and related equipment. Background Art
[0002] At present, motion recognition technology has broad application prospects in many fields. For example, in the automotive, medical, education and other industries, motion recognition technology can help users better operate equipment and improve work efficiency and safety. And because Wi-Fi signals have the characteristics of wide coverage, penetration and strong privacy, they can effectively deal with recognition problems such as insufficient light, privacy protection and line of sight obstruction. Therefore, Wi-Fi technology is widely used in motion recognition scenarios.
[0003] In the related art, most of the recognition methods based on Wi-Fi technology actions collect a large amount of action sample data and label the corresponding action labels, and train the classifier through these large amounts of labeled sample data to classify and recognize different actions. However, this method requires a large amount of labeled sample data to train the recognition model, and the collection and labeling costs of labeled sample data are high; in addition, the classification performance and generalization performance of a single classifier are poor, and when recognizing actions from different domains (such as different locations or different people), the classification accuracy is low. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a method and related equipment for data classification based on a model of few-sample learning, which can improve the accuracy of data classification while reducing the training cost of the model.
[0005] To achieve the above objectives, a first aspect of an embodiment of the present application proposes a method for classifying data based on a model of few-sample learning, the method comprising:
[0006] Obtain data to be classified;
[0007] Acquire a preset target model and a plurality of first feature templates of the target model; wherein the target model is obtained by performing a first comparison training with a preset first sample label based on a first similarity matrix obtained by the preset model based on a sample feature relationship between a plurality of first sample data, and a second comparison training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on a plurality of first sample data under each first sample label according to the first similarity matrix corresponding to the plurality of first sample data;
[0008] Inputting the data to be classified and the plurality of first feature templates into the target model to obtain a plurality of feature similarities between the data to be classified and the plurality of first feature templates respectively;
[0009] Based on the multiple feature similarities, determine the first feature template having the greatest feature similarity to the feature of the data to be classified as a target feature template, and determine a target category corresponding to the target feature template;
[0010] The target category is determined as a classification result of the data to be classified.
[0011] Accordingly, a second aspect of an embodiment of the present application proposes a device for classifying data based on a model of few-sample learning, the device comprising:
[0012] A first acquisition module, used to acquire data to be classified;
[0013] A second acquisition module is used to acquire a preset target model and a plurality of first feature templates of the target model; wherein the target model is obtained by performing a first comparison training between a first similarity matrix obtained by the preset model based on a sample feature relationship between a plurality of first sample data and a preset first sample label, and a second comparison training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on a plurality of first sample data under each first sample label according to the first similarity matrix corresponding to the plurality of first sample data;
[0014] An input module, used for inputting the data to be classified and the plurality of first feature templates into the target model, and obtaining a plurality of feature similarities between the data to be classified and the plurality of first feature templates respectively;
[0015] A first determination module is used to determine, based on the multiple feature similarities, the first feature template having the greatest feature similarity to the feature of the data to be classified as a target feature template, and determine a target category corresponding to the target feature template;
[0016] The second determination module is used to determine the target category as the classification result of the data to be classified.
[0017] In some embodiments, the apparatus for classifying data based on a few-sample learning model further includes a training module for:
[0018] Acquire a sample training set, and perform a first comparative training and a second comparative training on a preset model according to the sample training set to obtain a first target model;
[0019] When there is no sample support set for training the first target model, using the first target model as a target model;
[0020] When there is a sample support set for training the first target model, third comparative training and fourth comparative training are performed on the first target model based on the sample support set to obtain a target model; wherein there is no intersection between the sample training set and the sample support set; and the category of the data to be classified is the same as at least one sample label contained in the sample support set.
[0021] In some embodiments, the training module is further used to:
[0022] Inputting a plurality of first sample data in the sample training set into a preset model, obtaining a first similarity matrix corresponding to the plurality of first sample data; wherein the first similarity matrix is used to characterize the similarity between any two of the first sample data;
[0023] Obtaining a first sample label of each of the first sample data, and determining a first cross entropy loss of the preset model according to the similarity between any two first sample data and the first sample label;
[0024] Adjusting the parameters of the preset model according to the first cross entropy loss to obtain a first preset model after performing a first comparative training on the preset model;
[0025] Acquire multiple first feature templates corresponding to the sample training set, and calculate the second cross entropy loss of the first preset model based on the similarity between any two of the first sample data and the corresponding first feature templates;
[0026] The parameters of the first preset model are adjusted according to the second cross entropy loss to obtain a first target model after the second comparative training of the first preset model.
[0027] In some embodiments, the training module is further used to:
[0028] Determining a sample quality score of each of the first sample data based on the first similarity matrix;
[0029] For each first sample label in the sample training set, determine the product of each first sample data in the first sample label and the corresponding sample quality score, and accumulate multiple products corresponding to multiple first sample data under the first sample label to obtain a first product sum corresponding to the first sample label;
[0030] A sum of multiple sample quality scores of multiple first sample data under the first sample label is obtained, and a ratio of the first product sum to the sum of the multiple sample quality scores is used as a first feature template corresponding to the first sample label.
[0031] In some embodiments, the training module is further used to:
[0032] Obtaining a first similarity matrix corresponding to a plurality of first sample data;
[0033] Inputting the first similarity matrix into the convolution layer of the first preset model to obtain a plurality of sample quality scores corresponding to the plurality of first sample data;
[0034] The sample quality score is determined by the convolution layer for each of the first sample data, by determining multiple similarities between each of the first sample data and multiple other first sample data from the first similarity matrix, and based on the differences between the multiple similarities.
[0035] In some embodiments, the training module is further used to:
[0036] When there is a sample support set for training the first target model, a plurality of second sample data in the sample support set is input into the first target model to obtain a second similarity matrix corresponding to the plurality of second sample data; wherein the second similarity matrix is used to characterize the similarity between any two second sample data;
[0037] Obtaining second sample labels of the two second sample data, and determining a third cross entropy loss of the preset model according to the similarity between any two second sample data and the second sample labels;
[0038] Adjusting the parameters of the first target model according to the third cross entropy loss to obtain a second preset model after performing a third comparative training on the first target model;
[0039] Acquire multiple second feature templates corresponding to the sample support set, and calculate a fourth cross entropy loss of the second preset model based on the similarity between any two second sample data and the corresponding second feature templates;
[0040] The parameters of the second preset model are adjusted according to the fourth cross entropy loss to obtain a target model after comparative training of the second preset model.
[0041] In some implementations, the second acquisition module is further configured to:
[0042] Copying a plurality of first sample data to obtain sample copy data;
[0043] Input the first sample data as a first input to a preset model, input the sample copy data as a second input to the preset model, and obtain a plurality of feature similarities calculated by the preset model according to a sample feature relationship of any sample between the first sample data and the sample copy data;
[0044] Based on the multiple feature similarities, a first similarity matrix corresponding to the multiple first sample data is obtained.
[0045] To achieve the above-mentioned purpose, the third aspect of the embodiments of the present application proposes a computer device, which includes a memory and a processor, and the memory stores a computer program. When the processor executes the computer program, it implements the method for classifying data based on a model of few-sample learning as described in any one of the embodiments of the first aspect of the present application.
[0046] To achieve the above-mentioned objectives, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method for classifying data based on a model of few-sample learning as described in any one of the embodiments of the first aspect of the present application.
[0047] The embodiment of the present application obtains data to be classified; obtains a preset target model and multiple first feature templates of the target model; wherein the target model is obtained by a first similarity matrix obtained by the preset model based on the sample feature relationship between multiple first sample data, a first comparative training with a preset first sample label, and a second comparative training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on multiple first sample data under each first sample label according to the first similarity matrix corresponding to the multiple first sample data; the data to be classified and the multiple first feature templates are input into the target model to obtain multiple feature similarities between the data to be classified and the multiple first feature templates; based on the multiple feature similarities, the first feature template with the largest feature similarity with the data to be classified is determined as the target feature template, and the target category corresponding to the target feature template is determined; the target category is determined as the classification result of the data to be classified. In this way, the category features can be characterized by the first feature template, and efficient learning and accurate classification of a small number of samples can be achieved, reducing the dependence on traditional large-scale sample training, thereby reducing the training cost. At the same time, since the first feature template can accurately reflect the essential characteristics of the same type of data, the classification result can be more accurately determined by matching the similarity between the data to be classified and the first feature template. In summary, the present application can improve the accuracy of data classification while reducing the training cost of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1It is a schematic diagram of the architecture of a system for classifying data based on a model of few-sample learning provided in an embodiment of the present application;
[0049] Figure 2 is a flowchart of a method for classifying data based on a model of few-sample learning provided in an embodiment of the present application;
[0050] Figure 3 is a CSi-Net network structure diagram provided in an embodiment of the present application;
[0051] Figure 4 is a flowchart of the steps for training a preset model provided in an embodiment of the present application;
[0052] Figure 5 is a structural diagram of a Weight-Net network provided in an embodiment of the present application;
[0053] Figure 6 It is an overall flow chart of a method for classifying data based on a model of few-sample learning provided in an embodiment of the present application;
[0054] Figure 7 It is a functional module diagram of a device for classifying data based on a model of few-sample learning provided in an embodiment of the present application;
[0055] Figure 8 It is a schematic diagram of the hardware structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0059] At present, motion recognition technology has broad application prospects in many fields. For example, in the automotive, medical, education and other industries, motion recognition technology can help users better operate equipment and improve work efficiency and safety. And because Wi-Fi signals have the characteristics of wide coverage, penetration and strong privacy, they can effectively deal with recognition problems such as insufficient light, privacy protection and line of sight obstruction. Therefore, Wi-Fi technology is widely used in motion recognition scenarios.
[0060] In the related art, most of the recognition methods based on Wi-Fi technology actions collect a large amount of action sample data and label the corresponding action labels, and train the classifier through these large amounts of labeled sample data to classify and recognize different actions. However, this method requires a large amount of labeled sample data to train the recognition model, and the collection and labeling costs of labeled sample data are high; in addition, the classification performance and generalization performance of a single classifier are poor, and when recognizing actions from different domains (such as different locations or different people), the classification accuracy is low.
[0061] Based on this, the embodiments of the present application provide a method and related equipment for classifying data based on a model of few-sample learning, which can improve the accuracy of data classification while reducing the training cost of the model.
[0062] The method and related equipment for classifying data based on a model of few-sample learning provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the system for classifying data based on a model of few-sample learning in the embodiments of the present application is described.
[0063] Please refer to Figure 1 In some implementations, an embodiment of the present application provides a system for classifying data based on a few-sample learning model, including a terminal 11 and a server 12 , and the terminal 11 can work in conjunction with the server 12 .
[0064] Specifically, the terminal 11 is a front-end device of a system for classifying data based on a model of few-sample learning, and can be a user's computer, mobile phone, or any other data input device. Exemplarily, the terminal 11 can be responsible for obtaining the data to be classified and sending it to the server 12 for processing. The data to be classified can come from user input, sensor data, file upload, etc. The terminal 11 can also receive the classification result processed by the server 12 and display the result to the user.
[0065] Furthermore, the server 12 can be the core processing unit of the system for data classification based on the model of few-sample learning, responsible for receiving data from the terminal 11 and performing complex model training and data classification tasks. For example, the server 12 can perform functions such as model training, data classification, model maintenance and data processing.
[0066] The terminal 11 and the server 12 of the system for classifying data based on a model of few-sample learning work together to achieve automation, accuracy and efficiency of data classification.
[0067] The method for classifying data based on a few-sample learning model in the embodiments of the present application can be illustrated by the following embodiments.
[0068] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first. Moreover, the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or separate consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or separate consent, the necessary user-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0069] In the embodiment of the present application, the device for classifying data based on a model of few-sample learning is described from the perspective of the device, and the device for classifying data based on a model of few-sample learning can be integrated in a computer device. Figure 2 , Figure 2 The flowchart of the steps of the method for classifying data based on a model of few-sample learning provided in the embodiment of the present application is as follows: The embodiment of the present application takes the device for classifying data based on a model of few-sample learning as an example, in which the device is specifically integrated on a terminal or a server. When the processor on the terminal or the server executes the program instructions corresponding to the method for classifying data based on a model of few-sample learning, the specific process is as follows:
[0070] Step 101, obtaining data to be classified.
[0071] In some implementations, in order to perform a classification task, the data to be classified is divided into pre-defined categories, and the data to be classified can be obtained for processing to facilitate the subsequent completion of the classification task.
[0072] The data to be classified may be data items that have not been labeled or classified. Exemplarily, the data to be classified may be obtained from public data sets, user-generated content, internal enterprise data, crowdsourcing annotation services, and self-built data sets, and the data to be classified may be determined by a specific classification task. Furthermore, the data to be classified may be channel state information (CSI) collected when the detected person performs a specific gesture action.
[0073] Through the above method, the data to be classified can be obtained, so as to facilitate the subsequent rapid processing of the classification task of the data to be classified.
[0074] In some implementations, some data points may be lost due to sensor failure, network transmission problems, environmental interference problems, etc. during data collection. Therefore, in order to improve the integrity of the data, eliminate the deviations and defects in the data source, and ensure the normal operation of the target model, it is necessary to complete the missing data points to improve the performance of data classification, such as improving the performance of human gesture and human posture recognition. For example, step 101 also includes:
[0075] (101.1) obtaining data to be classified, and detecting each data point in the data to be classified to obtain a detection result;
[0076] (101.2) When the detection result indicates that the difference between the existing data point and the adjacent data point exceeds the missing threshold, the corresponding data point is determined as a missing data point;
[0077] (101.3) determining a target interpolation method for interpolating missing data points based on the distribution of the plurality of data points;
[0078] (101.4) calculating interpolated values of missing data points based on at least two adjacent data points by target interpolation;
[0079] (101.5) Fill the missing data points with interpolated values to obtain supplemented data to be classified.
[0080] The detection result may be information obtained after analyzing the data through a specific algorithm or method, and is used to determine outliers or missing data points in the data set.
[0081] The missing threshold may be a preset critical value used to determine whether the difference between data points is too large, thereby determining whether the data point is considered missing. The missing threshold may be set based on the specific characteristics of the data, the expected normal fluctuation range, and the actual application scenario.
[0082] Missing data points may be missing data points, which refer to values that are missing or not recorded in a data set. Missing data points may be caused by sensor failure, network interruption, device error, or other problems.
[0083] The target interpolation method may be a mathematical method or strategy selected to fill in missing data points. The target interpolation method depends on the distribution of data points, such as the continuity, trend and volatility of the data point distribution.
[0084] The interpolation value may be an actual value calculated by a target interpolation method to fill in the missing data points.
[0085] Exemplarily, during the data preprocessing stage, an outlier detection algorithm, such as a Z-score algorithm or an interquartile range method, can be used to identify outliers in a data set that may be caused by sensor failure or network transmission problems. The Z-score algorithm or the interquartile range method can determine whether a data point deviates from a normal range by calculating the distance between the data point and the mean or median.
[0086] Furthermore, in the data cleaning stage, it is possible to check whether there are significant differences or jumps between adjacent data points. If the difference exceeds a preset missing threshold (for example, more than 3 standard deviations of the mean), it can be determined as a missing data point. The missing threshold can be set according to the data distribution and actual application scenarios.
[0087] Furthermore, the corresponding target interpolation method can be selected according to the continuity and trend of the data. For example, in a scenario where there are continuous changes between data points, linear interpolation can be selected as the completion strategy; when the data fluctuates greatly, a more complex interpolation method can be selected, such as nearest neighbor interpolation or spline interpolation.
[0088] Taking the linear interpolation method as an example, the previous and next complete data points of the missing data point can be selected to calculate the estimated value of the missing data point, that is, the interpolation value.
[0089] Specifically, interpolation value = previous data point value + (next data point value - previous data point value) / (next time point - previous time point) × (missing data point time - previous time point).
[0090] Furthermore, the calculated interpolation values can be filled back into the missing data point positions in the original data set to obtain supplemented data to be classified, thereby ensuring the integrity of the data and improving the continuity and consistency of the data, providing a high-quality data foundation for CSI-based human gesture recognition or human posture recognition, thereby improving the accuracy and robustness of recognition.
[0091] Step 102, obtaining a preset target model and multiple first feature templates of the target model; wherein the target model is obtained by a first similarity matrix obtained by the preset model based on a sample feature relationship between multiple first sample data, a first comparative training with a preset first sample label, and a second comparative training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on multiple first sample data under each first sample label according to the first similarity matrix corresponding to the multiple first sample data.
[0092] In some embodiments, since the first feature template can accurately reflect the essential characteristics of the same type of data, in order to quickly and accurately determine the classification results of the data to be classified, the similarity between the data to be classified and the multiple first feature templates can be calculated by obtaining multiple first feature templates corresponding to the target model, thereby achieving efficient classification of the data to be classified.
[0093] The target model may be an algorithm or model for predicting or classifying data, and the target model may be obtained by adjusting model parameters by learning and training the first sample data from a preset model. Specifically, the target model may be the CSi-Net network proposed in this application, or other classification networks.
[0094] The first feature template can be calculated based on the first sample data and its first similarity matrix to characterize the essential features of the specific category of data. The first feature template can be generated based on the statistical information of the sample data or through a machine learning algorithm and is an abstract representation used to describe the data.
[0095] The preset model may be a model that has been built before starting the data classification task. The preset model may be established based on an existing knowledge base, literature, or previous experience and used as a starting point for subsequent training. Specifically, the preset model may be the CSi-Net network proposed in this application or other classification networks.
[0096] The first sample data may be a basic data unit for training and verifying a preset model. For example, in an action classification scenario, the first sample data may be channel state information collected when the detected person performs a specific gesture action, and multiple channel state information may constitute multiple first sample data for training a preset model.
[0097] The first similarity matrix may be a matrix used to represent the similarity or distance between the first sample data, and each element in the first similarity matrix represents the degree of similarity between two first sample data.
[0098] The first sample label may be a mark used to indicate a type of first sample data, that is, the first sample label may be used to indicate a category or attribute of a type of first sample data.
[0099] The first feature template can be obtained by training a preset model for a class of first sample data. For example, the first sample data under each first sample label can correspond to a first feature template.
[0100] Please refer to Figure 3 , Figure 3The network shown is a CSi-Net network structure diagram proposed in this application. When the first sample data is CSI data, the CSi-Net network can use a multi-head attention structure to determine the similarity between the first sample data, rather than a simple Gaussian distance. When training the preset model, two groups of first sample data can be extracted from the training set each time as CSI input 1 and CSI input 2 of the CSi-Net network and input into the CSi-Net network. For example, 64 first sample data are randomly extracted from the training set. The CSi-Net network can obtain the first similarity matrix between the two groups of first sample data based on the feature relationship between the samples. In some embodiments, the dimensions of the two groups of first sample data extracted are the same, and the two groups of first sample data may be the same or different.
[0101] Furthermore, a learning target Y can be defined according to each first sample label. The size of Y is the same as the first similarity matrix S (for example, both are 64*64). The value of Y can be determined based on the first sample label, that is, the similarity between the first sample data with the same first sample label is high, and the similarity between the first sample data with different first sample labels is low.
[0102] Furthermore, the cross entropy can be used as the loss function to calculate the difference between the first similarity matrix S and the learning target Y, and the preset model can be optimized by the gradient descent algorithm to minimize the loss function so that the difference between the first similarity matrix S and the learning target Y is as small as possible, thereby enabling the preset model to better learn the feature relationship between samples.
[0103] Furthermore, after the first comparative training of the preset model, the second comparative training can be continued to effectively use the first feature template to characterize the total feature expression form of multiple first sample data under each type of first sample label, so that the trained target model can fully utilize the sample characteristics of each first sample data even in the case of few samples.
[0104] Specifically, the sample quality scores of multiple first sample data under each first sample label can be determined through the first similarity matrix, and the proportion of each first sample data in the first feature template corresponding to the first sample label can be determined through the sample quality score, so as to determine the first feature template. Specifically, when determining the sample quality score through the first similarity matrix, when the similarity between a certain first sample data and all other first samples is high or low, it means that the first sample data may contain large noise and the sample quality score is low; and if the similarity between a certain first sample data and some first sample data is extremely high, but the similarity with other first sample data is extremely low, it means that the sample quality score of the first sample data may be high. It can be understood that since the sample quality score lacks a sample label and cannot be trained directly, the present application can indirectly train the convolution layer used to output the sample quality score in the preset model through first comparative training and second comparative training.
[0105] Exemplarily, after constructing a first feature template based on each first sample data and its sample quality score using a weighted method and adjusting the weight of the first feature template corresponding to the first sample label to which each first sample data belongs, the first sample data can be used as the first input of the target model, and the first feature template can be used as the second input of the target model to obtain a third similarity matrix, and the cross entropy between S and Y is calculated. Then, the preset model and the convolution layer for calculating the sample quality score are trained simultaneously through gradient descent training. In this way, the first feature template for summarizing the common features of each first sample data under each first sample label can be obtained, so that the trained target model can still make accurate judgments when facing data that has not appeared before.
[0106] Furthermore, since there may be differences in the data distribution of the source domain and the target domain in cross-domain learning, when there is a sample support set of the data to be classified, the target model is obtained by continuing to use the third comparative training and the fourth comparative training for the preset model using the sample support set, so that the target model can learn to be more suitable for the data distribution of the target domain and improve the performance on the target domain. It can be understood that the third comparative training process is similar to the first comparative training process above, and the fourth comparative training process is similar to the second comparative training process above, except that the data sets used to train the model are different. The specific process can be referred to above and will not be repeated here.
[0107] That is to say, when there is no sample support set, only the first comparative training and the second comparative training can be used for the preset model, and the first feature template obtained can be used as the feature template of the data to be classified; when there is a sample support set, in addition to using the first comparative training and the second comparative training for the preset model to obtain the first feature template of the source domain, the third comparative training and the fourth comparative training should be performed on the sample support set to obtain the first feature template of the target domain as the feature template of the data to be classified.
[0108] It can be understood that since the first feature template can accurately reflect the essential characteristics of the same type of data, the target model can quickly and accurately determine the classification results of the data to be classified even in the case of few samples or cross-domain learning. Therefore, the preset target model and multiple first feature templates of the target model can be obtained. In the absence of a sample support set, the first feature template is a feature template obtained by performing a first comparative training and a second comparative training on the preset model. In the presence of a sample support set, the first feature template is a feature template obtained after performing a first comparative training and a second comparative training on the preset model according to multiple first sample data and performing a third comparative training and a fourth comparative training on the preset model according to the sample support set.
[0109] By using the CSi-Net network with a multi-head attention structure to judge the similarity between the first sample data, the target model can more accurately capture the relationship between sample features, thereby improving classification accuracy. In addition, by characterizing the key features of each category through the first feature template, the target model can still maintain a high recognition accuracy when facing new data that has not been seen. In this way, even when the number of samples is limited, by using the first feature template, the target model can still make full use of the features of each sample data, improve the classification performance of the target model, and also optimize the generalization ability and training efficiency of the model.
[0110] In some embodiments, since only simple measurement methods such as Gaussian distance and cosine similarity are used to judge the distance between samples, the relationship between samples is not fully utilized. Therefore, the present application introduces a multi-head attention mechanism and applies the multi-head attention mechanism to the measurement of feature similarity between first sample data. By inputting the features of different first sample data as queries and keys into the attention module, the similarity between the first sample data is calculated, which can help the model better capture the relationship between the first sample data. Exemplarily, the first similarity matrix is obtained by the preset model through the following steps, including:
[0111] (A.1) copying a plurality of first sample data to obtain sample copy data;
[0112] (A.2) inputting the first sample data as a first input into a preset model, and inputting the sample copy data as a second input into the preset model, to obtain a plurality of feature similarities calculated by the preset model according to a sample feature relationship of any sample between the first sample data and the sample copy data;
[0113] (A.3) Based on the multiple feature similarities, a first similarity matrix corresponding to the multiple first sample data is obtained.
[0114] The sample copy data may be data copied from the first sample data, or may be data extracted from a training set that is identical to the first sample data, or may be data different from the first sample data that is extracted from the training set where the first sample data is located.
[0115] Among them, feature similarity can be an indicator to measure the similarity between the features of the first sample data. Calculating feature similarity is helpful for the preset model to identify and utilize the correlation between the first sample data, thereby improving the learning effect.
[0116] Exemplarily, a plurality of first sample data may be extracted from a preset training set, for example, 64 first sample data may be extracted.
[0117] Exemplarily, multiple first sample data can be copied to obtain sample copy data, and then the first sample data and the copied sample data are respectively input into a preset model, which can be CSi-Net. Then, the first sample data is used as the first input, and the sample copy data is used as the second input and simultaneously input into the preset model, so that the preset model calculates the feature similarity between samples according to the multi-head attention mechanism, and obtains the first similarity matrix corresponding to the multiple first sample data based on the multiple feature similarities. Each element in the first similarity matrix represents the feature similarity between each first sample data and any sample copy data, thereby improving the accuracy of feature similarity calculation and enhancing the expression ability and learning efficiency of the preset model.
[0118] Exemplarily, two groups of samples can be extracted from the training set, each group of samples includes m first sample data. Afterwards, the two groups of samples are used as the first input and the second input, respectively, and input into the preset model to obtain a first similarity matrix S of size m*m. For example, when m is 3, the first input is: sample A1, sample A2, sample A3, and the second input is: sample B1, sample B2, sample B3. The first similarity matrix S obtained by the preset model is:
[0119]
[0120] By combining the multi-head attention mechanism, the accuracy of feature similarity calculation and the learning efficiency of the preset model can be effectively improved, which helps the preset model to achieve better performance in various application scenarios.
[0121] Please refer to Figure 4 In some embodiments, in order to facilitate the preset model to learn sufficient distinguishing features from the limited first data samples and facilitate subsequent generalization to unseen data, the preset model can be trained so that the preset model can ensure that the first sample data with the same first sample label have a higher feature similarity, and the first sample data with different first sample labels have a lower feature similarity; and by training the preset model, the preset model can also learn the common features of multiple first sample data under the same first sample label, so that the trained target model can efficiently and accurately classify the data to be classified. For example, the "target model" in step 102 can be trained in the following way:
[0122] Step 201, obtaining a sample training set, and performing a first comparative training and a second comparative training on a preset model according to the sample training set to obtain a first target model;
[0123] Step 202, when there is no sample support set for training the first target model, use the first target model as the target model;
[0124] Step 203, when there is a sample support set for training the first target model, perform third comparative training and fourth comparative training on the first target model based on the sample support set to obtain a target model; wherein there is no intersection between the sample training set and the sample support set; and the category of the data to be classified is the same as at least one sample label contained in the sample support set.
[0125] The sample training set may be a training set including a plurality of first sample data, and the first sample data is used to train a preset model. The sample training set may include first sample data (e.g., image, text, or channel state information) and first sample labels corresponding to the first sample data (e.g., specific action categories, image categories, etc.). The sample training set may be used to perform first comparative training and second comparative training.
[0126] Among them, the first comparative training can be a process of randomly extracting two groups of first sample data from the sample training set and simultaneously inputting them into the preset model to obtain a first similarity matrix S, determining the learning target Y of the preset model based on the first sample label, and then calculating the cross entropy loss of the preset model based on S and Y, so as to adjust the preset model according to the cross entropy loss. Through the first comparative training, the preset model can learn the feature similarity between the first sample data and improve the ability of the preset model to distinguish different categories of first sample data.
[0127] Among them, the second comparative training can be a process in which a preset model generates a first feature template based on the common features of multiple first sample data under each first sample label. Specifically, the preset model can output the sample quality score of each first sample data through a convolutional layer, and obtain the first feature template corresponding to each first sample label through a weighted calculation of the sample quality score. Afterwards, the first sample data is used as the first input, and the first feature template is used as the second input, and is input into the preset model at the same time to obtain a similarity matrix, and the learning target Y of the first preset model is determined based on the first sample label, so as to calculate the cross entropy loss of the preset model according to the similarity matrix and Y, so as to adjust the first preset model according to the cross entropy loss. Thus, the trained first target model can learn the common features of the first sample data under each first sample label based on the first feature template.
[0128] The first target model may be a model obtained after performing a first comparative training and a second comparative training on a preset model. The first target model is a model with good generalization ability generated after the preset model is trained based on the source domain.
[0129] Among them, the sample support set can be a small-scale data set, which is used to provide a basis for classification decisions for a small number of sample scenarios in the test phase. The second sample labels of the sample support set can be the same as or different from the first sample labels of the sample training set, and the category of each second sample data of the sample support set is the same as the category of the data to be classified. Training the preset model with the sample training set can enable the preset model to have good classification capabilities. Training the preset model with the sample support set can enable the model to quickly adapt to the new environment, and with a small number of samples, efficient learning and accurate data classification can be achieved in the new environment.
[0130] Among them, the third comparative training can be a comparative training of the first target model based on the sample support set. The third comparative training can be a process of randomly extracting two groups of second sample data from the sample support set and simultaneously inputting them into the first target model to obtain a second similarity matrix S, determining the learning target Y of the first target model based on the second sample label, and then calculating the cross entropy loss of the first target model based on S and Y to adjust the first target model according to the cross entropy loss. Through the third comparative training, the first target model can learn the feature similarity between the second sample data and improve the ability of the first target model to distinguish different categories of first sample data.
[0131] Among them, the fourth comparative training can be a process in which the second preset model generates a second feature template based on the common features of multiple second sample data under each second sample label. Specifically, the second preset model can output the sample quality score of each second sample data through the convolution layer, and obtain the second feature template corresponding to each second sample label by weighted calculation of the sample quality score. Afterwards, the second sample data is used as the third input, and the second feature template is used as the fourth input, and is input into the second preset model at the same time to obtain a similarity matrix, and a learning target is determined based on the second feature template and the second sample label, and the cross entropy loss of the second preset model is calculated according to the similarity matrix and the learning target, so as to adjust the second preset model according to the cross entropy loss. Thus, the trained target model can learn the common features of the second sample data under each second sample label based on the second feature template.
[0132] For example, for the sample training set, in the first comparative training, the preset model can learn the mapping from the features of the first sample data to the first sample label, and by continuously adjusting the weights in the network, the preset model can more accurately identify the category of the first sample data. Through the second comparative training, the preset model can learn the common features of all the first sample data under each first sample label as the first feature template, so as to facilitate the subsequent direct calculation of the feature similarity between the data to be classified and the first feature template, and realize the rapid and accurate classification of the data to be classified.
[0133] It is understandable that, since new categories or situations that are not in the sample training set may appear in actual applications, the sample support set can be used to fine-tune the preset model so that it can better handle these new situations. It is understandable that the category of the second sample data in the sample support set is the same as the category of the data to be classified.
[0134] For example, for the sample support set, in the third comparative training, the preset model can learn the mapping of the second sample data from features to the second sample labels, and by continuously adjusting the weights in the network, the preset model can more accurately identify the category of the second sample data. Through the fourth comparative training, the preset model can learn the common features of all second sample data under each second sample label as the second feature template, so as to facilitate the subsequent direct calculation of the feature similarity between the data to be classified and the first feature template, and realize the rapid and accurate classification of the data to be classified.
[0135] In some implementations, the first preset model, the first target model, and the second preset model may also be referred to as preset models in certain circumstances.
[0136] Specifically, if there is no sample support set for training the first target model, then the first target model is already the best model trained on the available data (i.e., the sample training set). In this case, there is no additional data to further improve or fine-tune the model, so the first target model is regarded as the final target model for subsequent classification tasks.
[0137] If there is a sample support set, it means that there is additional data that does not overlap with the sample training set that can be used to further train and optimize the model. The sample support set may contain data distribution that is more similar to the data to be classified, or contain new categories or situations that have not appeared in the sample training set. In this case, additional training of the first target model using the sample support set can improve the performance of the target model.
[0138] Through the above methods, different data sets and training strategies can be combined to improve the generalization ability, adaptability and classification performance of the target model, so that the target model can still perform classification tasks more accurately and reliably in a variety of scenarios.
[0139] In some embodiments, in order to improve the accuracy of the target model in classifying the data to be classified, the preset model may be subjected to a first comparative training so that the preset model can learn the mapping of the first sample data from the feature to the first sample label, and by continuously adjusting the weights in the network, the preset model can more accurately identify the category of the first sample data. Through the second comparative training, the preset model can learn the common features of all the first sample data under each first sample label as the first feature template, so as to facilitate the subsequent direct calculation of the feature similarity between the data to be classified and the first feature template, and realize the rapid and accurate classification of the data to be classified. Exemplarily, step 201 may include:
[0140] (201.1) Inputting a plurality of first sample data in the sample training set into a preset model to obtain a first similarity matrix corresponding to the plurality of first sample data; wherein the first similarity matrix is used to represent the similarity between any two first sample data;
[0141] (201.2) Obtain a first sample label of each first sample data, and determine a first cross entropy loss of a preset model according to the similarity between any two first sample data and the first sample label;
[0142] (201.3) adjusting the parameters of the preset model according to the first cross entropy loss to obtain a first preset model after performing a first comparative training on the preset model;
[0143] (201.4) obtaining a plurality of first feature templates corresponding to the sample training set, and calculating a second cross entropy loss of the first preset model based on the similarity between any two first sample data and the corresponding first feature templates;
[0144] (201.5) Adjust the parameters of the first preset model according to the second cross entropy loss to obtain a first target model after performing a second comparative training on the first preset model.
[0145] Among them, the first cross entropy loss can be used to measure the difference between the first similarity matrix predicted by the preset model and the learning target. During the training process, the first cross entropy loss can be calculated based on the first similarity matrix output by the preset model and the actual first sample label to ensure that the preset model can better learn the similarity relationship between the first sample data during the training process. Specifically, the learning target can be that when the categories (first sample labels) of the i-th first sample data and the j-th first sample data are different, the element at the corresponding position is 0; when the categories of the i-th first sample data and the j-th first sample data are the same, the element at the corresponding position is 1.
[0146] The first preset model may be a model obtained after a first comparative training is performed on the preset model, and the first preset model has a good ability to distinguish between categories of different sample data.
[0147] Among them, the second cross entropy loss can be used to measure the difference between the similarity matrix predicted by the first preset model based on the first sample data and the first feature template and the learning target. Specifically, the learning target can be that when the categories (first sample labels) of the i-th first sample data and the j-th first feature template are different, the element at the corresponding position is 0; when the categories of the i-th first sample data and the j-th first feature template are the same, the element at the corresponding position is 1.
[0148] Exemplarily, the CSi-Net model proposed in this application is used as the preset model. Taking the gesture recognition scenario as an example (not limited to this scenario in actual application), when performing the first comparative training, 64 first sample data can be randomly extracted from the sample training set, and these 64 first sample data are input into the CSi-Net model, and the CSi-Net model outputs a 64x64 first similarity matrix S. Each matrix element S[i][j] in S represents the feature similarity that the i-th first sample data and the j-th first sample data predicted by the CSi-Net model belong to the same category.
[0149] Furthermore, a 64x64 learning target matrix Y can be constructed according to the true category (i.e., the first sample label) of each first sample data. If the i-th first sample data and the j-th first sample data belong to the same first sample label, then Y[i][j] is 1; if the i-th first sample data and the j-th first sample data belong to different first sample labels, then Y[i][j] is 0.
[0150] Furthermore, a first cross entropy loss may be calculated based on the first similarity matrix S and the learning target matrix Y, and the difference between the first similarity matrix S and the ideal learning target Y may be determined through the first cross entropy loss.
[0151] Furthermore, based on the first cross entropy loss, the parameters of the CSi-Net model can be optimized by the gradient descent method to reduce the loss value. The above training steps are repeated, and the model parameters are updated in each iteration until the model converges or reaches a preset number of training times, thereby obtaining a first preset model.
[0152] By performing the first comparative training on the preset model, the first preset model can accurately distinguish first sample data of different categories and continuously improve performance during the training process.
[0153] In some embodiments, when performing the second comparative training, if there are 6 first sample labels, for each first sample label, 3 first sample data can be extracted from the sample training set, for a total of 18 first sample data. The first sample data is input into the Weight-Net network of the first preset model to obtain the sample quality score W of the convolution layer for each first sample data. Then, according to the quality score W, the first sample data of each category is weighted to obtain the first feature template T of each category. T represents the common features of all first sample data under each first sample label.
[0154] Furthermore, the first sample data can be used as the first input of the first preset model, and the first feature template can be used as the second input of the first preset model, and both can be input into the first preset model at the same time to obtain the feature similarity matrix S.
[0155] Further, a learning target Y of the second contrast training is defined, and the learning target Y is a matrix whose construction is based on the first feature template of the first sample data. For each element Y[i][j] in Y, if the i-th first sample data and the j-th first sample data belong to the same first feature template, then Y[i][j] is 1; if the i-th first sample data and the j-th first sample data belong to different first feature templates, then Y[i][j] is 0.
[0156] Furthermore, a second cross entropy loss can be calculated based on the feature similarity matrix S and the learning target matrix Y, and the difference between the feature similarity matrix S and the ideal learning target Y can be determined through the second cross entropy loss.
[0157] Furthermore, the calculated second cross entropy loss can be used to iteratively update the parameters of the CSi-Net and Weight-Net networks through the gradient descent method to minimize the second cross entropy loss. In each iteration, the model parameters are updated in the opposite direction of the second cross entropy loss gradient, gradually improving the prediction ability of the first preset model, and the first target model can be obtained when the first preset model converges or reaches the preset number of training times.
[0158] By performing the first comparative training and the second comparative training on the preset model, we can focus on the similarity between samples in the first comparative training stage and enhance the ability of the preset model to distinguish samples of different categories. Through the second comparative training stage, we can improve the utilization rate of high-quality samples by evaluating the sample quality scores, so that the preset model can learn the common features of different first feature templates even in a small number of sample scenarios, so as to facilitate subsequent efficient and accurate classification.
[0159] In some embodiments, in general sample scenarios, especially in small sample scenarios, by learning the first feature template, a representative first feature template can be created using limited first sample data, so that the first feature template can adapt to data in different domains, which is conducive to improving the generalization ability of the target model and the accuracy of classifying the data to be classified. For example, "obtaining multiple first feature templates corresponding to the sample training set" in (201.4) may include:
[0160] (201.4.1) Determine a sample quality score of each first sample data based on the first similarity matrix;
[0161] (201.4.2) For each first sample label in the sample training set, determine the product of each first sample data in the first sample label and the corresponding sample quality score, and add up multiple products corresponding to multiple first sample data under the first sample label to obtain the sum of the first products corresponding to the first sample label;
[0162] (201.4.3) Obtain the sum of multiple sample quality scores of multiple first sample data under the first sample label, and use the ratio of the first product sum to the sum of the multiple sample quality scores as the first feature template corresponding to the first sample label.
[0163] The sample quality score may be a metric used to evaluate the quality or reliability of a single first sample data in the corresponding first sample label.
[0164] Specifically, multiple products corresponding to multiple first sample data under the first sample label can be accumulated to obtain the first product sum corresponding to the first sample label, and the ratio of the first product sum to the sum of the multiple sample quality scores can be used as the first feature template.
[0165] Exemplarily, if the sample quality score is represented by W, then the sample quality score is weighted for all first sample data under each first sample label to obtain the first feature template under the first sample label. Specifically, for each first sample label, if it includes n first sample data, the calculation formula of the first feature template is as follows:
[0166]
[0167] Among them, T i Represents the first feature template of the i-th class (first sample label), X i,j represents the jth first sample data of the i-th category, W i,j Represents the corresponding sample quality score.
[0168] By weighting the sample quality scores to obtain a first feature template that integrates the common features of all first sample data under a category of first sample labels, the preset model can better understand and distinguish samples of different qualities, improve the preset model's ability to migrate between different categories and tasks, and help the preset model achieve efficient and accurate data classification and processing in various complex environments.
[0169] In some embodiments, since different first sample data contribute differently to the training of the preset model, the sample quality score of each first sample data can be calculated so that the preset model can focus on learning high-quality samples, thereby improving the overall performance of the preset model. Furthermore, the first similarity matrix can be used as a basis for determining the sample quality score to improve the accuracy of the sample quality score calculation. Exemplarily, (201.4.1) may include:
[0170] (201.4.1.1) Obtaining a first similarity matrix corresponding to a plurality of first sample data;
[0171] (201.4.1.2) The first similarity matrix is input into the convolution layer of the first preset model to obtain multiple sample quality scores corresponding to the multiple first sample data; wherein the sample quality scores are determined by the convolution layer for each first sample data, from the first similarity matrix, for each first sample data, by determining multiple similarities between each first sample data and multiple other first sample data, and are determined based on the differences between the multiple similarities.
[0172] Among them, the convolution layer can be a network used to output the sample quality score. The present application can use the convolution layer of the Weight-Net network to output the sample quality score. The corresponding network can be determined according to the actual situation. The embodiments of the present application do not impose too many restrictions on this.
[0173] It is understandable that since the sample quality scores lack corresponding labels, they cannot be trained directly. Therefore, in the sample training set, the Weight-Net network can be indirectly trained through the first comparative training, so that the preset model has the ability to output more accurate sample quality scores. Similarly, in the sample support set, the Weight-Net network can also be indirectly trained through the third comparative training.
[0174] Specifically, taking the sample training set as an example, when the feature similarity between the first sample data and all other first sample data is higher or lower, it means that the first sample data may contain large noise and the sample quality score is lower; if the feature similarity between the first sample data and a small number of first sample data is extremely high, but the feature similarity with other first sample data is extremely low, it means that the sample quality score of the first sample data is higher.
[0175] For example, assuming that there are 10 first sample data, for sample 1, the feature similarity with the remaining 9 first samples is respectively: sample 2: 0.9, sample 3: 0.88, sample 4: 0.86, sample 5: 0.8, sample 6: 0.92, sample 7: 0.78, sample 8: 0.85, sample 9: 0.91, sample 10: 0.95, then sample 1 may have noise data or other factors, and it is difficult to distinguish from other samples, and the sample quality score is low, for example, it can be 0.2. For sample 6, the feature similarity with the remaining 9 first samples is respectively: sample 1: 0.92, sample 2: 0.23, sample 3: 0.26, sample 4: 0.2, sample 5: 0.15, sample 7: 0.88, sample 8: 0.3, sample 9: 0.4, sample 10: 0.1, indicating that sample 6 is a feature with clear boundaries, which can represent an important feature or pattern, and the sample quality score is high.
[0176] For example, please refer to Figure 5 , Figure 5 It is a structural diagram of the Weight-Net network provided in an embodiment of the present application. By inputting the copied data of CSI (first sample data) or different CSI data into CSi-Net, the corresponding first similarity matrix can be obtained. Then, the first similarity matrix is input into the convolutional layer to obtain the sample quality score of each CSI.
[0177] Through the above method, sample data with high sample quality scores can be determined, and sample data with different sample quality scores can be weighted so that the preset model can better understand and distinguish samples of different qualities.
[0178] In some embodiments, in order to enable the target model to better adapt to different tasks, the first target model can be trained by introducing a sample support set, so that the trained target model can have the ability to migrate and generalize between different categories and tasks. For the sample support set, in the third comparative training, the preset model can learn the mapping of the second sample data from features to the second sample labels, and by continuously adjusting the weights in the network, the preset model can more accurately identify the category of the second sample data. Through the fourth comparative training, the preset model can learn the common features of all second sample data under each second sample label as the second feature template, so as to facilitate the subsequent direct calculation of the feature similarity between the data to be classified and the first feature template, and realize the rapid and accurate classification of the data to be classified. Exemplarily, step 203 may include:
[0179] (203.1) When there is a sample support set for training the first target model, a plurality of second sample data in the sample support set is input into the first target model to obtain a second similarity matrix corresponding to the plurality of second sample data; wherein the second similarity matrix is used to represent the similarity between any two second sample data;
[0180] (203.2) Obtain second sample labels of two second sample data, and determine a third cross entropy loss of a preset model according to the similarity between any two second sample data and the second sample labels;
[0181] (203.3) adjusting the parameters of the first target model according to the third cross entropy loss to obtain a second preset model after performing a third comparative training on the first target model;
[0182] (203.4) Obtain multiple second feature templates corresponding to the sample support set, and calculate the fourth cross entropy loss of the second preset model based on the similarity between any two second sample data and the corresponding second feature templates;
[0183] (203.5) The parameters of the second preset model are adjusted according to the fourth cross entropy loss to obtain a target model after comparative training of the second preset model.
[0184] The second sample data may be a basic data unit for training and verifying the first target model. For example, in an action classification scenario, the second sample data may be channel state information collected when the detected person performs a specific gesture action, and multiple channel state information may constitute multiple second sample data for training the first target model.
[0185] The second similarity matrix may be a matrix used to represent the similarity or distance between the second sample data, and each element in the second similarity matrix represents the degree of similarity between two second sample data.
[0186] The second sample label may be a mark used to indicate a type of second sample data, that is, the second sample label may be used to indicate a category or attribute of a type of second sample data.
[0187] Among them, the third cross entropy loss can be used to measure the difference between the second similarity matrix predicted by the first target model and the learning target. During the training process, the third cross entropy loss can be calculated based on the second similarity matrix output by the first target model and the actual second sample label to ensure that the first target model can better learn the similarity relationship between the second sample data during the training process. Specifically, the learning target can be that when the categories (second sample labels) of the i-th second sample data and the j-th second sample data are different, the element at the corresponding position is 0; when the categories of the i-th second sample data and the j-th second sample data are the same, the element at the corresponding position is 1.
[0188] Among them, the second preset model can be a model obtained after the third comparative training of the first target model, and the second preset model has a good ability to distinguish the categories of different second sample data.
[0189] Among them, the fourth cross entropy loss can be used to measure the difference between the similarity matrix predicted by the second preset model based on the second sample data and the second feature template and the learning target. Specifically, the learning target can be that when the categories (second sample labels) of the i-th second sample data and the j-th second feature template are different, the element at the corresponding position is 0; when the categories of the i-th second sample data and the j-th second feature template are the same, the element at the corresponding position is 1.
[0190] Exemplarily, the CSi-Net model proposed in this application is used as the first target model. Taking the gesture recognition scenario as an example (not limited to this scenario in actual application), when performing the third comparative training, 24 second sample data can be randomly extracted from the sample support set, and these 24 second sample data are input into the CSi-Net model, and the CSi-Net model outputs a 24x24 second similarity matrix S. Each matrix element S[i][j] in S represents the feature similarity that the i-th second sample data and the j-th second sample data predicted by the CSi-Net model belong to the same category.
[0191] Furthermore, a 24x24 learning target matrix Y can be constructed according to the true category of each second sample data (ie, the second sample label). If the i-th second sample data and the j-th second sample data belong to the same second sample label, then Y[i][j] is 1; if the i-th second sample data and the j-th second sample data belong to different second sample labels, then Y[i][j] is 0.
[0192] Furthermore, a third cross entropy loss may be calculated based on the second similarity matrix S and the learning target matrix Y, and the difference between the second similarity matrix S and the ideal learning target Y may be determined through the third cross entropy loss.
[0193] Furthermore, based on the third cross entropy loss, the parameters of the CSi-Net model can be optimized by the gradient descent method to reduce the loss value. The above training steps are repeated, and the model parameters are updated in each iteration until the model converges or reaches the preset number of training times, thereby obtaining a second preset model.
[0194] By performing the third comparative training on the first target model, the second preset model can accurately distinguish the second sample data of different categories and continuously improve the performance during the training process.
[0195] In some embodiments, when performing the fourth comparative training, if there are 6 second sample labels, for each second sample label, 3 second sample data can be extracted from the sample support set, for a total of 18 second sample data. The second sample data is input into the Weight-Net of the second preset model to obtain a sample quality score W for each second sample data. Then, according to the quality score W, the second sample data of each category is weighted to obtain a second feature template T for each category. T represents the common features of all second sample data under each second sample label.
[0196] Furthermore, the second sample data can be used as the first input of the second preset model, and the second feature template can be used as the second input of the second preset model, and can be simultaneously input into the second preset model to obtain a feature similarity matrix S.
[0197] Further, a learning target Y of the fourth contrast training is defined, and the learning target Y is a matrix whose construction is based on the second feature template of the second sample data. For each element Y[i][j] in Y, if the i-th second sample data and the j-th second sample data belong to the same second feature template, then Y[i][j] is 1; if the i-th second sample data and the j-th second sample data belong to different second feature templates, then Y[i][j] is 0.
[0198] Furthermore, a fourth cross entropy loss may be calculated based on the feature similarity matrix S and the learning target matrix Y, and the difference between the feature similarity matrix S and the ideal learning target Y may be determined through the fourth cross entropy loss.
[0199] Furthermore, the calculated fourth cross entropy loss can be used to iteratively update the parameters of the CSi-Net and the convolution layer through the gradient descent method to minimize the fourth cross entropy loss. In each iteration, the model parameters are updated in the opposite direction of the fourth cross entropy loss gradient, and the prediction ability of the second preset model is gradually improved. When the second preset model converges or reaches the preset number of training times, the target model can be obtained.
[0200] By performing the third comparative training and the fourth comparative training on the first target model, we can focus on the similarity between samples in the third comparative training stage and enhance the ability of the first target model to distinguish samples of different categories. Through the fourth comparative training stage, we can improve the utilization rate of high-quality samples by evaluating the sample quality scores, so that the first target model can learn the common features of different second feature templates even in a small number of sample scenarios, so that the trained target model can subsequently perform efficient and accurate classification of the data to be classified.
[0201] Step 103: input the data to be classified and a plurality of first feature templates into the target model to obtain a plurality of feature similarities between the data to be classified and the plurality of first feature templates respectively.
[0202] In some embodiments, since the first feature template represents the common features of multiple first sample data under the corresponding first sample label, in order to quickly classify the data to be classified, the first feature template most similar to the data to be classified can be determined by calculating the feature similarity between the data to be classified and each first feature template, thereby determining the target category of the data to be classified.
[0203] The feature similarity can be the degree of similarity between the data to be classified and the multiple first feature templates in the feature space. A high similarity means that the data to be classified and the first feature template are very close in features, while a low similarity means that the data to be classified and the first feature template are quite different in features. The similarity measure can be calculated based on a variety of methods such as Euclidean distance, cosine similarity, and dot product.
[0204] Specifically, each first feature template can represent the common features of the first sample data under a first sample label. Therefore, by inputting the data to be classified and multiple first feature templates into the target model, multiple feature similarities between the data to be classified and the multiple first feature templates can be obtained, thereby indirectly evaluating the feature similarity between the data to be classified and each first sample label.
[0205] It can be understood that when there is no sample support set, the data to be classified can be classified based on the first feature template. When there is a sample support set, the data to be classified should be classified based on the second feature template. The method of obtaining the first feature template and the second feature template has been explained above and will not be repeated here.
[0206] Furthermore, when there is no sample support set, the data to be classified and multiple first feature templates can be input into the target model to obtain multiple feature similarities between the data to be classified and the multiple first feature templates, and multiple first feature templates with higher feature similarities can be selected as target domain templates based on the feature similarities. Furthermore, based on the calculated feature similarities between the data to be classified and each target domain template, the target domain template with the highest feature similarity to the data to be classified can be selected as the target feature template, and the target category corresponding to the target feature template can be determined, and the target category can be used as the classification result of the data to be classified.
[0207] Furthermore, when there is a sample support set, the data to be classified and multiple second feature templates can be input into the target model to obtain multiple feature similarities between the data to be classified and the multiple second feature templates, so as to facilitate the subsequent selection of the second feature template with the highest feature similarity to the data to be classified as the target feature template, and determine the target category corresponding to the target feature template, and use the target category as the classification result of the data to be classified.
[0208] By calculating the feature similarity between the data to be classified and the first feature template and classifying the data to be classified accordingly, accurate classification can be performed without relying on a large amount of sample data. At the same time, it is convenient to subsequently determine the target category based on the feature similarity.
[0209] Step 104 : determining, based on multiple feature similarities, a first feature template having the greatest feature similarity to the data to be classified as a target feature template, and determining a target category corresponding to the target feature template.
[0210] In some embodiments, the first feature template with the greatest feature similarity represents the first feature template that is most similar to the features of the data to be classified among multiple first feature templates, and the first feature template is used to characterize the common features of a class of first sample data. Therefore, the first feature template with the greatest feature similarity can be determined as the target feature template to facilitate determining the target category of the data to be classified.
[0211] Among them, the target feature template can be the first feature template with the highest feature similarity to the data to be classified among all the first feature templates learned by the target model. During the training process, the target model will learn the first feature template from multiple first sample labels of each first sample label (that is, sample category). For example, in a human posture classification task, a feature template may contain all the key features of a first sample label (such as "waving"), such as the angle change and motion trajectory of the arm swing, hand posture, body posture, etc.
[0212] The target category may be the first sample label (i.e., sample category) corresponding to the target feature template. Since the target feature template may be the first feature template with the highest feature similarity to the data to be classified among all the first feature templates learned by the target model, the target category may also be the sample category corresponding to the first sample label with the highest feature similarity to the data to be classified among all the first sample labels.
[0213] Exemplarily, when the feature similarity between the data to be classified and the first feature template 1 is 0.8, and the feature similarity with the first feature template 2 is 0.6, the first sample label corresponding to the first feature template 1 is waving, and the first sample label corresponding to the first feature template 2 is clapping, the feature similarity between the data to be classified and the first feature template 1 is high, so it can be determined that the first feature template 1 is the target feature template, and waving is determined as the target category.
[0214] By using the first feature template learned by the target model, the features of the data to be classified can be captured more accurately, thereby improving the accuracy of classification, so that the target category corresponding to the target feature template can be subsequently determined as the classification result of the data to be classified.
[0215] Step 105: determine the target category as the classification result of the data to be classified.
[0216] In some implementations, in order to obtain the classification result of the data to be classified, the target category corresponding to the target feature template with the greatest feature similarity to the data to be classified can be determined as the classification result of the data to be classified, thereby simplifying the classification process and improving the accuracy and efficiency of classification.
[0217] The classification result may be the final category attribution of the data to be classified output by the target model after the target model completes the classification task.
[0218] Specifically, by comparing the data to be classified with the first feature templates of all possible categories, the target feature template with the highest feature similarity to the data to be classified can be found, and the target category corresponding to the target feature template can be used as the classification result of the data to be classified. For example, if the target category corresponding to the target feature template is waving, then the classification result of the data to be classified is waving.
[0219] Through the above methods, efficient and accurate classification of classified data can be achieved to meet the needs of practical applications.
[0220] The embodiment of the present application obtains data to be classified; obtains a preset target model and multiple first feature templates of the target model; wherein the target model is obtained by a first similarity matrix obtained by the preset model based on the sample feature relationship between multiple first sample data, a first comparative training with a preset first sample label, and a second comparative training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on multiple first sample data under each first sample label according to the first similarity matrix corresponding to the multiple first sample data; the data to be classified and the multiple first feature templates are input into the target model to obtain multiple feature similarities between the data to be classified and the multiple first feature templates; based on the multiple feature similarities, the first feature template with the largest feature similarity with the data to be classified is determined as the target feature template, and the target category corresponding to the target feature template is determined; the target category is determined as the classification result of the data to be classified. In this way, the category features can be characterized by the first feature template, and efficient learning and accurate classification of a small number of samples can be achieved, reducing the dependence on traditional large-scale sample training, thereby reducing the training cost. At the same time, since the first feature template can accurately reflect the essential characteristics of the same type of data, the classification result can be more accurately determined by matching the similarity between the data to be classified and the first feature template. In summary, the present application can improve the accuracy of data classification while reducing the training cost of the model.
[0221] Please refer to Figure 6 In some embodiments, in combination Figure 6 The overall implementation process of this application is introduced.
[0222] For example, for the gesture recognition task based on CSI data, the target model proposed in this application is CSi-Net. The specific training process and application process of CSi-Net are as follows:
[0223] First, sample data collection is performed. Specifically, the ESP32-S3 receiver can be used to collect CSI data, and the sampling rate is set to 8Hz. Seven volunteers perform six gestures (pushing hands left and right, pushing hands up and down, pushing hands forward and backward, turning clockwise, clapping, and waving), each of which lasts for 1 minute. The collected actions are divided into sample training sets, each of which has multiple first sample data, and each first sample data corresponds to a first sample label.
[0224] Furthermore, the eighth volunteer repeats the above actions for 1 minute, the first 3 seconds of data is used as the sample support set, and the remaining data is used as the sample test set. The data in the sample test set can be used as the data to be classified to test the application effect of the target model. Furthermore, a non-overlapping sliding window can be used to divide all data into 1-second long sample data. For example, 3 seconds of data in the sample support set corresponds to 3 samples. Each sample support set has multiple second sample data, and each second sample data corresponds to a second sample label.
[0225] Exemplarily, in the first comparative training stage, 64 first sample data can be randomly selected from the sample training set and input into CSi-Net to calculate a 64x64 first similarity matrix S1. At the same time, a learning target Y1 is defined, and its size is 64x64. The value of Y is determined based on the first sample label. The value between the first sample data with the same first sample label (gesture in this embodiment) is 1, and the value between the first sample data with different first sample labels is 0, thereby obtaining the matrix corresponding to Y1.
[0226] Furthermore, a first cross entropy loss may be calculated based on the first similarity matrix S1 and the learning target Y1, and the parameters of the CSi-Net may be adjusted based on the first cross entropy loss to obtain a first preset model.
[0227] Furthermore, in the second comparative training stage, also known as the template learning stage, k first sample data may be randomly extracted from the sample training set, and the selection of k may be determined based on actual conditions, for example, k may be 18. The extracted k first sample data should contain all the first sample labels in the sample training set, and each second sample label also contains the same number of first sample data.
[0228] Afterwards, the first similarity matrix obtained through training in the first comparative training phase can be input into the Weight-Net network to obtain the sample quality scores of each first sample data, and the sample quality scores of each first sample data under each first sample label can be weighted to obtain the first feature template corresponding to each first sample label.
[0229] Furthermore, the first sample data can be used as the first input and the first feature template can be used as the second input to input into CSi-Net to obtain the corresponding feature similarity matrix S2. At the same time, a learning target Y2 is defined, and its size is 18x18. Afterwards, CSi-Net is trained based on S2 and Y2, so that CSi-Net has the ability to accurately determine the corresponding first feature template according to the first sample data through training.
[0230] Furthermore, in the process of performing the third comparative training and the fourth comparative training on the sample support set, the third comparative training process is similar to the first comparative training introduced above, and the fourth comparative training process is similar to the second comparative training introduced above. For example, the quality score corresponding to each second sample data is obtained through the Weight-Net network, and the common features of all second sample data under each second sample label are calculated as the second feature template, etc., which will not be elaborated here.
[0231] Exemplarily, in the process of classifying the data to be classified in the sample test set, if in a few-sample scenario, the third comparative training and the fourth comparative training can be carried out to obtain the second feature template, and then the feature similarity between the data to be classified and the second feature template is calculated to obtain the corresponding similarity matrix, and the second sample label corresponding to the second feature template with the highest feature similarity to the data to be classified is used as the category of the data to be classified, and the classification result is output, thereby completing the classification of the data to be classified.
[0232] Exemplarily, if in a zero-sample scenario, the preset model lacks a sample support set for training, and only the first comparative training and the second comparative training are performed, then multiple first feature templates and each data to be classified can be input into the target model to obtain a similarity matrix, and based on the similarity matrix, multiple first feature templates with the highest feature similarity to each data to be classified are determined as target domain templates. Furthermore, the data to be classified and multiple target domain templates in the sample test set can be input into the target model, and the first sample label corresponding to the target domain template with the highest feature similarity to each data to be classified is used as the category of the data to be classified, and the classification result is output, thereby completing the classification of the data to be classified.
[0233] The embodiment of the present application obtains data to be classified; obtains a preset target model and multiple first feature templates of the target model; wherein the target model is obtained by a first similarity matrix obtained by the preset model based on the sample feature relationship between multiple first sample data, a first comparative training with a preset first sample label, and a second comparative training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on multiple first sample data under each first sample label according to the first similarity matrix corresponding to the multiple first sample data; the data to be classified and the multiple first feature templates are input into the target model to obtain multiple feature similarities between the data to be classified and the multiple first feature templates; based on the multiple feature similarities, the first feature template with the largest feature similarity with the data to be classified is determined as the target feature template, and the target category corresponding to the target feature template is determined; the target category is determined as the classification result of the data to be classified. In this way, the category features can be characterized by the first feature template, and efficient learning and accurate classification of a small number of samples can be achieved, reducing the dependence on traditional large-scale sample training, thereby reducing the training cost. At the same time, since the first feature template can accurately reflect the essential characteristics of the same type of data, the classification result can be more accurately determined by matching the similarity between the data to be classified and the first feature template. In summary, the present application can improve the accuracy of data classification while reducing the training cost of the model.
[0234] See also Figure 7 The embodiment of the present application further provides a device for classifying data based on a model of few-sample learning, which can implement the above-mentioned method for classifying data based on a model of few-sample learning. The device for classifying data based on a model of few-sample learning includes:
[0235] A first acquisition module 71, used to acquire data to be classified;
[0236] The second acquisition module 72 is used to acquire a preset target model and a plurality of first feature templates of the target model; wherein the target model is obtained by performing a first comparison training with a preset first sample label based on a first similarity matrix obtained by the preset model based on a sample feature relationship between a plurality of first sample data, and a second comparison training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on a plurality of first sample data under each first sample label according to a first similarity matrix corresponding to the plurality of first sample data;
[0237] An input module 73, used to input the data to be classified and a plurality of first feature templates into a target model, and obtain a plurality of feature similarities between the data to be classified and the plurality of first feature templates respectively;
[0238] A first determination module 74 is used to determine, based on multiple feature similarities, a first feature template having the greatest feature similarity to the data to be classified as a target feature template, and determine a target category corresponding to the target feature template;
[0239] The second determination module 75 is used to determine the target category as the classification result of the data to be classified.
[0240] The specific implementation of the device for classifying data based on a model of few-sample learning is basically the same as the specific implementation of the method for classifying data based on a model of few-sample learning, and will not be repeated here. On the premise of meeting the requirements of the embodiments of the present application, the device for classifying data based on a model of few-sample learning can also be provided with other functional modules to implement the method for classifying data based on a model of few-sample learning in the above-mentioned embodiment.
[0241] The embodiment of the present application also provides a computer device, the computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned method for classifying data based on a model of few-sample learning when executing the computer program. The computer device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0242] See also Figure 8 , Figure 8 The hardware structure of a computer device according to another embodiment is shown, and the computer device includes:
[0243] The processor 81 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0244] The memory 82 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 82 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 82, and the processor 81 calls and executes the method for classifying data based on a model of few-sample learning in the embodiment of this application;
[0245] Input / output interface 83, used to implement information input and output;
[0246] Communication interface 84, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WI FI, Bluetooth, etc.);
[0247] A bus 85 that transmits information between the various components of the device (e.g., the processor 81, the memory 82, the input / output interface 83, and the communication interface 84);
[0248] The processor 81 , the memory 82 , the input / output interface 83 and the communication interface 84 are connected to each other in communication within the device via a bus 85 .
[0249] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned method for classifying data based on a few-sample learning model.
[0250] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0251] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0252] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0253] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0254] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0255] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0256] It should be understood that in the present application, "at least one (item)" and "several" refer to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0257] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0258] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0259] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0260] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0261] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for classifying data based on a model of few-sample learning, characterized in that: The method comprises: Obtain data to be classified; Acquire a preset target model and a plurality of first feature templates of the target model; wherein the target model is obtained by performing a first comparison training with a preset first sample label based on a first similarity matrix obtained by the preset model based on a sample feature relationship between a plurality of first sample data, and a second comparison training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on a plurality of first sample data under each first sample label according to the first similarity matrix corresponding to the plurality of first sample data; Inputting the data to be classified and the plurality of first feature templates into the target model to obtain a plurality of feature similarities between the data to be classified and the plurality of first feature templates respectively; Based on the multiple feature similarities, determine the first feature template having the greatest feature similarity to the feature of the data to be classified as a target feature template, and determine a target category corresponding to the target feature template; The target category is determined as a classification result of the data to be classified.
2. The method for classifying data based on a model of few-sample learning according to claim 1, characterized in that: The target model is trained in the following way: Acquire a sample training set, and perform a first comparative training and a second comparative training on a preset model according to the sample training set to obtain a first target model; When there is no sample support set for training the first target model, using the first target model as a target model; When there is a sample support set for training the first target model, third comparative training and fourth comparative training are performed on the first target model based on the sample support set to obtain a target model; wherein there is no intersection between the sample training set and the sample support set; and the category of the data to be classified is the same as at least one sample label contained in the sample support set.
3. The method for classifying data based on a model of few-sample learning according to claim 2, characterized in that: The step of obtaining a sample training set and performing a first comparative training and a second comparative training on a preset model according to the sample training set to obtain a first target model includes: Inputting a plurality of first sample data in the sample training set into a preset model, obtaining a first similarity matrix corresponding to the plurality of first sample data; wherein the first similarity matrix is used to characterize the similarity between any two of the first sample data; Obtaining a first sample label of each of the first sample data, and determining a first cross entropy loss of the preset model according to the similarity between any two first sample data and the first sample label; Adjusting the parameters of the preset model according to the first cross entropy loss to obtain a first preset model after performing a first comparative training on the preset model; Acquire multiple first feature templates corresponding to the sample training set, and calculate the second cross entropy loss of the first preset model based on the similarity between any two of the first sample data and the corresponding first feature templates; The parameters of the first preset model are adjusted according to the second cross entropy loss to obtain a first target model after the second comparative training of the first preset model.
4. The method for classifying data based on a model of few-sample learning according to claim 3, characterized in that: The obtaining of a plurality of first feature templates corresponding to the sample training set includes: Determining a sample quality score of each of the first sample data based on the first similarity matrix; For each first sample label in the sample training set, determine the product of each first sample data in the first sample label and the corresponding sample quality score, and accumulate multiple products corresponding to multiple first sample data under the first sample label to obtain a first product sum corresponding to the first sample label; A sum of multiple sample quality scores of multiple first sample data under the first sample label is obtained, and a ratio of the first product sum to the sum of the multiple sample quality scores is used as a first feature template corresponding to the first sample label.
5. The method for classifying data based on a model of few-sample learning according to claim 4, characterized in that: The determining, based on the first similarity matrix, a sample quality score of each of the first sample data includes: Obtaining a first similarity matrix corresponding to a plurality of first sample data; Inputting the first similarity matrix into the convolution layer of the first preset model to obtain a plurality of sample quality scores corresponding to the plurality of first sample data; The sample quality score is determined by the convolution layer for each of the first sample data, by determining multiple similarities between each of the first sample data and multiple other first sample data from the first similarity matrix, and based on the differences between the multiple similarities.
6. The method for classifying data based on a model of few-sample learning according to claim 2, characterized in that: When there is a sample support set for training the first target model, performing third comparative training and fourth comparative training on the first target model based on the sample support set to obtain a target model includes: When there is a sample support set for training the first target model, a plurality of second sample data in the sample support set is input into the first target model to obtain a second similarity matrix corresponding to the plurality of second sample data; wherein the second similarity matrix is used to characterize the similarity between any two second sample data; Obtaining second sample labels of the two second sample data, and determining a third cross entropy loss of the preset model according to the similarity between any two second sample data and the second sample labels; Adjusting the parameters of the first target model according to the third cross entropy loss to obtain a second preset model after performing a third comparative training on the first target model; Acquire multiple second feature templates corresponding to the sample support set, and calculate a fourth cross entropy loss of the second preset model based on the similarity between any two second sample data and the corresponding second feature templates; The parameters of the second preset model are adjusted according to the fourth cross entropy loss to obtain a target model after comparative training of the second preset model.
7. The method for classifying data based on a model of few-sample learning according to claim 1, characterized in that: The first similarity matrix is obtained by a preset model through the following steps, including: Copying a plurality of first sample data to obtain sample copy data; Input the first sample data as a first input to a preset model, input the sample copy data as a second input to the preset model, and obtain a plurality of feature similarities calculated by the preset model according to a sample feature relationship of any sample between the first sample data and the sample copy data; Based on the multiple feature similarities, a first similarity matrix corresponding to the multiple first sample data is obtained.
8. A device for classifying data based on a model of few-sample learning, characterized in that: The device comprises: A first acquisition module, used to acquire data to be classified; A second acquisition module is used to acquire a preset target model and a plurality of first feature templates of the target model; wherein the target model is obtained by performing a first comparison training with a preset first sample label based on a first similarity matrix obtained by the preset model based on a sample feature relationship between a plurality of first sample data, and a second comparison training based on the first sample data and the first feature template; the first feature template is obtained by performing feature weighted calculation on a plurality of first sample data under each first sample label according to the first similarity matrix corresponding to the plurality of first sample data; An input module, used for inputting the data to be classified and the plurality of first feature templates into the target model, and obtaining a plurality of feature similarities between the data to be classified and the plurality of first feature templates respectively; A first determination module is used to determine, based on the multiple feature similarities, the first feature template having the greatest feature similarity to the feature of the data to be classified as a target feature template, and determine a target category corresponding to the target feature template; The second determination module is used to determine the target category as the classification result of the data to be classified.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method for classifying data based on a few-sample learning model as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for classifying data based on a model of few-sample learning as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Template image updating method and device, target tracking method and device, electronic equipment and medium
CN110766725A
Attribute recognition method based on artificial intelligence and attribute recognition model training method
CN117523275A
Subject identification systems and methods
US20180373925A1
Cited By
Label generation method and device, electronic equipment and computer storage medium
CN120105087A
