Sample anomaly detection method, device, equipment and medium based on machine learning
By obtaining the offline loss sequence and category label information formed during the historical training process of sample data, we train the main network and sub-networks, update the weight parameters, and build an anomaly detection model, which solves the problem in the existing technology that it is difficult to accurately detect anomalies with heavy weighting. Improved the classification effect and anomaly detection accuracy of the sample data model.
Patent Information
- Application Number
- CN202111015957.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-08-31
AI Technical Summary
The method based on re-weighting in the prior art is difficult to accurately detect anomalies in sample data, which affects the classification effect of the model trained on the sample data.
By obtaining the offline loss sequence formed by the sample data in the historical training process, using the sample data carrying category labels to train the main network, and using the offline loss sequence to train the sub-network to update the weight parameters of the main network and sub-network, and build an anomaly detection model. Anomaly detection in target sample data.
It improves the classification effect of the model trained on the sample data, and can accurately detect anomalies in the sample data, improving the accuracy of anomaly detection.
Smart Images

Figure CN113705699B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a sample anomaly detection method, device, computer equipment and computer storage medium based on machine learning. Background Art
[0002] As classification technology continues to deepen in the field of machine learning, a series of new problems and challenges have also emerged. Among them, the classification of abnormal sample data is one of the difficulties. The abnormal sample data can be expressed as unbalanced sample data or incorrectly labeled sample data. Unbalanced sample data is a sample space with uneven category distribution. The number of samples in a certain category is less than or much less than the number of samples in other categories. It is used as a large category in the classification process, while other sample data is used as a small category in the classification process. Incorrectly labeled sample data is a sample space with category label noise, which also affects the category distribution in the sample data to a certain extent. Since abnormal text data will be affected by data imbalance and label problems in the process of machine learning, it is necessary to perform anomaly detection on sample data.
[0003] In the related technology, the method for sample anomaly detection mainly uses sample assignment, and reduces the weight of sample data in the training process through the loss function, and continuously adjusts the parameters again and again. Since the loss function is a fixed strategy before training, its effect is not as good as dynamically adjusting the weights to continuously reassign. The dynamic re-weighting process is mainly based on the model parameters at the current moment or at several current moments to learn and assign weights. However, considering that the abnormal situation in the sample data is an unchanging state, and the model parameters relied on by the above-mentioned re-weighting method are constantly changing, it is difficult to accurately detect the abnormal situation in the sample data, which affects the classification effect of the model trained on the sample data. Summary of the invention
[0004] In view of this, the present invention provides a sample anomaly detection method, device, computer equipment and computer storage medium based on machine learning. The main purpose is to solve the problem in the prior art that it is difficult to accurately detect anomalies in sample data based on the re-weighting method, which affects the classification effect of the model trained for the sample data.
[0005] According to one aspect of the present invention, a sample anomaly detection method based on machine learning is provided, the method comprising:
[0006] Obtain the offline loss sequence formed by the sample data during the historical training process;
[0007] Use sample data with category labels to train the main network for classification tasks;
[0008] Using the offline loss sequence to train the sub-network to assign weights to the sample data, and updating the weight parameters of the main network and the sub-network;
[0009] In response to an anomaly detection instruction for the target sample data, anomaly detection is performed on the category labels in the target sample data according to the anomaly detection model constructed by the updated sub-network.
[0010] In another embodiment of the present invention, the obtaining of an offline loss sequence formed by the sample data during the historical training process specifically includes:
[0011] Input sample data into the network model for historical training, and during the historical training of the network model, record the loss value formed by the loss function outputting the predicted value and the actual value in each iteration cycle;
[0012] Aggregate the loss values output over multiple iterations to form an offline loss sequence.
[0013] In another embodiment of the present invention, the offline loss sequence includes sample label information and sample bias information, and the sub-network is trained using the offline loss sequence to assign weights to the sample data and update the weight parameters of the main network and the sub-network, specifically including:
[0014] Using the sample label information and the sample bias information to train a subnetwork to assign weights to the sample data, and outputting the category weights of the sample data;
[0015] According to the category weights of the sample data, the weight parameters of the main network and the sub-network are updated.
[0016] In another embodiment of the present invention, updating the weight parameters of the main network and the sub-network according to the category weight of the sample data specifically includes:
[0017] According to the category weight of the sample data, the sub-network is optimized using a metadata set carrying a category label to minimize a loss value output by the metadata set on the main network, wherein the metadata set is obtained by processing the sample data;
[0018] Optimizing the main network using the sample data according to the weight parameters output by the optimized sub-network;
[0019] The process of optimizing the sub-network and optimizing the main network is repeatedly and iteratively performed, and the weight parameters of the main network and the sub-network are updated.
[0020] In another embodiment of the present invention, optimizing the subnetwork using a metadata set carrying a category label according to the category weight of the sample data specifically includes:
[0021] Determining, according to the category weight of the sample data, a loss value outputted by the metadata data set carrying the classification label on the main network;
[0022] Taking minimization of the loss value as the optimization goal, the weight parameters of the sub-network are updated.
[0023] In another embodiment of the present invention, the anomaly detection model constructed according to the updated sub-network performs anomaly detection on the category label in the target sample data, specifically including:
[0024] According to the anomaly detection model constructed by the updated sub-network, determining whether there is an abnormal representation in the category label of the target sample data;
[0025] If so, the target sample data is adjusted according to the abnormal representation obtained by the detection.
[0026] In another embodiment of the present invention, the anomaly detection model constructed according to the updated sub-network determines whether there is an abnormal representation in the category label of the target sample data, specifically including:
[0027] Output the category weight of the target sample data according to the anomaly detection model constructed by the updated sub-network, determine the category distribution information in the target sample data, and use the category distribution information to determine whether there is an abnormal representation of uneven category distribution in the target sample data;
[0028] According to the loss data output by the anomaly detection model constructed by the updated sub-network, the category labeling information in the target sample data is determined, and the category labeling information is used to judge whether there is an abnormal representation with category labeling error in the target sample data.
[0029] According to another aspect of the present invention, a sample anomaly detection device based on machine learning is provided, the device comprising:
[0030] An acquisition unit, used to acquire an offline loss sequence formed by sample data during the historical training process;
[0031] A training unit, used to train a main network for a classification task using sample data carrying category labels;
[0032] An updating unit, configured to use the offline loss sequence to train a sub-network to assign weights to the sample data, and to update weight parameters of the main network and the sub-network;
[0033] The detection unit is used to respond to the anomaly detection instruction of the target sample data and perform anomaly detection on the category label in the target sample data according to the anomaly detection model constructed by the updated sub-network.
[0034] In another embodiment of the present invention, the acquisition unit includes:
[0035] A recording module is used to input sample data into the network model for historical training, and in the process of historical training of the network model, record the loss value formed by the loss function outputting the predicted value and the actual value in each iteration cycle;
[0036] The summary module is used to summarize the loss values output after multiple iterations to form an offline loss sequence.
[0037] In another embodiment of the present invention, the offline loss sequence includes sample label information and sample bias information, and the updating unit includes:
[0038] An assignment module, used to train a sub-network using the sample label information and the sample bias information to assign weights to the sample data, and output the category weights of the sample data;
[0039] The updating module is used to update the weight parameters of the main network and the sub-network according to the category weights of the sample data.
[0040] In another embodiment of the present invention, the update module includes:
[0041] A first optimization submodule, configured to optimize the subnetwork using a metadata set carrying a category label according to the category weight of the sample data, so as to minimize a loss value output by the metadata set on the main network, wherein the metadata set is obtained by processing the sample data;
[0042] A second optimization submodule, configured to optimize the main network using the sample data according to the weight parameters output by the optimized subnetwork;
[0043] The updating submodule is used to repeatedly iterate the process of optimizing the subnetwork and optimizing the main network, and to update the weight parameters of the main network and the subnetwork.
[0044] In another embodiment of the present invention, the first optimization submodule is specifically used to determine the loss value outputted on the main network by the metadata data set carrying the classification label according to the category weight of the sample data;
[0045] The first optimization submodule is specifically used to update the weight parameters of the subnetwork by taking minimization of the loss value as the optimization goal.
[0046] In another embodiment of the present invention, the detection unit comprises:
[0047] A judgment module, used to judge whether there is an abnormal representation in the category label of the target sample data according to the anomaly detection model constructed by the updated sub-network;
[0048] An adjustment module is used to adjust the target sample data according to the abnormal representation obtained by detection if yes.
[0049] In another embodiment of the present invention, the judgment module is specifically used to output the category weight of the target sample data according to the anomaly detection model constructed by the updated sub-network, determine the category distribution information in the target sample data, and use the category distribution information to judge whether there is an abnormal representation of uneven category distribution in the target sample data;
[0050] The judgment module is specifically used to determine the category labeling information in the target sample data based on the loss data output by the anomaly detection model constructed by the updated sub-network, and use the category labeling information to determine whether there is an abnormal representation of category labeling error in the target sample data.
[0051] According to another aspect of the present invention, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of a sample anomaly detection method based on machine learning when executing the computer program.
[0052] According to another aspect of the present invention, a computer storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of a sample anomaly detection method based on machine learning are implemented.
[0053] By means of the above technical scheme, the present invention provides a method and device for sample anomaly detection based on machine learning, which obtains the offline loss sequence formed by the sample data in the historical training process, and uses the sample data carrying the category label to train the main network for the classification task, uses the offline loss sequence to train the sub-network to assign weights to the sample data, and updates the weight parameters of the main network and the sub-network, responds to the anomaly detection instruction of the target sample data, and performs anomaly detection on the category label in the target sample data according to the anomaly detection model constructed by the updated sub-network. Compared with the prior art method of using re-weighting to perform anomaly detection on sample data, the present application uses an offline loss sequence to train the sub-network to re-weight the sample data. The offline loss sequence characterizes the essential state of the sample data from different angles, and can give a more reasonable weight to the sample data. By adding the weight to the loss of the main network to the sample data during the training process, the training effect of the main network is improved, and the sub-network can also be used to perform anomaly detection on the sample data, thereby improving the classification effect of the model trained by the sample data. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0055] Figure 1 A schematic diagram of a flow chart of a sample anomaly detection method based on machine learning provided by an embodiment of the present invention is shown;
[0056] Figure 2 A schematic diagram of a process flow of another sample anomaly detection method based on machine learning provided by an embodiment of the present invention is shown;
[0057] Figure 3 A schematic diagram of the structure of a sample anomaly detection device based on machine learning provided by an embodiment of the present invention is shown;
[0058] Figure 4 A schematic diagram of the structure of another sample anomaly detection device based on machine learning provided in an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0059] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0060] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0061] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0062] The embodiment of the present invention provides a sample anomaly detection method based on machine learning, which uses an anomaly detection model constructed by a trained sub-network to accurately detect anomalies in sample data and improve the classification effect of the model trained on the sample data. Figure 1 As shown, the method includes:
[0063] 101. Obtain the offline loss sequence formed by the sample data during the historical training process.
[0064] Among them, the offline loss sequence is a data sequence formed by the loss value of the sample data. In the process of training the network model for the sample data history, multiple iteration cycles will be generated. In each iteration cycle, the loss function will be used to calculate the loss value between the prediction and the actual value. A loss value will be obtained for each sample data, so that an offline loss sequence will be formed for each sample data after multiple iteration cycles. The offline loss sequence contains sample label information and sample bias information, which is equivalent to a representation of the essential state of the data.
[0065] Generally speaking, for any classification task, such as disease prediction, face recognition, etc., sample data and sample labels are required. However, sample labels are mostly massive and need to be manually or machine labeled. Due to subjective and objective reasons, label noise will appear, and its existence will have a certain impact on the performance of the final classification model. Common label noise includes cross-category noise and random noise. Cross-category noise refers to the fact that images belonging to a certain category of the data set are mistakenly classified into another certain category of the data set. Random noise refers to the fact that among the images belonging to a certain category of the data set, there are a large number of images that are not related to the category label, and these images do not belong to any category in the data set. Since the offline loss sequence is formed in the process of inputting sample data into the historical network model for training, the loss value of each iteration of the sample data recorded in this process is equivalent to the gap between the predicted value and the actual value. Incorrect labels or unbalanced labels will affect the classification prediction results. If the loss value continues to represent a large gap, it means that the label of the sample data may be wrong or belongs to a small category in the sample data. On the contrary, if the loss value represents a small gap, it means that the label of the sample data may belong to a large category in the sample data. Here, the offline loss sequence can be used to characterize the noise of the sample data from different aspects, such as whether the category in the sample data is a large category or a small category, whether the label is accurate, etc.
[0066] In an embodiment of the present invention, the execution subject can be a sample anomaly detection device based on machine learning, which is specifically applied on the server side. The relevant technology can use the loss value output for the sample data during the training process to dynamically assign weights to the sample data during the network training process, and use the sub-network to map the loss of the previous moment to the weight of the corresponding sample data to obtain the category distribution of the sample data. However, since the paranoid state of the sample data is static rather than dynamic, this method needs to determine the loss function before training, and use the loss value output by the loss function during the training process to adjust the learning weight of the sample data, and then reduce the weight of the sample data that is easy to learn, so that the model can focus on learning the more difficult sample data. This process depends on the continuous change of the model parameters, so that the learning weight of the sample data is also constantly changing, and it is difficult to effectively extract the abnormal information of the sample data, affecting the accuracy of the sample anomaly detection. This application assigns weights to the sample data by using the offline loss sequence recorded during the historical network model training process. The offline loss sequence contains more accurate category label information, which can achieve better training effects and alleviate the paranoia in the sample data.
[0067] The above-mentioned servers can be independent servers or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0068] 102. Use sample data with category labels to train the main network for classification tasks.
[0069] Among them, the main network of the classification task can use different networks according to different task types. For example, the transformer encoder is used for the classification task of natural language processing, and the CNN network is used for the image classification task.
[0070] Assume the sample data is: D Train ={(x i ,y i ), 1≤i≤N}, the weight parameter of the main network F is θ, and the cross entropy loss function is generally calculated as follows:
[0071]
[0072] Here x is the sample data input to the main network. is the predicted category label output by the main network, N is the number of sample data, y i is the category label of the sample data.
[0073] It is understandable that the above training process for sample data can be widely used in any classification scenario, mainly for sample data with bias (imbalance, labeling errors, etc.). Taking the image classification task as an example, some images may be labeled incorrectly, and here we hope to assign a lower weight close to 0 to the labeled errors, while some images may have more categories, so these sample data need to be assigned relatively low weights during model training.
[0074] 103. Use the offline loss sequence to train the sub-network to assign weights to the sample data, and update the weight parameters of the main network and the sub-network.
[0075] Taking into account that the sample data itself may be biased, where the bias can be imbalanced sample features, imbalanced sample labels, incorrect sample labels, etc., the idea of meta-learning is used here to map the offline loss sequence to the category weight of the sample data using a sub-network.
[0076] Specifically, the sub-network can be set to H, and the weight parameter can be set to w. The sub-network can be any small network, generally CNN or MLP, that is, the offline loss function sequence is s. Generally, the more thorough the process of training the historical network model, the better the offline loss sequence contains sample label information and sample bias information, and the better the classification effect will be when used to optimize the main network. The optimization of the main network with weighted data can be expressed as follows:
[0077]
[0078] Here v is the category weight of the subnetwork output sample data.
[0079] 104. In response to an anomaly detection instruction of the target sample data, anomaly detection is performed on the category labels in the target sample data according to the anomaly detection model constructed by the updated sub-network.
[0080] Since the updated subnetwork can learn the categories in the sample data and output the category weights of the sample data, the subnetwork has the ability to identify the category labels and category distribution in the sample data. The anomaly detection model constructed for the subnetwork can detect whether there are abnormal representations in the sample data based on the category labels and category distribution.
[0081] The abnormal representations detected here can be the existence of category labeling errors in the target sample data and the existence of uneven category distribution in the target sample data. On the one hand, according to the category weight of the target sample data output by the anomaly detection model, the category distribution in the target sample data can be determined. On the other hand, according to the loss data of the target sample data output by the anomaly detection model, the category labeling in the target sample data can be determined. The larger the mean and variance of the loss data, the greater the probability that the target sample data belongs to a noise sample, indicating that the target sample data has labeling errors on the category label.
[0082] The embodiment of the present invention provides a sample anomaly detection method based on machine learning, which obtains the offline loss sequence formed by the sample data in the historical training process, and uses the sample data carrying the category label to train the main network for the classification task, and uses the offline loss sequence to train the sub-network to assign weights to the sample data, and updates the weight parameters of the main network and the sub-network, and responds to the anomaly detection instruction of the target sample data, and performs anomaly detection on the category label in the target sample data according to the anomaly detection model constructed by the updated sub-network. Compared with the prior art that uses the re-weighting method to perform anomaly detection on sample data, the present application uses the offline loss sequence to train the sub-network to re-weight the sample data. The offline loss sequence characterizes the essential state of the sample data from different angles, and can give a more reasonable weight to the sample data. By adding the weight to the loss of the main network to the sample data during the training process, the training effect of the main network is improved, and the sub-network can also be used to perform anomaly detection on the sample data, thereby improving the classification effect of the model trained by the sample data.
[0083] The embodiment of the present invention provides another sample anomaly detection method based on machine learning, which uses the anomaly detection model constructed by the trained sub-network to accurately detect anomalies in sample data and improve the classification effect of the model trained on the sample data. Figure 2 As shown, the method includes:
[0084] 201. Input the sample data into the network model for historical training, and in the process of historical training of the network model, record the loss value formed by the predicted value and the actual value output by the loss function in each iteration cycle.
[0085] 202. Summarize the loss values outputted through multiple iteration cycles to form an offline loss sequence.
[0086] It is understandable that since the offline loss sequence can characterize the label information and bias information of the sample data, the longer the iteration cycle of the historical training of the network model, the more thorough the network model training is, and the better the classification effect of the model is. At this time, the offline loss sequence reflects the label information and bias information of the sample data more accurately. Here, the loss value output by the network model with a longer iteration cycle during the historical training process can be selected to form an offline loss sequence. For example, the historical training process of the network model has undergone 20 iteration cycles, and the loss values output by 20 iteration cycles can be used to form a discrete loss sequence. Of course, considering the length limit of the offline loss sequence, the loss value output at the end of the iteration cycle can also be used to form an offline loss function. For example, the loss value output by the last 10 iteration cycles is used to form a discrete loss sequence.
[0087] 203. Use sample data with category labels to train the main network for classification tasks.
[0088] It should be noted that the main network trained here can output category labels for sample data, but the category labels do not take into account abnormal situations such as category distribution and label errors in the sample data. In other words, the category labels output by using the main network for category prediction may be wrong and the accuracy of the classification results cannot be guaranteed.
[0089] 204. Use the sample label information and the sample bias information to train a subnetwork to assign weights to the sample data, and output the category weights of the sample data.
[0090] Considering the influence of category labels and bias information in sample data on classification effect, the main network needs to be optimized. Here, sample label information and sample bias information are used to train the sub-network. The sub-network can accurately output the category weights of sample data. The category weights are further added to the loss of the main network corresponding to the sample data during the training process, so that the sample weights output by the sub-network allow the main network to perform better in the metadata set after being trained in the sample data, which helps to optimize the main network.
[0091] 205. Update the weight parameters of the main network and the sub-network according to the category weights of the sample data.
[0092] It is understandable that for the network model of the classification task, it is necessary to continuously try to train the network model on the same sample data. The loss sequence formed by the network model in the process can also be recorded. Since the loss sequence characterizes the essential characteristics of the static data from different aspects, by introducing a sub-network that maps the offline loss sequence to the category weight of the sample data, the recorded offline loss sequence of each sample data is used as the input of the sub-network, and the corresponding output is the category weight of the sample data. The category weight will be added to the loss of the main network corresponding to the sample data during the training process. The purpose is to enable the main network to adjust the learning weights of different categories in the sample data. Appropriate learning weights help optimize the main network, thereby improving the classification effect of the main network.
[0093] In order to ensure the optimization effect of the main network and the sub-network, the sub-network is first optimized here, and then the output of the optimized sub-network is used to optimize the main network. Specifically, the sub-network can be optimized according to the category weight of the sample data and the metadata set carrying the category label to minimize the loss value output by the metadata set on the main network. The metadata set is obtained by processing the sample data, and according to the weight parameters output by the optimized sub-network, the main network is optimized using the sample data. The process of optimizing the sub-network and optimizing the main network is iteratively executed repeatedly, and the weight parameters of the main network and the sub-network are updated.
[0094] Specifically according to the category weight of the sample data, in the process of optimizing the sub-network using the metadata set carrying the category label, the loss value output by the metadata set carrying the category label on the main network can be determined according to the category weight of the sample data, and the weight parameter of the sub-network is updated with the loss value minimized as the optimization goal. Here, the metadata set can be formed by secondary optimization of the biased data part in the current sample data, which is equivalent to part of the data in the sample data. Usually, the part of the data has a more accurate category label and a smaller data volume. For example, in the picture classification scenario, the sample data can be 10,000 pictures that may be incorrectly labeled, and the metadata set is 100 correctly labeled pictures. Since the labeling of the sample data is not accurate, the metadata set is used here to verify the classification effect of the main network. The specific direction of optimizing the sub-network is to make the category weight of its output metadata set enable the classification effect of the main network (on the metadata set) to be better.
[0095] Assume the sample data is: In the process of updating the weight parameters of the main network and the sub-network using the metadata set carrying the classification labels, it can be achieved by the following formula: The formula is to find the minimum w so that the loss of the main network on the meta-data set is minimized.
[0096] The specific process mainly includes two stages. The first stage is the process of obtaining the offline loss sequence for the sample data. After obtaining the offline loss sequence of the sample data, the second stage begins. The second stage is the process of updating the weight parameters of the main network and the sub-network mentioned above, which corresponds to the algorithm process below. That is, the following process is iteratively performed: First, the main network is optimized once using the weighted loss and sample data to obtain the weight parameters of the temporarily updated main network. Then the weight parameter w of the sub-network is optimized using the cross loss function and the meta-dataset t+1 , so that the weight parameters of the main network after temporary update have less loss on the metadata data set. Finally, for the sample data, the optimized sub-network is used to output the category weights of the sample data, and the category weights of the sample data are used to optimize the weight parameters θ of the main network. t+1 , and further iterate the optimization process of the main network weight parameters and the sub-network weight parameters.
[0097] 206. In response to the anomaly detection instruction of the target sample data, determine whether there is an abnormal representation in the category label of the target sample data according to the anomaly detection model constructed by the updated sub-network.
[0098] Since the main network can reassign the category weights of sample data during the training process, the main network has a better classification effect on the sample data after updating the weight parameters. The optimized main network can be used to build a classification model, and the optimized sub-network can be used alone as an anomaly detection model to detect sample bias, to determine whether there are labeling errors in the category labels in the sample data and to detect the distribution of each category in the sample data.
[0099] Specifically, the category weight of the target sample data can be output according to the anomaly detection model constructed by the updated sub-network to determine the category distribution information in the target sample data, and the category distribution information can be used to judge whether the category labels in the target sample data have abnormal representations of uneven category distribution. The category labeling information in the target sample data can be determined according to the loss data output by the anomaly detection model constructed by the updated sub-network, and the category labeling information can be used to judge whether the category labels in the target sample data have abnormal representations of incorrect labeling.
[0100] 207. If yes, adjust the target sample data according to the abnormal representation obtained by detection.
[0101] It can be understood that if there are abnormal representations in the category labels of the detected target sample data, it means that there are abnormal representations with uneven category distribution in the target sample data or abnormal representations with category labeling errors in the target sample data. Here, for the abnormal representations with uneven category distribution, the distribution of samples of each category in the target sample data can be adjusted, and for the abnormal representations with category labeling errors, the category labeling errors in the target sample data can be modified.
[0102] This application uses offline loss sequences to assign weights to sample data, which can give more reasonable weights to sample data than other related work, so that the effect of the main network is improved, and the sub-network can be used to detect anomalies in sample data. Among them, offline loss sequences can be obtained in a variety of ways, and the diversity of multiple offline loss sequences can further improve the performance of classification models and anomaly detection models. Furthermore, in the network training process after adding the offline loss sequence, the offline loss sequence can also be updated so that it can be added in the next network training, and repeated training can be used to obtain better classification effects and sample anomaly detection effects.
[0103] Further, as Figure 1 In a specific implementation of the method, an embodiment of the present invention provides a sample anomaly detection device based on machine learning, such as Figure 3 As shown, the device includes: an acquisition unit 31, a training unit 32, an updating unit 33, and a detection unit 34.
[0104] An acquisition unit 31 may be used to acquire an offline loss sequence formed by sample data during a historical training process;
[0105] A training unit 32, which can be used to train a main network for a classification task using sample data carrying category labels;
[0106] An updating unit 33 may be used to train a sub-network using the offline loss sequence to assign weights to the sample data, and to update weight parameters of the main network and the sub-network;
[0107] The detection unit 34 can be used to respond to the anomaly detection instruction of the target sample data and perform anomaly detection on the category label in the target sample data according to the anomaly detection model constructed by the updated sub-network.
[0108] The embodiment of the present invention provides a sample anomaly detection device based on machine learning, which obtains the offline loss sequence formed by the sample data in the historical training process, and uses the sample data carrying the category label to train the main network for the classification task, and uses the offline loss sequence to train the sub-network to assign weights to the sample data, and updates the weight parameters of the main network and the sub-network, and responds to the anomaly detection instruction of the target sample data, and performs anomaly detection on the category label in the target sample data according to the anomaly detection model constructed by the updated sub-network. Compared with the prior art that uses the re-weighting method to perform anomaly detection on sample data, the present application uses the offline loss sequence to train the sub-network to re-weight the sample data. The offline loss sequence characterizes the essential state of the sample data from different angles, and can give a more reasonable weight to the sample data. By adding the weight to the loss of the main network to the sample data during the training process, the training effect of the main network is improved, and the sub-network can also be used to perform anomaly detection on the sample data, thereby improving the classification effect of the model trained by the sample data.
[0109] As Figure 3 Further description of the machine learning based sample anomaly detection device shown in, Figure 4 is a schematic diagram of the structure of another sample anomaly detection device based on machine learning according to an embodiment of the present invention. Figure 4 As shown, the acquisition unit 31 includes:
[0110] The recording module 311 can be used to input sample data into the network model for historical training, and in the process of historical training of the network model, record the loss value formed by the predicted value and the actual value output by the loss function in each iteration cycle;
[0111] The summarization module 312 may be used to summarize the loss values outputted through multiple iteration cycles to form an offline loss sequence.
[0112] In specific application scenarios, such as Figure 4 As shown, the offline loss sequence includes sample label information and sample bias information, and the updating unit 33 includes:
[0113] The assignment module 331 may be used to train a sub-network using the sample label information and the sample bias information to assign weights to the sample data and output the category weights of the sample data;
[0114] The updating module 332 may be used to update the weight parameters of the main network and the sub-network according to the category weights of the sample data.
[0115] In specific application scenarios, such as Figure 4 As shown, the update module 332 includes:
[0116] A first optimization submodule 3321 may be used to optimize the subnetwork using a metadata set carrying a category label according to the category weight of the sample data, so as to minimize a loss value output by the metadata set on the main network, wherein the metadata set is obtained by processing the sample data;
[0117] The second optimization submodule 3322 may be used to optimize the main network using the sample data according to the weight parameters output by the optimized subnetwork;
[0118] The updating submodule 3323 may be used to repeatedly iterate the process of optimizing the subnetwork and optimizing the main network, and update the weight parameters of the main network and the subnetwork.
[0119] In a specific application scenario, the first optimization submodule 3321 can be specifically used to determine the loss value outputted on the main network by the metadata set carrying the classification label according to the category weight of the sample data;
[0120] The first optimization submodule 3321 can also be specifically used to update the weight parameters of the subnetwork by taking minimization of the loss value as the optimization goal.
[0121] In specific application scenarios, such as Figure 4 As shown, the detection unit 34 includes:
[0122] The judgment module 341 can be used to judge whether there is an abnormal representation in the category label of the target sample data according to the anomaly detection model constructed by the updated sub-network;
[0123] The adjustment module 342 may be configured to adjust the target sample data according to the abnormal representation obtained by the detection.
[0124] In a specific application scenario, the judgment module 341 can be specifically used to output the category weight of the target sample data according to the anomaly detection model constructed by the updated sub-network, determine the category distribution information in the target sample data, and use the category distribution information to judge whether there is an abnormal representation of uneven category distribution in the target sample data;
[0125] The judgment module 341 can also be specifically used to determine the category labeling information in the target sample data based on the loss data output by the anomaly detection model constructed by the updated sub-network, and use the category labeling information to determine whether there is an abnormal representation of category labeling error in the target sample data.
[0126] It should be noted that for other corresponding descriptions of the functional units involved in the sample anomaly detection device based on machine learning provided in this embodiment, please refer to Figure 1 , Figure 2 The corresponding description in will not be repeated here.
[0127] Based on the above Figure 1 , Figure 2 The method shown in the embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned Figure 1 , Figure 2 The sample anomaly detection method based on machine learning is shown.
[0128] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0129] Based on the above Figure 1 , Figure 2 The method shown, and Figure 3 , Figure 4 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides a computer device, which can be a personal computer, a server, a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 , Figure 2 The sample anomaly detection method based on machine learning is shown
[0130] Optionally, the computer device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a Bluetooth interface, a WI-FI interface), etc.
[0131] Those skilled in the art will understand that the physical device structure of the machine learning-based sample anomaly detection apparatus provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0132] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned computer device, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the physical device.
[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the technical solution of the present application, compared with the current prior art, the present application uses an offline loss sequence training sub-network to re-weight the sample data. The offline loss sequence characterizes the essential state of the sample data from different angles, and can give a more reasonable weight to the sample data. By adding the weight to the loss of the sample data by the main network during the training process, the training effect of the main network is improved, and the sub-network can also be used to detect anomalies in the sample data, thereby improving the classification effect of the model trained by the sample data.
[0134] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0135] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A sample anomaly detection method based on machine learning, characterized in that: The method comprises: Obtain an offline loss sequence formed by sample data during historical training. In the image classification scenario, the sample data is an image. Specifically, the sample data is input into the network model for historical training. During the historical training of the network model, the loss value formed by the predicted value and the actual value output by the loss function in each iteration cycle is recorded. The loss values output after multiple iteration cycles are summarized to form an offline loss sequence. Use sample data with category labels to train the main network for classification tasks; The offline loss sequence is used to train the subnetwork to assign weights to the sample data, and the weight parameters of the main network and the subnetwork are updated, wherein the offline loss sequence includes sample label information and sample bias information, and the sample label information and the sample bias information are used to train the subnetwork to assign weights to the sample data, and output the category weights of the sample data; according to the category weights of the sample data, the subnetwork is optimized using a metadata set carrying category labels to minimize the loss value output by the metadata set on the main network, wherein the metadata set is obtained by processing the sample data; according to the weight parameters output by the optimized subnetwork, the main network is optimized using the sample data; the process of optimizing the subnetwork and optimizing the main network is repeatedly and iteratively executed, and the weight parameters of the main network and the subnetwork are updated; In response to an anomaly detection instruction for the target sample data, anomaly detection is performed on the category labels in the target sample data according to the anomaly detection model constructed by the updated sub-network.
2. The method according to claim 1, characterized in that The optimizing the subnetwork by using a metadata set carrying a category label according to the category weight of the sample data specifically includes: Determining, according to the category weight of the sample data, a loss value outputted by the metadata data set carrying the classification label on the main network; Taking minimization of the loss value as the optimization goal, the weight parameters of the sub-network are updated.
3. The method according to any one of claims 1 to 2, characterized in that: The anomaly detection model constructed according to the updated sub-network performs anomaly detection on the category labels in the target sample data, specifically including: According to the anomaly detection model constructed by the updated sub-network, determining whether there is an abnormal representation in the category label of the target sample data; If so, the target sample data is adjusted according to the abnormal representation obtained by the detection.
4. The method according to claim 3, characterized in that The anomaly detection model constructed according to the updated sub-network determines whether there is an abnormal representation in the category label of the target sample data, specifically including: Output the category weight of the target sample data according to the anomaly detection model constructed by the updated sub-network, determine the category distribution information in the target sample data, and use the category distribution information to determine whether there is an abnormal representation of uneven category distribution in the target sample data; According to the loss data output by the anomaly detection model constructed by the updated sub-network, the category labeling information in the target sample data is determined, and the category labeling information is used to judge whether there is an abnormal representation with category labeling error in the target sample data.
5. A sample anomaly detection device based on machine learning, characterized in that: The device comprises: An acquisition unit is used to acquire an offline loss sequence formed by sample data during a historical training process. In an image classification scenario, the sample data is an image. Specifically, the sample data is input into a network model for historical training. During the historical training of the network model, a loss value formed by outputting a predicted value and an actual value using a loss function in each iteration cycle is recorded. The loss values outputted through multiple iteration cycles are summarized to form an offline loss sequence. A training unit, used to train a main network for a classification task using sample data carrying category labels; An updating unit is used to train a subnetwork using the offline loss sequence to assign weights to the sample data, and to update weight parameters of the main network and the subnetwork, wherein the offline loss sequence includes sample label information and sample bias information, and specifically uses the sample label information and sample bias information to train the subnetwork to assign weights to the sample data, and outputs the category weights of the sample data; optimizes the subnetwork using a metadata set carrying category labels according to the category weights of the sample data, so as to minimize the loss value output by the metadata set on the main network, wherein the metadata set is obtained by processing the sample data; optimizes the main network using the sample data according to the weight parameters output by the optimized subnetwork; repeatedly and iteratively executes the process of optimizing the subnetwork and optimizing the main network, and updates the weight parameters of the main network and the subnetwork; The detection unit is used to respond to the anomaly detection instruction of the target sample data and perform anomaly detection on the category label in the target sample data according to the anomaly detection model constructed by the updated sub-network.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
