Data Classification Method, Apparatus and Electronic Device
By determining the weight of the training loss value based on the sample type in neural network model training, the problem that noise samples affect the accuracy of the model is solved, the learning effect and accuracy of the classification model are improved, and additional manual annotation is avoided.
Patent Information
- Application Number
- CN202110254104.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-04
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2041-03-04
AI Technical Summary
During the training of neural network model, the existence of noise samples causes learning effects to deviate from expectations, affecting the classification accuracy of the model.
By determining the weight of the training loss value based on the sample type of the training sample, the classification model can improve the processing ability of the noise samples, and use the trained classification model to classify data to avoid additional manual labeling of noise samples.
The learning effect and classification accuracy of the classification model are improved, the model's processing ability of noise samples is improved, and additional labor costs are avoided.
Smart Images

Figure CN113705598B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology. Specifically, this application relates to a data classification method, apparatus, and electronic device. Background Art
[0002] A neural network (NN) model is a complex network system formed by a large number of processing units widely interconnected, and is a complex mathematical model for data processing by simulating many basic characteristics of the human brain function. The neural network model can be applied to various fields of data processing, such as text classification, image classification, etc.
[0003] Before using the neural network model for data processing, it is necessary to iteratively train the neural network model with a large number of training samples, and continuously adjust the model parameters during the training process until the training end condition is met to obtain a trained neural network model. When training the neural network model, the model can be trained with training samples with sample labels. However, when the training samples contain samples with incorrect class annotations (which can also be called noise samples), the learning effect of the neural network model will deviate from the expectation of the classification task, resulting in the trained neural network model being unable to give accurate judgments during application, affecting the use effect of the neural network model. Therefore, in the process of training the neural network model, how to process the noise samples to improve the learning effect of the neural network model has become a problem to be solved. Summary of the Invention
[0004] Embodiments of this application provide a data classification method, apparatus, and electronic device. Based on this solution, the learning effect of the classification model can be improved, thereby improving the classification accuracy of the trained classification model.
[0005] To achieve the above object, the specific technical solutions provided by the embodiments of this application are as follows:
[0006] On the one hand, an embodiment of this application provides a data classification method, and the method includes:
[0007] Obtain data to be classified; the data to be classified includes image data or text data;
[0008] Input the data to be classified into a trained classification model to obtain a classification result corresponding to the data to be classified;
[0009] Wherein, the trained classification model is obtained by training the classification model with a training sample set, the training loss value of the classification model is determined based on the weights of the training loss values corresponding to the respective training samples in the training sample set, and the weights of the training loss values corresponding to the respective training samples are determined based on the sample types of the respective training samples, and the sample types are noise samples or non-noise samples.
[0010] On the other hand, an embodiment of the present application further provides a data classification device, which includes:
[0011] An acquisition module, configured to acquire data to be classified; the data to be classified includes image data or text data;
[0012] A classification module, configured to input the data to be classified into a trained classification model to obtain a classification result corresponding to the data to be classified;
[0013] Wherein, the trained classification model is obtained by training the classification model with a training sample set, the training loss value of the classification model is determined based on the weights of the training loss values corresponding to the respective training samples in the training sample set, and the weights of the training loss values corresponding to the respective training samples are determined based on the sample types of the respective training samples, and the sample types are noise samples or non-noise samples.
[0014] An embodiment of the present application further provides an electronic device, which includes one or more processors; a memory; one or more computer programs, wherein one or more computer programs are stored in the memory and configured to be executed by one or more processors, and one or more computer programs are configured to execute the above data classification method or the method provided in various alternative implementations of the data classification method.
[0015] An embodiment of the present application further provides a computer-readable storage medium, which is used to store a computer program. When the computer program runs on a processor, the processor can execute the above data classification method or the method provided in various alternative implementations of the data classification method.
[0016] An embodiment of the present application further provides a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above data classification method or the method provided in various alternative implementations of the data classification method.
[0017] The beneficial effects brought by the technical solution provided by the present application are:
[0018] The present application provides a data classification method, apparatus and electronic device, which use a trained classification model for data classification. The training loss value of the classification model is determined based on the weights of the training loss values corresponding to the respective training samples in the training sample set. The weights of the training loss values corresponding to the respective training samples are determined based on the sample types of the respective training samples. Determining the training loss value of the classification model according to the sample types of the respective training samples can improve the processing ability of the classification model for noise samples, enhance the learning effect of the model, and thus improve the classification accuracy of the trained classification model. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments of the present application.
[0020] Figure 1 It is a flowchart of the data classification method provided by the embodiment of the present application;
[0021] Figure 2 It is a schematic structural diagram of a convolutional block provided by the embodiment of the present application;
[0022] Figure 3 It is a schematic diagram of the data processing process of the training method of the classification model provided by the embodiment of the present application;
[0023] Figure 4 It is a schematic diagram of the update process of the memory unit provided by the embodiment of the present application;
[0024] Figure 5 It is a schematic diagram of the application process of the classification model provided by the embodiment of the present application;
[0025] Figure 6 It is a schematic structural diagram of the data classification apparatus provided by the embodiment of the present application;
[0026] Figure 7 It is a schematic structural diagram of an electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] The following will describe in detail the embodiments of the present application. The examples of the embodiments are shown in the drawings, where the same or similar reference numerals denote the same or similar elements or elements with the same or similar functions from beginning to end. The embodiments described below by referring to the drawings are exemplary and are only used to explain the present application, and should not be construed as limiting the present application.
[0028] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application means the presence of the described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say that an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more related listed items.
[0029] When training a classification model in the embodiments of the present application, the training samples contain noise samples, which causes the learning effect of the classification model to deviate from the expectation of the classification task, resulting in the trained classification model being unable to give accurate judgments during application and affecting the use effect of the classification model. To solve this problem, a data classification method is provided. When using the trained classification model for data classification, there is no need for additional manual annotation of noise samples during the training of the classification model, which does not increase the labor cost. According to the sample type of the training samples, the training loss value of the classification model can be determined, which can improve the processing ability of the classification model for noise samples, enhance the learning effect of the model, and thus improve the classification accuracy of the trained classification model.
[0030] The solution provided by the embodiments of the present application relates to fields such as cloud technology, big data, and artificial intelligence in computer technology.
[0031] In the embodiments of the present application, the data processing involved can be implemented through cloud technology, and the data calculation involved can be implemented through cloud computing in cloud technology.
[0032] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computing devices, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides resources is called the "cloud". The resources in the "cloud" seem to be infinitely expandable to users, and can be obtained at any time, used on demand, expanded at any time, and paid according to usage.
[0033] As a basic cloud computing capabilities provider, a cloud computing resource pool (abbreviated as cloud platform, generally known as IaaS (Infrastructure as a Service) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to select and use. The cloud computing resource pool mainly includes computing devices (virtual machines containing operating systems), storage devices, and network devices.
[0034] According to the logical function division, the PaaS (Platform as a Service) layer can be deployed on the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, the SaaS can be directly deployed on the IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is various business software, such as web portals, mass text message senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
[0035] Cloud computing refers to the delivery and usage model of IT infrastructure, which means obtaining the required resources through the network in a demand-driven and easily scalable manner; in a broad sense, cloud computing refers to the delivery and usage model of services, which means obtaining the required services through the network in a demand-driven and easily scalable manner. Such services can be related to IT, software, the Internet, or other services. Cloud computing is the product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balance.
[0036] With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the promotion of demands such as search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Different from the previous parallel distributed computing, the emergence of cloud computing will revolutionize the entire Internet model and enterprise management model conceptually.
[0037] The training of the classification model involved in the embodiments of this application can be achieved through machine learning in artificial intelligence technology.
[0038] Artificial Intelligence (AI) uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, including theories, methods, technologies, and application systems that can perceive the environment, acquire knowledge, and use knowledge to achieve the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines to enable machines to have the functions of perception, reasoning, and decision-making.
[0039] Artificial intelligence technology is an interdisciplinary subject with a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, large image processing technology, operation / interaction systems, and mechatronics. The artificial intelligence technology involved in the embodiments of this application mainly includes several major directions such as machine learning / deep learning.
[0040] Machine Learning (ML) is an interdisciplinary subject that involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications cover all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and rote learning.
[0041] The training samples required for data classification involved in the embodiments of this application can be big data obtained from the Internet.
[0042] Big data refers to a collection of data that cannot be captured, managed, and processed by conventional software tools within a certain time range. It is a massive, high-growth, and diverse information asset that requires new processing models to have stronger decision-making power, insight discovery ability, and process optimization ability. With the advent of the cloud era, big data has attracted more and more attention. Big data requires special technologies to effectively process a large amount of data that can tolerate the elapsed time. Technologies applicable to big data include massively parallel processing databases, data mining, distributed file systems, distributed databases, cloud computing platforms, the Internet, and scalable storage systems.
[0043] The execution subject of the technical solution of this application is a computer device, including but not limited to servers, personal computers, laptops, tablets, smartphones, etc. The computer device includes a user device and a network device. Among them, the user device includes but not limited to computers, smartphones, PADs, etc.; the network device includes but not limited to a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of computers or network servers in cloud computing. Among them, cloud computing is a type of distributed computing and consists of a super virtual computer composed of a group of loosely coupled computer sets. Among them, the computer device can run alone to implement this application, or can be connected to the network and implement this application through interactive operations with other computer devices in the network. Among them, the network where the computer device is located includes but not limited to the Internet, wide area network, metropolitan area network, local area network, VPN network, etc.
[0044] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of this application with reference to the accompanying drawings.
[0045] An embodiment of this application provides a data classification method. The execution subject of this method can be any electronic device. For example, this method can be executed by a server, such as Figure 1 As shown, this method may include:
[0046] Step S101, obtain the data to be classified;
[0047] Among them, the data to be classified includes image data or text data. The data to be classified can also be other types of data that can be converted into image data or text data through a certain processing method, including but not limited to video data, audio data, and video-audio data.
[0048] Step S102, input the data to be classified into the trained classification model to obtain the classification result corresponding to the data to be classified;
[0049] Among them, the trained classification model is obtained by training the classification model with a training sample set. The training loss value of the classification model is determined based on the weights of the training loss values corresponding to each training sample in the training sample set. The weights of the training loss values corresponding to each training sample are determined based on the sample type of each training sample, and the sample type is a noise sample or a non-noise sample.
[0050] Among them, the classification result corresponding to the data to be classified can be an indication that the data to be classified belongs to a certain classification category corresponding to the classification model, or the probability that the data to be classified belongs to each classification category corresponding to the classification model, or any other type of information that can characterize the classification category of the data to be classified. This application does not make any limitations in this regard.
[0051] The classification model in the technical solution of this application can be any mathematical model that classifies the data to be classified into different categories according to the data features after extracting the data features of the data to be classified.
[0052] Optionally, the classification model in the technical solution of this application can be a neural network model applied to different classification scenarios. For example, an image classification model applied to the image recognition scenario. The image classification model performs category-level recognition on images, without considering specific instances of objects, and only considers the categories of objects (such as people, dogs, cats, birds, etc.) for recognition, and gives the category to which the object belongs. A typical example is the recognition task in the large-scale general object recognition open-source dataset ImageNet, which recognizes which of the 1000 categories a certain object belongs to.
[0053] Optionally, the image classification model can also be a model for multi-label recognition of images, which can identify whether an image has a combination of specified attribute labels through a computer. For example, an image may have multiple attributes, and the multi-label recognition task is to determine which preset attribute labels a certain image has.
[0054] Optionally, the classification model can also be a text classification model that classifies texts according to text features.
[0055] Optionally, the initial model of the classification model can be a deep learning network model whose parameter weights are trained based on the ImageNet dataset, that is, the ImageNet pre-trained model.
[0056] Among them, the training samples in the training sample set include samples with true class labels. Samples with true class labels are samples that have been manually or machine-labeled, and the true class label is the labeled label. The training sample set can be sample data including noise samples. Noise samples include samples with incorrect class labels caused by mislabeling and samples with inconsistent samples and corresponding class labels due to unclear concepts.
[0057] For example, for inter-class image recognition of scenes, the scenes in the images are easily confused, resulting in a higher mislabeling rate than that of normal classification data. For example, both a coffee shop and a library are collections of tables and chairs. When labeling them, a corner of the library may be labeled as a coffee shop (without coffee-related markers), that is, a sample with a noise label in the labeling.
[0058] It can be understood that non-noise samples are samples with accurate class labels, which can also be referred to as clean samples.
[0059] In the embodiments of the present application, a trained classification model is used for data classification. The training loss value of the classification model is determined based on the weights of the training loss values corresponding to each training sample in the training sample set. The weights of the training loss values corresponding to each training sample are determined based on the sample types of each training sample. Determining the training loss value of the classification model according to the sample types of each training sample can improve the processing ability of the classification model for noise samples, enhance the learning effect of the model, and thus improve the classification accuracy of the trained classification model.
[0060] In a possible implementation manner, the classification model is trained through the following steps:
[0061] Obtain a training sample set, where the training sample set includes training samples in each batch, and each batch of training samples includes each training sample with a true class label;
[0062] For each batch of training samples, repeat the following training operations until the training loss value of the classification model meets the preset training end condition to obtain a trained classification model:
[0063] For each training sample in the current batch, input the training sample into the classification model, extract the sample feature vector of the training sample, and based on the sample feature vector, obtain the class prediction result of the training sample;
[0064] Obtain the class feature vectors of each classification class corresponding to the classification model;
[0065] For each training sample, based on the similarity between the sample feature vector of the training sample and the class feature vectors of each class, determine the recommended class label corresponding to the training sample, and based on the true class label and the recommended class label of the training sample, determine the sample type of the training sample;
[0066] For each training sample, based on the sample type of the training sample, determine the weight of the training loss value corresponding to the training sample;
[0067] Based on the weights of the training loss values corresponding to each training sample, the class prediction results of each training sample, and the true class labels of each training sample, determine the training loss value of the classification model. Among them, if the training loss value does not meet the training end condition, adjust the model parameters of the classification model, and obtain the next batch of training samples in the training sample set and perform the next training operation.
[0068] Among them, the training sample set can be sample data related to the application scenario of the classification model, including but not limited to image data, text data, video data, audio data, and video-audio data. The training sample set includes training samples in each batch. Each time a training operation is performed, a batch of training samples is selected for model training. If the training loss value of the current training operation does not meet the training end condition, the model parameters of the classification model are adjusted, and the next batch of training samples is obtained from the training sample set for another training operation.
[0069] When training the classification model, the training samples are input into the classification model. The sample feature vectors of the training samples are extracted through the feature extraction module of the classification model. Through the classification module in the classification model, the training samples are classified based on the sample feature vectors to obtain the classification prediction results of each training sample. According to the true class labels corresponding to each training sample, the training samples with the same true class label can be divided into the same classification category, thereby obtaining multiple classification categories, that is, each classification category corresponding to the classification model.
[0070] Optionally, for each classification category, the category feature vector of the classification category can be determined according to the sample feature vectors of the training samples in the classification category. Each classification category can have at least one category feature vector. At a certain moment during the iterative training of the classification model, the category feature vector of each classification category is also called the memory unit (memory bank) of the classification category at that moment.
[0071] For each training sample, calculate the similarity between the sample feature vector of the training sample and each category feature vector. According to the calculation results of each similarity, determine the recommended category label corresponding to the training sample. Optionally, the category label of the classification category corresponding to the similarity that meets the preset condition can be used as the recommended category label corresponding to the training sample. Each training sample can correspond to at least one recommended category label.
[0072] Based on the true class label and the recommended class label of the training sample, the sample type of the training sample can be determined as a noise sample or a non-noise sample. For each training sample, if the training sample is a noise sample, a relatively small weight can be configured for the training loss value of the training sample; if the training sample is a non-noise sample, a relatively large weight can be configured for the training loss value of the training sample. For each training sample, according to the classification prediction result of the training sample and the true class label of the training sample, the training loss value corresponding to the training sample can be calculated. According to the training loss values corresponding to each training sample and the weights of the training loss values corresponding to each training sample, the training loss value of the classification model is determined.
[0073] Optionally, for any training sample, the class prediction result includes the predicted probability that the training sample belongs to each classification category. If the training loss value of the classification model does not meet the preset training end condition, the model parameters of the classification model are adjusted, and the next batch of training sample sets are obtained, and the classification model is trained again. If the training loss value of the classification model meets the preset training end condition, the training ends, and a trained classification model is obtained.
[0074] Among them, the preset training end condition can be that the training loss value of the classification model is stable and no longer decreases, or it can be that when the classification model classifies the test sample set and the classification effect reaches the preset target, the training loss value of the classification model. The training end condition can be configured according to specific needs, and this application does not limit it.
[0075] In an example, for each training sample, the value of the loss function corresponding to the training sample can be calculated by the following formula (1):
[0076]
[0077] where L class represents the training loss value corresponding to the training sample, y represents the true class label of the training sample, represents the class prediction result of the training sample, and the class prediction result can be the predicted probability that the training sample corresponds to each classification category.
[0078] The training loss value of the classification model is determined according to the following formula (2):
[0079]
[0080] where L n represents the training loss value of the classification model; w i represents the weight of the training loss value corresponding to the i-th training sample; represents the training loss value corresponding to the i-th training sample, which can be calculated according to formula (1).
[0081] In one example, taking image classification as an example, the parameters of the Conv1 layer - Conv5 layer of the initial classification model adopt the parameters of the ResNet101 model pre-trained on the ImageNet dataset, and a fully connected layer is added. The fully connected layer is initialized with a Gaussian distribution with a variance of 0.01 and a mean of 0. This embodiment uses the gradient descent method based on Stochastic Gradient Descent (SGD) to solve the parameters w and bias parameter b of the classification model. In each iteration process, it backpropagates to the classification model, calculates the gradient, and updates the parameters of the classification model. The specific process is as follows: Set all the parameters of the initial classification model to the state that needs to be learned. When training the classification model, the classification model performs forward calculation on each input training sample to obtain the class prediction result of the training sample; Calculate the training loss value corresponding to the training sample according to the classification prediction result and the true class label, and determine the classification loss value of the classification model according to the training loss value of each training sample. If the training loss value of the classification model meets the training end condition, the training ends. If the training loss value of the classification model does not meet the training end condition, adjust the model parameters of the classification model, obtain the next batch of training samples, and repeat the training operation.
[0082] Among them, the ResNet-101 model includes a feature module and a classification module.
[0083] In one example, the structure of the feature module is shown in Table 1:
[0084]
[0085]
[0086] Table 1
[0087] Among them, in the first row of Table 1, Conv1 represents the layer name of the first layer of the classification model, 300×500 represents the size of the sample features output by the Conv1 layer, 7×7 represents the size of the convolution kernel, 64 represents the number of channels, and stride 2 represents a stride of 2; in the second row of Table 1, Conv2_x represents the layer name of the second layer of the classification model, 150×250 represents the size of the sample features output by the Conv2_x layer, 3×3 represents the size of the convolution kernel, max pool represents the max pooling operation, stride 2 represents a stride of 2, and ×3 blocks means that this layer includes 3 convolutional blocks, each convolutional block includes 3 convolutional layers, 1×1 represents the size of the convolution kernel of the first convolutional layer, 64 represents the number of channels of the first convolutional layer; 3×3 represents the size of the convolution kernel of the second convolutional layer, 64 represents the number of channels of the second convolutional layer; 1×1 represents the size of the convolution kernel of the third convolutional layer, 256 represents the number of channels of the third convolutional layer; in the third row of Table 1, Conv3_x represents the layer name of the third layer of the classification model, 76×126 represents the size of the sample features output by the Conv3_x layer, ×4 blocks means that this layer includes 4 convolutional blocks, each convolutional block includes 3 convolutional layers, 1×1 represents the size of the convolution kernel of the first convolutional layer, 128 represents the number of channels of the first convolutional layer; 3×3 represents the size of the convolution kernel of the second convolutional layer, 128 represents the number of channels of the second convolutional layer; 1×1 represents the size of the convolution kernel of the third convolutional layer, 512 represents the number of channels of the third convolutional layer; in the fourth row of Table 1, Conv4_x represents the layer name of the fourth layer of the classification model, 38×63 represents the size of the sample features output by the Conv4_x layer, ×23 blocks means that this layer includes 23 convolutional blocks, each convolutional block includes 3 convolutional layers, 1×1 represents the size of the convolution kernel of the first convolutional layer, 256 represents the number of channels of the first convolutional layer; 3×3 represents the size of the convolution kernel of the second convolutional layer, 256 represents the number of channels of the second convolutional layer; 1×1 represents the size of the convolution kernel of the third convolutional layer, 1024 represents the number of channels of the third convolutional layer; in the fifth row of Table 1, Conv5_x represents the layer name of the fifth layer of the classification model, 19×32 represents the size of the sample features output by the Conv5_x layer, ×3 blocks means that this layer includes 3 convolutional blocks, each convolutional block includes 3 convolutional layers, 1×1 represents the size of the convolution kernel of the first convolutional layer, 512 represents the number of channels of the first convolutional layer; 3×3 represents the size of the convolution kernel of the second convolutional layer, 512 represents the number of channels of the second convolutional layer; 1×1 represents the size of the convolution kernel of the third convolutional layer, 2048 represents the number of channels of the third convolutional layer.
[0088] Among them, the structure of each convolutional block of the Conv2_x layer is as Figure 2As shown in the figure. The training samples with 256 channels are convolved through the first convolutional layer. The convolutional kernel size of the first convolutional layer is 1×1, and the number of channels is 64. The sample features output by the first convolutional layer are non-linearly processed through the Rectified Linear Unit (ReLU) to obtain the processed sample features, and then are convolved through the second convolutional layer. The convolutional kernel size of the second convolutional layer is 3×3, and the number of channels is 64. The sample features output by the second convolutional layer are non-linearly processed through ReLU to obtain the processed sample features, and then are convolved through the third convolutional layer. The convolutional kernel size of the third convolutional layer is 1×1, and the number of channels is 256. The sample features output by the third convolutional layer are non-linearly processed through ReLU to obtain the processed sample features. After the current convolutional block is processed, the next convolutional block is processed.
[0089] The structure of the classification module is shown in Table 2:
[0090] Layer name Output size Layer Pool_cr 1×2048 Max pool Fc_cr 1×N full connection
[0091] Table 2
[0092] Among them, Pool_cr represents the layer name of the first layer of the classification module, 1×2048 represents the output size of the training samples of this layer, and Max pool represents that the function of this layer is to perform max pooling operation; Fc_cr represents the layer name of the second layer of the classification module, 1×N represents the output size of the training samples of this layer, where N represents the number of classification categories of the classification model, and full connection represents that the function of this layer is to perform full connection operation.
[0093] In the embodiment of the present application, no additional manual annotation is required for the noise samples. That is to say, it is not necessary to know in advance which of the training samples are noise samples, but all training samples are incorporated into the model training. Based on the sample types of each training sample, the weights of the training loss values corresponding to each training sample are determined, and then the training loss value of the classification model is determined, which can improve the processing ability of the classification model for noise samples, so as to improve the utilization efficiency of sample data, thereby realizing the self-perception of categories by the classification model and the iterative learning of self-supervised verification data, and avoiding the problem that the classification model falls into a local optimum due to a single deviation caused by determining weights or updating sample labels during offline learning of noise samples, which affects the classification accuracy of the trained classification model.
[0094] In addition, the category feature vectors of each classification category of the classification model can be continuously updated. See the following embodiments for details:
[0095] In a possible implementation, for each training operation, if the training loss value corresponding to the current training operation does not meet the training end condition, before performing the next training operation, the method further includes:
[0096] Updating the category feature vectors of each classification category in the following manner:
[0097] For each training sample, based on the true category label of the training sample, determine the classification category of the training sample;
[0098] For each classification category, perform clustering processing on the sample feature vectors of the training samples in the classification category to obtain N clustering categories corresponding to the classification category, where N≥1;
[0099] For each clustering category, based on the sample feature vectors of the training samples belonging to the clustering category, obtain the feature vector corresponding to the clustering category;
[0100] For each classification category, update the category feature vector of the classification category based on the feature vectors of the clustering categories corresponding to the current training operation, where the category feature vector of each classification category includes N feature vectors.
[0101] In practical applications, for each training operation, if the training loss value corresponding to the current training operation does not meet the training end condition, before performing the next training operation, the category feature vectors of each classification category can be updated using the training sample set of the current training. Specifically, according to the true category labels of the training samples, the training samples are divided into different classification categories, the sample feature vectors of the training samples in each classification category are clustered to obtain at least one clustering category corresponding to each classification category, and based on the sample feature vectors of the training samples belonging to each clustering category, the feature vector corresponding to the clustering category is obtained. Optionally, determine the category center of each clustering category, and use the sample feature vector of the training sample closest to the category center as the feature vector corresponding to the clustering category.
[0102] Among them, the distance between two vectors can be calculated by any distance formula, including but not limited to: Euclidean distance, Chebyshev Distance, Manhattan Distance, Mahalanobis Distance.
[0103] When updating the category feature vector of each classification category, the category feature vector of the classification category can be updated according to the feature vectors of each clustering category corresponding to the classification category. Optionally, for each classification category, the category feature vector of the classification category can be determined according to the feature vectors of each clustering category corresponding to the classification category, so as to obtain N feature vectors corresponding to the classification category.
[0104] Optionally, each classification category can correspond to multiple category feature vectors. Taking image classification as an example, since each classification category may have scene images of multiple styles, for example, the park category may include children's amusement parks, lakeside parks, park greenways, etc. If a classification category only corresponds to one category feature vector, it is not sufficient to represent these styles. In order to better represent each classification category, multiple feature vectors of clustering categories can be obtained through clustering. The category feature vector corresponding to the classification category includes the feature vectors of multiple clustering categories corresponding to the classification category.
[0105] In this embodiment, by continuously updating the category feature vectors of each classification category, the training of the classification model can be continuously optimized, and the training effect of the classification model can be improved.
[0106] Among them, the specific implementation method for updating the category feature vector of the classification category is shown in the following embodiments:
[0107] In a possible implementation manner, for each classification category, based on the feature vectors of each clustering category corresponding to the current training operation, updating the category feature vector of the classification category includes:
[0108] For each clustering category, determine the similarity between the category center of the clustering category corresponding to the current training operation and the category centers of the clustering categories before the current training operation;
[0109] For each clustering category, based on the category center of the clustering category corresponding to the current training operation and the category center of the clustering category before the current training operation corresponding to the highest similarity among the similarities, determine the new category center of the clustering category;
[0110] For each clustering category, based on the new category center, determine the new feature vector of the clustering category;
[0111] Among them, the updated category feature vector of the classification category includes the new feature vector.
[0112] In practical applications, for each classification category, when updating the category feature vector of the classification category based on the feature vectors of each clustering category corresponding to the current training operation, the category center of the clustering category corresponding to the current training operation can be updated first to obtain the new category center of the clustering category corresponding to the current training operation. Specifically, calculate the similarity between the category center of the clustering category corresponding to the current training operation and the category centers of each clustering category before the current training operation. Optionally, the vector corresponding to the category center can be the average of the sample feature vectors of each training sample in the clustering category. Among them, the similarity between vectors can be calculated by any similarity calculation method. Optionally, the similarity between vectors can be calculated by calculating the cosine similarity.
[0113] For each clustering category, based on the category center of the clustering category corresponding to the current training operation and the category center of the clustering category before the current training operation corresponding to the highest similarity among the similarities corresponding to the clustering category, determine the new category center corresponding to the clustering category. For each clustering category, a new feature vector of the clustering category can be determined based on the new category center. Optionally, the sample feature vector of the training sample closest to the new category center can be used as the new feature vector of the clustering category. The category feature vector of each classification category includes the feature vectors of each clustering category corresponding to the classification category. Therefore, the category feature vector of the classification category is updated as the feature vector of the clustering category is updated, and the updated category feature vector of the classification category includes the new feature vectors of the clustering categories corresponding to the classification category.
[0114] Optionally, for each clustering category, a similarity threshold between the category center of the clustering category corresponding to the current training operation and the category center before the current training operation can be pre-configured, and based on the category center of the clustering category before the current training operation whose similarity exceeds the similarity threshold and the category center of the clustering category corresponding to the current training operation, determine the new category center of the clustering category.
[0115] In an example, the new category center corresponding to clustering category i can be determined by the following formula (3):
[0116] C i-new =a1C j +a2C i (3)
[0117] Where, C i-new represents the new category center corresponding to clustering category i; C i represents the category center of clustering category i corresponding to the current training operation; C j represents the one related to C iThe class center before the current training operation with the highest similarity; a1 and a2 are preset parameters that can be configured according to specific needs.
[0118] Among them, for each classification category, the category feature vector of this classification category can be used to determine the recommended category label corresponding to the training sample of this classification category. See the following embodiments for details:
[0119] In a possible implementation manner, based on the similarity between the sample feature vector of the training sample and the category feature vectors of each category, determining the recommended category label corresponding to the training sample includes:
[0120] For each training sample, determine the similarity between the sample feature vector of this training sample and the category feature vectors of each category;
[0121] Obtain the similarity threshold corresponding to each classification category;
[0122] For each training sample, use the category label of the classification category corresponding to the similarity that is greater than or equal to the similarity threshold among the similarities between the sample feature vector of this training sample and the category feature vectors of each category as the recommended category label corresponding to this training sample.
[0123] In practical applications, for each training sample, determine the similarity between the sample feature vector of this training sample and the category feature vectors of each category. Among them, the similarity between feature vectors can be calculated by any similarity calculation method. Optionally, the similarity between feature vectors can be calculated by calculating the cosine similarity. After obtaining the similarity between the sample feature vector of this training sample and the category feature vectors of each category, obtain the similarity threshold corresponding to each classification category. Among them, the similarity threshold corresponding to each classification category can be pre-configured or determined according to the category prediction result of the training sample of each classification category. For each training sample, calculate the similarity between the sample feature vector of this training sample and the category feature vectors of each category. Among them, the classification category corresponding to the similarity that is greater than or equal to the similarity threshold is the relevant classification category of this training sample, and use the category label of the relevant classification category of this training sample as the recommended category label corresponding to this training sample. The recommended category label is used to identify the recommended classification category of this training sample.
[0124] Among them, the execution order of the two steps of determining the similarity between the sample feature vector of this training sample and the category feature vectors of each category and obtaining the similarity threshold corresponding to each classification category can also be to first obtain the similarity threshold corresponding to each classification category, and then determine the similarity between the sample feature vector of this training sample and the category feature vectors of each category.
[0125] In this embodiment, determining the category recommendation label of a training sample based on the similarity between the sample feature vector and the category feature vector of the training sample can make the category recommendation label of the training sample more accurate.
[0126] Among them, the similarity threshold corresponding to each classification category can be updated in the following manner:
[0127] In a possible implementation, for each training operation, if the training loss value of the classification model corresponding to the current training operation does not meet the training end condition, before performing the next training operation, the method further includes:
[0128] Updating the similarity threshold corresponding to each classification category in the following manner:
[0129] Based on the true category labels of the training samples, determine the number of training samples in the training sample set that belong to each classification category;
[0130] For each classification category, based on the number of training samples belonging to the classification category and the prediction probabilities corresponding to the classification category in the category prediction results of the training samples in the training sample set, determine the new similarity threshold corresponding to the classification category.
[0131] In practical applications, if the training loss value corresponding to the current training operation does not meet the training end condition, then update the similarity threshold corresponding to each classification category. Specifically, for each classification category, according to the true category labels of the training samples in the classification category, the number of training samples in each classification category can be obtained. According to the category prediction results of the training samples that can be obtained from the current training operation, for each training sample, the category prediction result can be the prediction probability of the training sample corresponding to each classification category. When updating the similarity threshold corresponding to each classification category, for each classification category, according to the prediction probabilities of the training samples corresponding to the classification category and the number of training samples in the classification category, determine the new similarity threshold corresponding to the classification category. For the initial value of the similarity threshold corresponding to each classification category, it can be configured according to specific needs.
[0132] Optionally, when determining the new similarity threshold corresponding to a classification category, for each classification category, the number of samples of all training samples in the classification category and the prediction probabilities of all training samples in the classification category corresponding to the classification category can be used to determine the new similarity threshold corresponding to the classification category; or, the non-noise samples in the classification category can also be determined, and the number of samples of the non-noise samples in the classification category and the prediction probabilities of the non-noise samples corresponding to the classification category can be used to determine the new similarity threshold corresponding to the classification category.
[0133] In one example, the similarity threshold corresponding to each classification category can be updated by the following formula (4):
[0134]
[0135] where thr i represents the updated similarity threshold corresponding to classification category i; C i represents the sample set of the training samples of classification category i; |C i | represents the number of training samples of the classification category with class i; P ji represents the predicted probability that sample j corresponds to classification category i.
[0136] In a possible implementation, for any training sample, based on the true class label and the recommended class label of the training sample, determine the sample type of the training sample, including:
[0137] If the recommended class label does not include the true class label, then the training sample is a noise sample.
[0138] In practical applications, for any training sample, the classification category corresponding to the similarity that is greater than or equal to the similarity threshold among the similarities between the sample feature vector of the training sample and the feature vectors of each category may be one or multiple. Each classification category corresponds to a class label, so the recommended class label corresponding to each training sample may be one or multiple. For each training sample, if the recommended class label of the training sample does not include the true class label of the training sample, then the training sample is a noise sample.
[0139] In a possible implementation, for each training sample, based on the sample type of the training sample, determine the weight of the training loss value corresponding to the training sample, including:
[0140] If the training sample is a non-noise sample, then determine the proportion of the number of true class labels of the training sample in the recommended class labels corresponding to the training sample, and based on the proportion, determine the weight of the training loss value corresponding to the training sample.
[0141] In practical applications, if the training sample is a noise sample, then the weight of the training loss value corresponding to the training sample can be configured to be less than the weight of the training loss value corresponding to the non-noise sample. For example, it can be zero, which is equivalent to filtering out the noise sample to avoid the influence of the noise sample on data classification. If the training sample is a non-noise sample, then determine the weight of the training loss value corresponding to the training sample according to the proportion of the number of true class labels of the training sample in the recommended class labels corresponding to the training sample.
[0142] In this embodiment, according to the sample type of the training samples, the influence degree of each training sample on model training is determined. For the training loss value corresponding to the noise samples, a relatively small weight can be configured to suppress the influence of the noise samples. For the non-noise samples, according to the proportion of the number of true class labels of the training samples in the recommended class labels, the weight of the training loss value of the training sample is determined. That is to say, according to the proportion of the number of true class labels in the recommended class labels, the influence degree of the non-noise samples is determined, realizing the self-supervised suppression of the noise samples by using the knowledge learned by the classification model, avoiding the problem of poor recognition performance caused by overfitting of the classification model to the noise samples, and improving the classification accuracy of the trained classification model.
[0143] Next, a specific embodiment is used to elaborate in detail the data processing process of the training method of the classification model in the technical solution of the present application. This embodiment is only one embodiment of the technical solution of the present application and does not represent all implementation manners of the technical solution of the present application.
[0144] In this embodiment, the classification model corresponds to 20 classification categories. The training sample set includes multiple batches (also called batches) of training samples. Each time the model is trained, a batch of training samples is used for training. The number of training samples in each batch is 2048, and each training sample has a true class label.
[0145] Each time a training operation is performed, the training samples are input into the classification model. The sample feature vectors of each training sample are extracted through the feature module of the classification model. The sample feature vectors of the training samples of each classification category are clustered to obtain 5 clustering categories, and the category centers of each clustering category are determined. If this training operation is the first training operation, the sample feature vector closest to the category center is used as the feature vector corresponding to the clustering category. If this training operation is not the first training operation, for each clustering category, according to the category center corresponding to this clustering category in this training operation and the category centers of the clustering categories in each previous training operation with the highest similarity to the category center corresponding to this clustering category in this training operation, the new category center of this clustering category is determined, and the new feature vector of this clustering category is determined according to the new category center.
[0146] For each classification category, the category feature vector of the current training operation includes the feature vectors of each clustering category corresponding to the classification category. Then, the category feature vector of each classification category includes the feature vectors of 5 clustering categories. Thus, the category feature vectors of 20 classification categories include a total of 20×5 = 100 clustering category feature vectors. There are 2048 training samples in this batch, resulting in a 100×2048 matrix. For each classification category, calculate the similarity between the sample feature vector of the training samples corresponding to the classification category and the 100 feature vectors. For each training sample, use the category label of the classification category with a similarity greater than the similarity threshold as the recommended category label for the training sample.
[0147] Based on the above similarity calculation, taking 3 training samples as an example, the recommended category labels for training sample 1 are 1, 1, 2, while the true category label of training sample 1 is 4; the recommended category labels for training sample 2 are 1, 5, 5, 6, 7, while the true category label of training sample 2 is 5; training sample 3 has no recommended category label, and the true category label of training sample 3 is 6. Among them, since each classification category includes the feature vectors of 5 clustering categories, the recommended category labels of the training samples may have 5 identical category labels.
[0148] For each training sample, when the recommended category label does not contain the true category label, it means the training sample is a noise sample, and set the weight of the training loss value corresponding to the training sample to 0, such as training sample 1 and training sample 3 above; when the recommended category label contains the true category label, if 1 / 2 or more of the recommended category labels are the same as the true category label, then set the weight of the training loss value corresponding to the training sample to 1; when less than 1 / 2 of the recommended category labels are the same as the true category label, then set the weight of the training loss value corresponding to the training sample to m / n, where m is the number of category labels in the recommended category label that are the same as the true category label, and n is the total number of recommended category labels of the training sample. For example, for training sample 2 above, there are 5 recommended category labels: 1, 5, 5, 6, 7, and 2 of them are the same as the true category label, so the weight of the training loss value corresponding to training sample 2 is set to 2 / 5.
[0149] After determining the weights of the training loss values of each training sample, based on the category prediction results and true category labels of each training sample, determine the training loss values of each training sample. According to the weights of the training loss values of each training sample and the training loss values of each training sample, determine the training loss value of the classification model. If the training loss value of the classification model does not meet the training end condition, adjust the model parameters of the classification model and use another batch of training samples to perform the training operation of the classification model again until the training loss value of the classification model meets the training end condition to obtain the trained classification model.
[0150] The data processing process of the training method of the classification model in the technical solution of the present application will be described in detail below through a specific embodiment.
[0151] As Figure 3 shown, obtain a training sample set, where each training sample in the training sample set includes a true class label (such as the "data" shown in the figure); input each training sample into a classification model (such as the "convolutional neural network model" shown in the figure), and the feature module of the neural network model extracts the sample feature vector of each training sample. Cluster the sample feature vectors of the training samples corresponding to each classification category of the classification model to obtain multiple clustering categories corresponding to each classification category, determine the feature vector corresponding to each clustering category, and after each training operation, update the feature vectors of each clustering category to obtain new feature vectors of each clustering category. Use the new feature vectors of each clustering category to update the category feature vector of the classification category, that is, update the memory unit of this classification category. Match the sample feature vector of each training sample with the category feature vectors (such as the "category memory unit" shown in the figure) of each classification category to obtain the category recommended label of each training sample. According to the category recommended label and the true class label of the training sample, determine the sample type of the training sample, that is, whether it is a noise sample (such as the "noise determination" shown in the figure). According to the sample type of the training sample, determine the weight of the training loss value of the training sample. The classification module of the convolutional neural network model obtains the category prediction result of the training sample according to the sample feature vector of the training sample. According to the true class label and the category prediction result of the training sample, the training loss value of the training sample can be obtained. According to the training loss values of each training sample and the weights of the training loss values, the training loss value of the classification model is obtained. If the training loss value of the classification model does not meet the training end condition, adjust the model parameters of the classification model and obtain a new training sample set to continue training until the training loss value of the classification model meets the preset training end condition to obtain a trained classification model.
[0152] The update process of the memory unit in the technical solution of the present application will be described in detail below through a specific embodiment.
[0153] As Figure 4 shown, execute step S401 to obtain the sample feature vectors of each training sample.
[0154] Specifically, extract the sample feature vectors of each training sample through the feature module of the classification model.
[0155] Execute step S402, clustering of each classification category.
[0156] Specifically, cluster the sample feature vectors of the training samples corresponding to each classification category to obtain multiple clustering categories corresponding to each classification category.
[0157] Execute step S403 to determine the class center of the clustering class.
[0158] Specifically, calculate the mean of the sample feature vectors of the training samples of each clustering class as the class center of the clustering class.
[0159] Execute step S404 to obtain the historical feature vectors of the clustering classes in the memory unit.
[0160] Specifically, the class center of the clustering class corresponding to each classification class (memory unit) includes the class center of the clustering class corresponding to this classification class. Obtain the class centers of the clustering classes corresponding to the previous training operations before this training operation, that is, the historical class centers.
[0161] Execute step S405 to update the class center of the clustering class.
[0162] Specifically, for each clustering class, determine the new class center corresponding to this clustering class according to the historical class center corresponding to this clustering class and the class center of this training operation. Use the updated new class center to determine the new feature vector to update the class feature vector of the classification class corresponding to this clustering class, that is, update the memory unit of this classification class, and record the updated memory unit for the next iteration.
[0163] The application process of the classification model in the technical solution of the present application will be introduced below through a specific embodiment.
[0164] As Figure 5 shown, in this embodiment, the classification model is an image recognition model. The user terminal (such as "Front End A" shown in the figure) receives data (such as "the picture input by the user" shown in the figure), uploads the data to the server (such as "Back End" shown in the figure), and the server uses the trained image recognition model obtained by training through the classification model training method in the present technical solution to perform recognition processing on the picture, and outputs the recognition result to the user terminal (such as "Front End B" shown in the figure). Front End A and Front End B can be different display interfaces.
[0165] In addition, the image recognition model trained by the classification model training method in the technical solution of the present application not only supports user calls, but also supports other service calls. For example, when the player is playing a TV series and needs to display what scene the current plot is, the player inputs the front and back image frames of the video corresponding to the current playing moment into the image recognition model, obtains the recognition result through the image recognition model, outputs the scene information of the current plot, and returns it to the player for display.
[0166] The present application provides a data classification method, which uses a trained classification model for data classification. The training loss value of the classification model is determined based on the weights of the training loss values corresponding to the respective training samples in the training sample set. The weights of the training loss values corresponding to the respective training samples are determined based on the sample types of the respective training samples. Determining the training loss value of the classification model according to the sample types of the respective training samples can improve the processing ability of the classification model for noise samples, enhance the learning effect of the model, and thus improve the classification accuracy of the trained classification model.
[0167] Same as the principle of the method shown in Figure 1 In the embodiments of the present application, a data classification device 60 is also provided. As shown in Figure 6 shown, the data classification device 60 includes:
[0168] An acquisition module 61, configured to acquire data to be classified; the data to be classified includes image data or text data;
[0169] A classification module 62, configured to input the data to be classified into the trained classification model to obtain a classification result corresponding to the data to be classified;
[0170] Among them, the trained classification model is obtained by training the classification model with a training sample set. The training loss value of the classification model is determined based on the weights of the training loss values corresponding to the respective training samples in the training sample set. The weights of the training loss values corresponding to the respective training samples are determined based on the sample types of the respective training samples, and the sample types are noise samples or non-noise samples.
[0171] In a possible implementation manner, the classification module 62 is further configured to train the classification model in the following manner:
[0172] Acquire a training sample set, where the training sample set includes training samples in each batch, and each batch of training samples includes respective training samples with true class labels;
[0173] For each batch of training samples, by repeatedly performing the following training operations until the training loss value of the classification model meets a preset training end condition, a trained classification model is obtained:
[0174] For each training sample in the current batch, input the training sample into the classification model, extract the sample feature vector of the training sample, and based on the sample feature vector, obtain the class prediction result of the training sample;
[0175] Acquire the class feature vectors of the respective classification classes corresponding to the classification model;
[0176] For each training sample, based on the similarity between the sample feature vector of the training sample and the feature vectors of each category, determine the recommended category label corresponding to the training sample, and based on the true category label and the recommended category label of the training sample, determine the sample type of the training sample;
[0177] For each training sample, based on the sample type of the training sample, determine the weight of the training loss value corresponding to the training sample;
[0178] Based on the weights of the training loss values corresponding to each training sample, the category prediction results of each training sample, and the true category labels of each training sample, determine the training loss value of the classification model. Among them, if the training loss value does not meet the training end condition, adjust the model parameters of the classification model, and obtain the next batch of training samples in the training sample set, and perform the next training operation.
[0179] In a possible implementation, the classification module 62 includes a first update unit for:
[0180] For each training operation, if the training loss value corresponding to the current training operation does not meet the training end condition, before performing the next training operation, update the feature vectors of each classification category in the following way:
[0181] For each training sample, based on the true category label of the training sample, determine the classification category of the training sample;
[0182] For each classification category, perform clustering processing on the sample feature vectors of the training samples of the classification category to obtain N clustering categories corresponding to the classification category, where N≥1;
[0183] For each clustering category, based on the sample feature vectors of the training samples belonging to the clustering category, obtain the feature vector corresponding to the clustering category;
[0184] For each classification category, based on the feature vectors of each clustering category corresponding to the current training operation, update the category feature vector of the classification category, where the category feature vector of each classification category includes N feature vectors.
[0185] In a possible implementation, when the classification module 62 updates the category feature vector of each classification category based on the feature vectors of each clustering category corresponding to the current training operation for each classification category, it is used for:
[0186] For each clustering category, determine the similarity between the category center of the clustering category corresponding to the current training operation and the category centers of the previous clustering categories of the current training operation;
[0187] For each clustering category, based on the category center of this clustering category corresponding to the current training operation and the category center of the clustering category before the current training operation corresponding to the highest similarity among all similarities, determine the new category center of this clustering category;
[0188] For each clustering category, based on the new category center, determine the new feature vector of this clustering category;
[0189] Among them, the category feature vector of the updated classification category includes the new feature vector.
[0190] In a possible implementation manner, when the classification module 62 determines the recommended category label corresponding to the training sample based on the similarity between the sample feature vector of the training sample and the category feature vectors of each category, it is used for:
[0191] For each training sample, determine the similarity between the sample feature vector of the training sample and the category feature vectors of each category;
[0192] Obtain the similarity threshold corresponding to each classification category;
[0193] For each training sample, use the category label of the classification category corresponding to the similarity that is greater than or equal to the similarity threshold among the similarities between the sample feature vector of the training sample and the category feature vectors of each category as the recommended category label corresponding to the training sample.
[0194] In a possible implementation manner, the classification module 62 further includes a second update unit, which is used for:
[0195] For each training operation, if the training loss value of the classification model corresponding to the current training operation does not meet the training end condition, before performing the next training operation, update the similarity threshold corresponding to each classification category in the following manner:
[0196] Based on the true category labels of all training samples, determine the number of training samples belonging to each classification category in the training sample set;
[0197] For each classification category, based on the number of training samples belonging to the classification category and the prediction probability corresponding to the classification category in the category prediction results of all training samples in the training sample set, determine the new similarity threshold corresponding to the classification category.
[0198] In a possible implementation manner, for any training sample, when the classification module 62 determines the sample type of the training sample based on the true category label and the recommended category label of the training sample, it is used for:
[0199] If the recommended category label does not include the true category label, then the training sample is a noise sample.
[0200] In one possible implementation, for each training sample, when determining the weight of the training loss value corresponding to the training sample based on the sample type of the training sample, the classification module 62 is configured to:
[0201] If the training sample is a non-noise sample, the quantitative ratio of the true category label of the training sample in the recommended category label corresponding to the training sample is determined, and based on the quantitative ratio, the weight of the training loss value corresponding to the training sample is determined.
[0202] The data classification device of the embodiment of the present application can execute the data classification provided by the embodiment of the present application. Figure 1 The corresponding data classification method has a similar implementation principle. The actions performed by each module in the data classification device in the embodiment of the present application correspond to the steps in the data classification method in the embodiment of the present application. For the detailed functional description of each module of the data classification device, please refer to the description in the corresponding data classification method shown in the previous text, which will not be repeated here.
[0203] The data classification device provided in the embodiment of the present application uses a trained classification model to perform data classification. The training loss value of the classification model is determined based on the weight of the training loss value corresponding to each training sample in the training sample set. The weight of the training loss value corresponding to each training sample is determined based on the sample type of each training sample. Determining the training loss value of the classification model based on the sample type of each training sample can improve the classification model's ability to process noise samples, improve the model's learning effect, and thus improve the classification accuracy of the trained classification model.
[0204] Among them, the data classification device can be a computer program (including program code) running in a computer device, for example, the data classification device is an application software; the device can be used to execute the corresponding steps in the method provided in the embodiment of the present application.
[0205] In some embodiments, the data classification device provided by the embodiments of the present application can be implemented in a combination of software and hardware. As an example, the data classification device provided by the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the data classification method provided by the embodiments of the present application. For example, a processor in the form of a hardware decoding processor can employ one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0206] In other embodiments, the data classification device provided by the embodiments of the present application can be implemented in software. Figure 6 Shown is the data classification device stored in the memory, which can be software in the form of a program and plug-ins, etc., and includes a series of modules, including an acquisition module 61 and a module 62, for implementing the data classification method provided by the embodiments of the present application. <l
[0207] The above embodiments introduce the data classification device from the perspective of virtual modules. The following introduces an electronic device from the perspective of physical modules, which is specifically as follows:
[0208] The embodiments of the present application provide an electronic device, as Figure 7 shown. Figure 7 As shown, the electronic device 7000 includes: a processor 7001 and a memory 7003. Among them, the processor 7001 and the memory 7003 are connected, such as through a bus 7002. Optionally, the electronic device 7000 may further include a transceiver 7004. It should be noted that in actual applications, the transceiver 7004 is not limited to one, and the structure of the electronic device 7000 does not constitute a limitation on the embodiments of the present application.
[0209] The processor 7001 can be a CPU, a general-purpose processor, a GPU, a DSP, an ASIC, an FPGA, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in connection with the disclosure of the present application. The processor 7001 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0210] The bus 7002 may include a path for transmitting information between the above components. The bus 7002 can be a PCI bus, an EISA bus, or the like. The bus 7002 can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 7 it is only represented by a thick line in Figure 7 , but it does not mean that there is only one bus or one type of bus.
[0211] The memory 7003 can be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or it can also be an EEPROM, a CD-ROM, or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but not limited thereto.
[0212] The memory 7003 is used to store the application program code for executing the solution of this application and is controlled by the processor 7001 to execute. The processor 7001 is used to execute the application program code stored in the memory 7003 to implement the content shown in any of the foregoing method embodiments.
[0213] The embodiments of this application provide an electronic device. The electronic device in the embodiments of this application includes: one or more processors; a memory; one or more computer programs, where one or more computer programs are stored in the memory and are configured to be executed by one or more processors. When the one or more programs are executed by the processor, the data to be classified is obtained; the data to be classified includes image data or text data; the data to be classified is input into a trained classification model to obtain a classification result corresponding to the data to be classified; where the trained classification model is obtained by training the classification model with a training sample set, the training loss value of the classification model is determined based on the weights of the training loss values corresponding to the respective training samples in the training sample set, and the weights of the training loss values corresponding to the respective training samples are determined based on the sample types of the respective training samples, and the sample types are noise samples or non-noise samples.
[0214] The embodiments of this application provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program runs on a processor, the processor can execute the corresponding content in the foregoing method embodiments.
[0215] According to one aspect of the present application, there is provided a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the various alternative implementations of the above data classification method.
[0216] It should be understood that although the steps in the flowchart of the accompanying drawings are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this document, there is no strict order restriction for the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed alternately or alternately with at least some of the sub-steps or stages of other steps.
[0217] The above are only some embodiments of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. A data classification method, characterized in that, The method includes: Obtaining data to be classified; the data to be classified includes image data or text data; Inputting the data to be classified into a trained classification model obtained by the following method to obtain a classification result corresponding to the data to be classified: Obtaining a training sample set, where the training sample set includes training samples in each batch, and each batch of training samples includes each training sample with a true class label; For each batch of training samples, through repeatedly performing the following training operations until the training loss value of the classification model meets a preset training end condition, a trained classification model is obtained: For each training sample in the current batch, inputting the training sample into the classification model, extracting a sample feature vector of the training sample, and based on the sample feature vector, obtaining a class prediction result of the training sample; Obtaining class feature vectors of each classification class corresponding to the classification model; For each training sample, based on the similarity between the sample feature vector of the training sample and the class feature vectors of each class, determining class labels of each classification class whose corresponding similarity is greater than or equal to a similarity threshold as recommended class labels corresponding to the training sample, and according to whether the recommended class labels of the training sample include the true class label of the training sample, determining the sample type of the training sample, where the sample type is a noise sample or a non-noise sample; For each training sample, based on the sample type of the training sample, determining a weight of the training loss value corresponding to the training sample; wherein, the weight of the noise sample is less than the weight corresponding to the non-noise sample; Based on the weights of the training loss values corresponding to each training sample, and the difference between the class prediction result and the true class label of each training sample, determining the training loss value of the classification model, adjusting the model parameters of the classification model based on the training loss value, and obtaining the next batch of training samples in the training sample set to perform the next training operation.
2. The method according to claim 1, wherein For each training operation, if the training loss value corresponding to the current training operation does not meet the training end condition, before performing the next training operation, the method further includes: Updating the class feature vectors of each classification class by the following method: For each training sample, based on the true class label of the training sample, determining the classification class of the training sample; For each classification class, performing clustering processing on the sample feature vectors of the training samples of the classification class to obtain N clustering classes corresponding to the classification class, where N≥1; For each clustering class, based on the sample feature vectors of the training samples belonging to the clustering class, obtaining a feature vector corresponding to the clustering class; For each classification class, based on the feature vectors of each clustering class corresponding to the current training operation, updating the class feature vector of the classification class, where the class feature vector of each classification class includes N feature vectors.
3. The method according to claim 2, wherein The step of, for each classification class, updating the class feature vector of the classification class based on the feature vectors of each clustering class corresponding to the current training operation includes: For each clustering category, determine the similarity between the category center of the clustering category corresponding to the current training operation and the category centers of each clustering category before the current training operation; For each clustering category, based on the category center of the clustering category corresponding to the current training operation and the category center of the clustering category before the current training operation corresponding to the highest similarity among the similarities, determine the new category center of the clustering category; For each clustering category, based on the new category center, determine the new feature vector of the clustering category; Among them, the category feature vector of the updated classification category includes the new feature vector.
4. The method according to claim 1, wherein For each training operation, if the training loss value of the classification model corresponding to the current training operation does not meet the training end condition, before performing the next training operation, the method further includes: Update the similarity threshold corresponding to each classification category in the following manner: Based on the true category labels of each training sample, determine the number of training samples belonging to each classification category in the training sample set; For each classification category, based on the number of training samples belonging to the classification category and the prediction probability corresponding to the classification category in the category prediction results of each training sample in the training sample set, determine the new similarity threshold corresponding to the classification category.
5. The method according to claim 4, wherein The determining the new similarity threshold corresponding to the classification category based on the number of training samples belonging to the classification category and the prediction probability corresponding to the classification category in the category prediction results of each training sample in the training sample set includes: Obtain the new similarity threshold corresponding to classification category i through the following formula: Among them, represents the updated similarity threshold corresponding to classification category i; represents the sample set of the training samples of classification category i; represents the number of training samples of classification category i; represents the predicted probability that sample j belongs to classification category i.
6. The method according to claim 1, wherein For each training sample, the determining the weight of the training loss value corresponding to the training sample based on the sample type of the training sample includes: If the training sample is a non-noise sample, determine the proportion of the number of the true category label of the training sample in the recommended category label corresponding to the training sample in the recommended category label corresponding to the training sample, and based on the proportion, determine the weight of the training loss value corresponding to the training sample.
7. A data classification device, characterized in that, The device includes: An acquisition module, configured to acquire data to be classified; the data to be classified includes image data or text data; A classification module, configured to input the data to be classified into a trained classification model to obtain a classification result corresponding to the data to be classified; The classification module is further configured to train the classification model in the following manner: Obtain a training sample set, the training sample set includes training samples in each batch, and each batch of training samples includes each training sample with a true category label; For each batch of training samples, by repeatedly performing the following training operations until the training loss value of the classification model meets a preset training end condition, obtain a trained classification model: For each training sample in the current batch, input the training sample into the classification model, extract the sample feature vector of the training sample, and based on the sample feature vector, obtain the category prediction result of the training sample; Obtain the category feature vectors of each classification category corresponding to the classification model; For each training sample, based on the similarity between the sample feature vector of the training sample and the feature vectors of each category, determine the category labels of each classification category whose corresponding similarity is greater than or equal to the similarity threshold as the recommended category labels corresponding to the training sample. According to whether each recommended category label of the training sample includes the true category label of the training sample, determine the sample type of the training sample, where the sample type is a noise sample or a non-noise sample; For each training sample, based on the sample type of the training sample, determine the weight of the training loss value corresponding to the training sample; among them, the weight of the noise sample is less than the weight corresponding to the non-noise sample; Based on the weights of the training loss values corresponding to each training sample, and the difference between the category prediction results and the true category labels of each training sample, determine the training loss value of the classification model. Based on the training loss value, adjust the model parameters of the classification model, and obtain the next batch of training samples in the training sample set, and perform the next training operation.
8. The device according to claim 7, characterized in that, The classification module includes a first update unit for: For each training sample, based on the true category label of the training sample, determine the classification category of the training sample; For each classification category, perform clustering processing on the sample feature vectors of the training samples belonging to the classification category to obtain N clustering categories corresponding to the classification category, where N≥1; For each clustering category, based on the sample feature vectors of the training samples belonging to the clustering category, obtain the feature vector corresponding to the clustering category; For each classification category, based on the feature vectors of each clustering category corresponding to the current training operation, update the category feature vector of the classification category, where the category feature vector of each classification category includes N feature vectors.
9. The device according to claim 8, characterized in that When the first update unit updates the category feature vector of the classification category based on the feature vectors of each clustering category corresponding to the current training operation, it specifically is used for: For each clustering category, determine the similarity between the category center of the clustering category corresponding to the current training operation and the category centers of each clustering category before the current training operation; For each clustering category, based on the category center of the clustering category corresponding to the current training operation and the category center of the clustering category before the current training operation corresponding to the highest similarity among the similarities, determine the new category center of the clustering category; For each clustering category, based on the new category center, determine the new feature vector of the clustering category; Among them, the updated category feature vector of the classification category includes the new feature vector.
10. The device according to claim 7, characterized in that, The classification module further includes a second update unit for: For each training operation, if the training loss value of the classification model corresponding to the current training operation does not meet the training end condition, before performing the next training operation, update the similarity threshold corresponding to each classification category in the following manner: Based on the true category labels of each training sample, determine the number of training samples belonging to each classification category in the training sample set; For each classification category, based on the number of training samples belonging to the classification category and the prediction probability corresponding to the classification category in the class prediction results of each training sample in the training sample set, determine a new similarity threshold corresponding to the classification category.
11. The device according to claim 10, characterized in that, When the second updating unit determines a new similarity threshold corresponding to the classification category based on the number of training samples belonging to the classification category and the prediction probability corresponding to the classification category in the class prediction results of each training sample in the training sample set, it is specifically configured to: Obtain a new similarity threshold corresponding to classification category i through the following formula: Among them, represents the updated similarity threshold corresponding to classification category i; represents the sample set of the training samples of classification category i; represents the number of training samples of classification category i; represents the prediction probability of sample j corresponding to classification category i.
12. The device according to claim 7, characterized in that, For each training sample, when the classification module determines the weight of the training loss value corresponding to the training sample based on the sample type of the training sample, it is configured to: If the training sample is a non-noise sample, determine the proportion of the number of the true class labels of the training sample in the recommended class labels corresponding to the training sample among the recommended class labels corresponding to the training sample, and based on the proportion, determine the weight of the training loss value corresponding to the training sample.
13. An electronic device, characterized in that, The electronic device includes: One or more processors; A memory; One or more computer programs, where the one or more computer programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more computer programs are configured to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Supervised learning method and device, label prediction method and device, electronic equipment and storage medium
CN110781934A
Training method and device of image classification model
CN111507419A