Image multi-classification model training method and device and electronic equipment
Through parallel training and multi-branch networks with different parameter magnitudes, the calculation complexity and performance degradation of image classification models in the existing technology are solved, and the rapid convergence and high accuracy of the model are achieved, with strong adaptability. Image multi-classification model training method.
Patent Information
- Application Number
- CN202411028303.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-07-30
AI Technical Summary
When existing deep learning models add new categories to image classification, they need to be retrained, resulting in increased computational complexity, time-consuming and labor-intensive, reduced model performance, high maintenance costs, and a great impact on the original category recognition ability.
The initial image multi-classification model is adopted, including N classification networks and N binary classification networks. The model is iteratively trained through parallel training, and parameters of the same order as the initial network parameters are selected for updates. The remaining parameters remain unchanged, which is reduced. Training complexity and model maintenance costs to achieve rapid addition of new categories and multi-dimensional basic network fusion.
The rapid convergence of the model is achieved, the training complexity and maintenance costs are reduced, the model is improved, the adaptability and scalability is improved, and the ability to process changing data sets is ensured, the rapid development of business needs is improved, and the accuracy and business scope is improved. ability to transform.
Smart Images

Figure CN119006901A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image classification, and in particular to a training method, device and electronic equipment for an image multi-classification model. Background Art
[0002] Currently, deep learning models are increasingly used in image classification. When new categories of images are added, it usually takes a lot of time and computing resources to retrain the model so that it can recognize the new categories.
[0003] Since the model needs to be retrained every time a new category is added, it not only increases the complexity of calculation, but also consumes time and effort, and the maintenance cost is getting higher and higher. Moreover, in the process of retraining the model, the model parameters will be adjusted, which will lead to a decrease in the model's recognition ability for the original category. Even with the linear increase of classification, the performance of the model will decrease exponentially. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a method, device and electronic device for training an image multi-classification model to solve the problems in the prior art.
[0005] To solve the above technical problems, the embodiments of the present invention are implemented as follows:
[0006] In a first aspect, an embodiment of the present invention provides a method for training an image multi-classification model, comprising:
[0007] Determine an initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network, the N-classification network is used to perform probability prediction of N categories on the input image, and output N classification results, the initial second network includes N binary classification networks, the binary classification networks are used to judge whether the input image belongs to the corresponding category, and output the binary classification results, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network;
[0008] Acquire a first training sample set, where the first training sample set includes images of the N categories and images of an N+1th newly added category;
[0009] Iteratively training the initial first network using the first training sample set until a convergence condition is reached to obtain a trained first network, wherein the trained first network is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on the input image and output N+1 classification results;
[0010] Adding a binary classification network to the initial second network to obtain a second network to be trained; using the first training sample set to iteratively train the second network to be trained, selecting parameters of the same magnitude as the parameters of the initial first network as training parameters to be updated during the training process, and setting the remaining parameters to be fixed parameters to remain unchanged until a convergence condition is reached, thereby obtaining a trained second network, wherein the trained second network includes N+1 binary classification networks;
[0011] The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model. In a second aspect, an embodiment of the present invention provides a training device for an image multi-classification model, comprising:
[0012] A determination module, used to determine an initial image multi-classification model, wherein the initial image multi-classification model includes an initial first network and an initial second network, wherein the initial first network is an N-classification network, wherein the N-classification network is used to perform probability prediction of N categories on an input image and output N classification results, wherein the initial second network includes N binary classification networks, wherein the binary classification networks are used to determine whether an input image belongs to a corresponding category and output a binary classification result, and wherein the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network;
[0013] An acquisition module, configured to acquire a first training sample set, wherein the first training sample set includes images of the N categories and images of an N+1th newly added category;
[0014] A first training module is used to iteratively train the initial first network using the first training sample set until a convergence condition is reached to obtain a trained first network, wherein the trained first network is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on an input image and output an N+1 classification result;
[0015] A second training module is used to add a binary classification network to the initial second network to obtain a second network to be trained; use the first training sample set to iteratively train the second network to be trained, select parameters of the same magnitude as the parameters of the initial first network as training parameters to be updated during the training process, and set the remaining parameters to be fixed parameters and remain unchanged until a convergence condition is reached, thereby obtaining a trained second network, wherein the trained second network includes N+1 binary classification networks;
[0016] The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
[0017] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the training method for the image multi-classification model provided in the above embodiment.
[0018] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the training method of the image multi-classification model provided in the above embodiment are implemented.
[0019] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the training method of the image multi-classification model provided in the above embodiment.
[0020] It can be seen from the technical solution provided by the above embodiments of the present invention that the embodiments of the present invention determine an initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network used to perform probability prediction of N categories of the input image and output N classification results, the initial second network includes N binary classification networks, which are used to judge whether the input image belongs to the corresponding category and output the binary classification results, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; obtain a first training sample set, including images of N categories and images of the N+1th newly added category; use the first training sample set to iteratively train the initial first network until the convergence condition is reached, and obtain a trained first network, and the trained first network is an N+1 classification network; add a binary classification network to the initial second network to obtain the first network to be trained. Second network; use the first training sample set to iteratively train the second network to be trained, select parameters of the same magnitude as the parameters of the initial first network as the training parameters to be updated during the training process, and set the remaining parameters to remain unchanged until the convergence condition is reached, and obtain the trained second network, which includes N+1 binary classification networks; wherein, the training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute the trained image multi-classification model. Since the fixed parameters in the second network do not need to be trained during the parallel training process, the complexity of training and the maintenance cost of the model are reduced, the model converges quickly, and new categories are added quickly. It can handle changing or expanding data sets, has flexible applications, strong adaptability and scalability, high real-time performance, and can meet the rapid development of business needs. Moreover, the model uses a multi-branch network with different parameter magnitudes to convert N classification tasks into N binary classification tasks for training, realizing a training method of multi-dimensional basic network fusion, with strong feature diversity, output of results in different dimensions, high accuracy, and strong business generalization ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0022] Figure 1 A flowchart of a method for training an image multi-classification model provided by an embodiment of the present invention;
[0023] Figure 2 A schematic diagram of a flow chart of another method for training an image multi-classification model provided by an embodiment of the present invention;
[0024] Figure 3 A schematic diagram of the architecture of an image multi-classification model provided by an embodiment of the present invention;
[0025] Figure 4 A schematic diagram of the image multi-classification model training process provided by an embodiment of the present invention;
[0026] Figure 5 A schematic diagram of the structure of a training device for an image multi-classification model provided by an embodiment of the present invention;
[0027] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The embodiments of the present invention provide a method, a device and an electronic device for training an image multi-classification model.
[0029] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] The training method and device of the image multi-classification model provided by the embodiment of the present invention can be applied to a server, which can be an independent server or a server cluster composed of multiple servers, without specific limitation. The application scenarios of the above method and device include scenarios in which new categories are added to the image multi-classification model for training. Among them, the image multi-classification model has been pre-trained and can recognize N categories, and adding new categories means retraining the image multi-classification model to learn the N+1th category. Through the above method and device, the complexity of training and the maintenance cost of the model can be reduced, and the rapid addition of new categories and the training method of multi-dimensional basic network fusion can be realized. It has strong adaptability and scalability, high real-time performance, and can meet the rapid development of business needs.
[0031] like Figure 1 As shown, an embodiment of the present invention provides a method for training an image multi-classification model, which may specifically include the following steps.
[0032] S102: Determine an initial image multi-classification model.
[0033] In the embodiment of the present application, the initial image multi-classification model includes an initial first network and an initial second network. The initial first network is an N-classification network, which is used to perform probability prediction of N categories on the input image and output N classification results. The initial second network includes N binary classification networks, which are used to determine whether the input image belongs to the corresponding category and output binary classification results. The parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network.
[0034] The above-mentioned initial first network outputs N classification results, which means that the output results include N probability values, which correspond to N categories respectively.
[0035] In the embodiment of the present invention, the initial image multi-classification model can be trained using the second training sample set, and the second training sample set includes the images of the above N categories. In the process of training the initial image multi-classification model using the second training sample set, labels corresponding to the N categories have been added to the initial first network.
[0036] The above-mentioned initial second network outputs N binary classification results, which means that the output results include N groups of classification results, corresponding to N categories respectively. Among them, each group of classification results includes two labels, 1 and 0, 1 indicates belonging to the category corresponding to the group, and 0 indicates not belonging to the category corresponding to the group. In the process of training the initial image multi-classification model using the second training sample set, N groups of binary classification labels have been added to the initial second network, each group including two labels.
[0037] S104: Obtain a first training sample set, where the first training sample set includes images of N categories and images of an N+1th newly added category.
[0038] S106: Iteratively train the initial first network using the first training sample set until a convergence condition is reached, thereby obtaining a trained first network.
[0039] Among them, the first network after training is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on the input image and output N+1 classification results.
[0040] S108: Add a binary classification network to the initial second network to obtain a second network to be trained.
[0041] S110: Iteratively train the second network to be trained using the first training sample set. During the training process, parameters of the same magnitude as those of the initial first network are selected as training parameters to be updated, and the remaining parameters are set as fixed parameters to remain unchanged until the convergence condition is reached to obtain the trained second network.
[0042] The trained second network includes N+1 binary classification networks.
[0043] In the embodiment of the present invention, the training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
[0044] In the embodiment of the present application, the training parameters refer to the parameters that need to be retrained when adding new categories to the initial image multi-classification model, and the fixed parameters refer to the parameters that do not need to be retrained when adding new categories to the initial image multi-classification model, that is, the fixed parameters remain unchanged during the retraining process. This method can greatly reduce the complexity of retraining, save computing resources and time costs, and improve the efficiency of model training.
[0045] In one implementation, in the above step S110, during the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set as fixed parameters to remain unchanged, which may specifically include:
[0046] During the training process, multiple hierarchical structures are selected according to the forward propagation direction, the parameters in the selected hierarchical structures are set as fixed parameters and remain unchanged, and the parameters in the remaining hierarchical structures of the second network to be trained are used as updated training parameters. The magnitude of the parameters of the remaining hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0047] In another implementation, in the above step S110, during the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set as fixed parameters to remain unchanged, which may specifically include:
[0048] During the training process, multiple hierarchical structures are selected according to the back propagation direction, and the parameters in the selected hierarchical structures are used as the training parameters to be updated, and the parameters in the remaining hierarchical structures of the second network to be trained are set as fixed parameters to remain unchanged. The magnitude of the parameters of the selected hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0049] In the embodiment of the present application, the above-mentioned equal magnitude means that the difference between the number of parameters and the number of parameters of the initial first network is within a specified range. The specified range can be set as needed, and the specific value is not limited.
[0050] In one implementation, the above method may further include:
[0051] During the parallel training process, a total loss value is obtained according to a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained, and the initial image multi-classification model is back-propagated and optimized according to the total loss value.
[0052] Among them, back propagation optimization refers to the use of back propagation to continuously iterate the training model to reduce the total loss value until the model convergence condition is reached and the training is stopped, which means that the model accuracy has reached the required level.
[0053] In one implementation manner, obtaining the total loss value according to the first loss value of the loss function of the initial first network and the second loss value of the loss function of the second network to be trained may specifically include:
[0054] Under the condition that the accuracy of the initial image multi-classification model is not less than a specified threshold during parallel training, a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained are added to obtain a total loss value;
[0055] When parallel training makes the accuracy of the initial image multi-classification model lower than a specified threshold, a first weight is set for a first loss value of the loss function of the initial first network, and a second weight is set for a second loss value of the loss function of the second network to be trained, and the first weight is greater than the second weight; according to the first weight and the second weight, a weighted sum is performed on the first loss value and the second loss value to obtain a total loss value.
[0056] The above method provided by the present embodiment determines an initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network used to perform probability prediction of N categories of the input image and output N classification results, the initial second network includes N binary classification networks, used to judge whether the input image belongs to the corresponding category and output the binary classification result, the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; obtain a first training sample set, including images of N categories and images of the N+1th newly added category; use the first training sample set to iteratively train the initial first network until the convergence condition is reached, and obtain the trained first network, the trained first network is an N+1 classification network; add a binary classification network to the initial second network to obtain the second network to be trained; use the A training sample set is used to iteratively train the second network to be trained. During the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set as fixed parameters to remain unchanged until the convergence condition is reached, and the trained second network is obtained. The trained second network includes N+1 binary classification networks; wherein, the training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute the trained image multi-classification model. Since the fixed parameters in the second network do not need to be trained during the parallel training process, the complexity of training and the maintenance cost of the model are reduced, the model converges quickly, and new categories are added quickly. It can handle changing or expanding data sets, has flexible application, strong adaptability and scalability, high real-time performance, and can meet the rapid development of business needs. Moreover, the model uses a multi-branch network with different parameter magnitudes to convert N classification tasks into N binary classification tasks for training, realizing a training method of multi-dimensional basic network fusion, with strong feature diversity, different dimensional result output, high accuracy, and strong business generalization ability.
[0057] like Figure 2 As shown, an embodiment of the present invention provides another method for training an image multi-classification model, which may specifically include the following steps.
[0058] S202: Determine an initial image multi-classification model.
[0059] In the embodiment of the present application, the image multi-classification model includes an initial first network and an initial second network. The initial first network is an N-classification network, which is used to perform probability prediction of N categories on the input image and output N classification results. The initial second network includes N binary classification networks, which are used to determine whether the input image belongs to the corresponding category and output binary classification results. The parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network.
[0060] In the embodiment of the present application, the initial first network can be implemented by a network with a smaller parameter magnitude, that is, a relatively streamlined network, such as the Inception network, etc. The initial second network can be implemented by a network with a larger parameter magnitude, that is, a relatively complex and mature network, such as the Resnet network, etc. Exemplarily, the parameter magnitude of the initial second network can be much greater than the parameter magnitude of the initial first network, such as the difference between the total number of parameters of the initial second network and the total number of parameters of the initial first network is higher than a specified threshold, and the threshold can be set as needed, such as set to 50 or 100, etc. The embodiment of the present application does not specifically limit the numerical value.
[0061] S204: Obtain a first training sample set, where the first training sample set includes images of N categories and images of an N+1th newly added category.
[0062] S206: Iteratively train the initial first network using the first training sample set until a convergence condition is reached, thereby obtaining a trained first network.
[0063] Among them, the first network after training is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on the input image and output N+1 classification results.
[0064] S208: Add a binary classification network to the initial second network to obtain a second network to be trained.
[0065] S210: Iteratively train the second network to be trained using the first training sample set, select multiple hierarchical structures according to the forward propagation direction during the training process, set the parameters in the selected hierarchical structures to be fixed parameters and keep them unchanged, and use the parameters in the remaining hierarchical structures of the second network to be trained as training parameters to be updated until convergence conditions are reached to obtain the trained second network.
[0066] The trained second network includes N+1 binary classification networks. The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
[0067] In the embodiment of the present invention, forward propagation refers to starting from the input data, calculating and transmitting the data layer by layer through each layer of the neural network, and finally obtaining the output result of the model. During the forward propagation process, the input data is linearly transformed by the weights and biases of each layer, and nonlinearly transformed by the activation function, and then output to the next layer until it reaches the output layer. The purpose of forward propagation is to calculate the predicted value of the model.
[0068] In the embodiment of the present application, the above-mentioned selected multiple hierarchical structures can be selected specifically according to the following principle: the parameter magnitudes of the remaining hierarchical structures in the second network to be trained after selection are the same as the parameter magnitudes of the initial first network.
[0069] The above-mentioned equal magnitude means that the difference between the number of parameters of the remaining hierarchical structures and the number of parameters of the initial first network is within a specified range. The specified range can be set as needed and is not specifically limited.
[0070] For example, the number of parameters of the remaining hierarchical structures is 28, the number of parameters of the initial first network is 30, the specified range is 0 to 10, and the difference of 2 between the number of parameters of the remaining hierarchical structures and the number of parameters of the initial first network is within the specified range, and therefore is of the same order of magnitude.
[0071] Among them, the fixed parameters remain unchanged in the process of each retraining of the model, that is, they do not participate in retraining, thereby ensuring the iteration speed and overall generalization ability of the model.
[0072] For example, the number of parameters of the second network to be trained is 100 in total, and the multi-level structure selected in the forward propagation direction has 85 parameters in total. These 85 parameters are set as fixed parameters, that is, they do not participate in retraining. The remaining hierarchical structures have 15 parameters in total, and these 15 parameters are set as training parameters, that is, they participate in retraining.
[0073] In the embodiment of the present application, the image multi-classification model can recognize N categories after the pre-training process. When a new category is added, the output result of the first network becomes the N+1 classification result, and the first network is retrained to add a new label on the basis of the original N labels, that is, the label corresponding to the new category. In addition, the output result of the second network becomes N+1 binary classification results, and the training parameters of the second network are retrained to add a new set of labels on the basis of the original N sets of binary classification labels, that is, a set of labels (0,1) corresponding to the new category, where 0 represents not belonging to the new category and 1 represents belonging to the new category.
[0074] The above step S210 is a method of setting parameters for training in the forward propagation direction. In the embodiment of the present application, a method of setting parameters for training in the reverse propagation direction may also be adopted, that is, the following steps are used to replace:
[0075] The second network to be trained is iteratively trained using the first training sample set. During the training process, multiple hierarchical structures are selected according to the back propagation direction, and the parameters in the selected hierarchical structures are used as updated training parameters. The parameters in the remaining hierarchical structures of the second network to be trained are set as fixed parameters and remain unchanged until the convergence condition is reached, thereby obtaining the trained second network. The magnitude of the parameters of the selected hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0076] Among them, back propagation refers to the reverse calculation of the gradient through the chain rule according to the difference between the model's prediction results and the true label, and the gradient is propagated from the output layer back to each layer of the network to update the model's parameters. In the back propagation process, the error of the output layer is first calculated, and then the error is propagated from the output layer to the hidden layer, and then to the shallower hidden layer, until it propagates to the input layer. Through back propagation, the gradient information of each parameter to the loss function can be obtained, thereby realizing the optimization and update of the parameters.
[0077] For example, the number of parameters of the second network to be trained is 100 in total, and the multi-level structure selected according to the back-propagation direction has 10 parameters in total, and these 10 parameters are used as the training parameters to be updated, that is, participate in the retraining. The remaining hierarchical structures have 90 parameters in total, and these 90 parameters are set as fixed parameters, that is, do not participate in the retraining.
[0078] In the embodiments of the present application, whether the forward propagation direction or the reverse propagation direction is used to set the training parameters and solidify the parameters, rapid convergence of the model can be achieved, thereby improving the efficiency and accuracy of training.
[0079] S212: When the parallel training makes the accuracy of the initial image multi-classification model lower than a specified threshold, a first weight is set for a first loss value of the loss function of the initial first network, and a second weight is set for a second loss value of the loss function of the second network to be trained.
[0080] In the embodiment of the present application, the above-mentioned specified threshold can be set according to actual needs, and the specific value is not limited. The loss function of the initial first network and the loss function of the second network to be trained can both be the cross entropy loss function softmax. Of course, other loss functions can also be used, which are not specifically limited.
[0081] In an embodiment of the present application, the first weight and the second weight can be dynamically adjusted, such as being initially set to 1, that is, the weights of the first loss value and the second loss value are consistent. When the accuracy of the initial image multi-classification model is lower than the specified threshold, the first weight can be set greater than the second weight to ensure that the first loss value of the first network inception is optimized. In addition, the second weight can be set unchanged or adjusted to a smaller value to ensure that the output result of the second network resnet fluctuates little and reduce the impact on the accuracy of the model. This method of dynamically adjusting weights can maintain a balanced training method for the training parameters of the initial first network and the second network to be trained, thereby improving the performance and training efficiency of the model.
[0082] For example, during the retraining of the model, the initial first network maintains N classification training. As the number of classifications increases, the classification performance of the model will be affected. When the accuracy of the model drops from 97% to 94.8%, since it is lower than the threshold of 95%, the weights are dynamically adjusted. The first weight is set to 1.2 and the second weight is set to 1, so that during the back propagation optimization process, the first loss value is continuously reduced, the optimization effect of the initial first network is improved, and the accuracy and performance of the model are improved.
[0083] S214: According to the first weight and the second weight, weighted sum is performed on the first loss value and the second loss value to obtain a total loss value, and back-propagation optimization is performed on the initial image multi-classification model according to the total loss value.
[0084] In the process of back-propagation optimization, since the parameters of the initial first network and the second network to be trained are of the same magnitude, that is, the difference is not large, the overall training iteration time is basically the same, and the model can be converged quickly. The classification performance of the model will not decrease exponentially with the increase in the number of classifications, thereby improving training efficiency and timeliness.
[0085] Figure 3 Schematic diagram of the architecture of the image multi-classification model provided by the embodiment of the present invention. Figure 3As shown, the image multi-classification model includes an initial first network and an initial second network, the initial first network is a network that outputs N classification results, the initial second network is a network that outputs N binary classification results, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network. N is the number of categories recognized by the image multi-classification model. Image A and image B are two categories among the N categories, such as the two categories of cats and dogs. Among them, after adding a binary classification network, the initial second network determines the solidification parameters and training parameters according to the parameter magnitude of the initial first network. When a new category image C is added, such as the mouse category, the training parameters of the initial first network and the second network after the network is added are retrained, and back-propagation optimization is performed according to the loss functions of the two networks, thereby completing the rapid convergence of the model and improving the accuracy and training efficiency of the model.
[0086] Figure 4 Schematic diagram of the image multi-classification model training process provided by the embodiment of the present invention. Figure 4 As shown in the figure, the image multi-classification model includes the Inception network and the Resnet network. The Resnet network is divided into fixed parameters and training parameters based on the parameter magnitude of the Inception network. Among them, the parameter magnitude corresponding to the training parameter is of the same magnitude as the parameter magnitude of the Inception network. The image multi-classification model has been pre-trained with labeled data of N categories. When a new category is added, the training parameters of the Resnet network and the Inception network are retrained to learn to recognize the new category respectively. The solid circle in the figure represents the recognized category, and the dotted circle represents the new category learned through retraining. Back propagation optimization is performed based on the loss function of the two networks, and finally an image multi-classification model with the expected accuracy is obtained, which enables the model to quickly learn new categories and improves the training efficiency and model accuracy.
[0087] The above method provided by the present embodiment determines an initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network used to perform probability prediction of N categories of the input image and output N classification results, the initial second network includes N binary classification networks, used to judge whether the input image belongs to the corresponding category and output the binary classification result, the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; obtain a first training sample set, including images of N categories and images of the N+1th newly added category; use the first training sample set to iteratively train the initial first network until the convergence condition is reached, and obtain the trained first network, the trained first network is an N+1 classification network; add a binary classification network to the initial second network to obtain the second network to be trained; use the A training sample set is used to iteratively train the second network to be trained. During the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set as fixed parameters to remain unchanged until the convergence condition is reached, and the trained second network is obtained. The trained second network includes N+1 binary classification networks; wherein, the training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute the trained image multi-classification model. Since the fixed parameters in the second network do not need to be trained during the parallel training process, the complexity of training and the maintenance cost of the model are reduced, the model converges quickly, and new categories are added quickly. It can handle changing or expanding data sets, has flexible application, strong adaptability and scalability, high real-time performance, and can meet the rapid development of business needs. Moreover, the model uses a multi-branch network with different parameter magnitudes to convert N classification tasks into N binary classification tasks for training, realizing a training method of multi-dimensional basic network fusion, with strong feature diversity, different dimensional result output, high accuracy, and strong business generalization ability.
[0088] The above is a training method for an image multi-classification model provided by an embodiment of the present invention. Based on the same idea, an embodiment of the present invention also provides a training device for an image multi-classification model, such as Figure 5 shown.
[0089] Determine module 501, used to determine the initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network, the N-classification network is used to perform probability prediction of N categories on the input image, and output N classification results, the initial second network includes N binary classification networks, the binary classification network is used to judge whether the input image belongs to the corresponding category, and output the binary classification result, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network;.
[0090] The acquisition module 502 is used to acquire a first training sample set, where the first training sample set includes images of N categories and images of an N+1th newly added category.
[0091] The first training module 503 is used to iteratively train the initial first network using the first training sample set until the convergence condition is reached, thereby obtaining the trained first network, where the trained first network is an N+1 classification network. The N+1 classification network is used to perform probability prediction of N+1 categories on the input image and output N+1 classification results.
[0092] The second training module 504 is used to add a binary classification network to the initial second network to obtain the second network to be trained; use the first training sample set to iteratively train the second network to be trained, and during the training process, select parameters of the same order of magnitude as the parameters of the initial first network as training parameters to be updated, and set the remaining parameters to be fixed parameters and remain unchanged until the convergence condition is reached, so as to obtain the trained second network, and the trained second network includes N+1 binary classification networks.
[0093] The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
[0094] In the embodiment of the present invention, the initial image multi-classification model is trained using the second training sample set, and the second training sample set includes the images of the above N categories.
[0095] In one implementation, the second training module 504 may include:
[0096] The forward setting unit is used to select multiple hierarchical structures according to the forward propagation direction during the training process, set the parameters in the selected hierarchical structures as fixed parameters to remain unchanged, and use the parameters in the remaining hierarchical structures of the second network to be trained as updated training parameters. The magnitude of the parameters of the remaining hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0097] In one implementation, the second training module 504 may include:
[0098] The reverse setting unit is used to select multiple hierarchical structures according to the reverse propagation direction during the training process, use the parameters in the selected hierarchical structures as the training parameters to be updated, and set the parameters in the remaining hierarchical structures of the second network to be trained as fixed parameters to remain unchanged. The magnitude of the parameters of the selected hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0099] In the embodiment of the present application, the above-mentioned equal magnitude means that the difference between the number of parameters and the number of parameters of the initial first network is within a specified range.
[0100] In an embodiment of the present application, the above-mentioned device is also used to: during the parallel training process, obtain a total loss value based on the first loss value of the loss function of the initial first network and the second loss value of the loss function of the second network to be trained, and perform back propagation optimization on the initial image multi-classification model based on the total loss value.
[0101] In one implementation manner, when the above-mentioned device obtains the total loss value according to the first loss value of the loss function of the initial first network and the second loss value of the loss function of the second network to be trained, it can be specifically used to:
[0102] Under the condition that the accuracy of the initial image multi-classification model is not less than a specified threshold during parallel training, a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained are added to obtain a total loss value;
[0103] When parallel training makes the accuracy of the initial image multi-classification model lower than a specified threshold, a first weight is set for the first loss value of the loss function of the initial first network, and a second weight is set for the second loss value of the loss function of the second network to be trained, and the first weight is greater than the second weight. According to the first weight and the second weight, the first loss value and the second loss value are weightedly summed to obtain a total loss value.
[0104] The above-mentioned device provided in this embodiment can execute the method provided in any of the above-mentioned method embodiments. The detailed process is described in the method embodiment and will not be repeated here.
[0105] The above-mentioned device provided by the present embodiment determines an initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network used to perform probability prediction of N categories on the input image and output N classification results, the initial second network includes N binary classification networks, which are used to judge whether the input image belongs to the corresponding category and output the binary classification result, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; obtains a first training sample set, including images of N categories and images of the N+1th newly added category; uses the first training sample set to iteratively train the initial first network until the convergence condition is reached, and obtains a trained first network, and the trained first network is an N+1 classification network; adds a binary classification network to the initial second network to obtain a second network to be trained; uses the A training sample set is used to iteratively train the second network to be trained. During the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set as fixed parameters to remain unchanged until the convergence condition is reached, and the trained second network is obtained. The trained second network includes N+1 binary classification networks; wherein, the training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute the trained image multi-classification model. Since the fixed parameters in the second network do not need to be trained during the parallel training process, the complexity of training and the maintenance cost of the model are reduced, the model converges quickly, and new categories are added quickly. It can handle changing or expanding data sets, has flexible application, strong adaptability and scalability, high real-time performance, and can meet the rapid development of business needs. Moreover, the model uses a multi-branch network with different parameter magnitudes to convert N classification tasks into N binary classification tasks for training, realizing a training method of multi-dimensional basic network fusion, with strong feature diversity, different dimensional result output, high accuracy, and strong business generalization ability.
[0106] Figure 6 The hardware structure diagram of an electronic device for implementing various embodiments of the present invention is shown in FIG. The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, a processor 610, and a power supply 611. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0107] The processor 610 is used to determine an initial image multi-classification model, wherein the initial image multi-classification model includes an initial first network and an initial second network, wherein the initial first network is an N-classification network, wherein the N-classification network is used to perform probability prediction of N categories on the input image and output N classification results, wherein the initial second network includes N binary classification networks, wherein the binary classification networks are used to determine whether the input image belongs to a corresponding category and output a binary classification result, and wherein the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network;
[0108] Acquire a first training sample set, where the first training sample set includes images of the N categories and images of an N+1th newly added category;
[0109] Iteratively training the initial first network using the first training sample set until a convergence condition is reached to obtain a trained first network, wherein the trained first network is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on the input image and output N+1 classification results;
[0110] Adding a binary classification network to the initial second network to obtain a second network to be trained; using the first training sample set to iteratively train the second network to be trained, selecting parameters of the same magnitude as the parameters of the initial first network as training parameters to be updated during the training process, and setting the remaining parameters to be fixed parameters to remain unchanged until a convergence condition is reached, thereby obtaining a trained second network, wherein the trained second network includes N+1 binary classification networks;
[0111] The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
[0112] In one implementation, the processor 610 may be configured to: select multiple hierarchical structures according to the forward propagation direction during the training process, set the parameters in the selected hierarchical structures as fixed parameters to remain unchanged, and use the parameters in the remaining hierarchical structures of the second network to be trained as updated training parameters. The magnitude of the parameters in the remaining hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0113] In another implementation, the processor 610 may be configured to: select multiple hierarchical structures according to the back propagation direction during the training process, use the parameters in the selected hierarchical structures as the training parameters to be updated, and set the parameters in the remaining hierarchical structures of the second network to be trained as fixed parameters to remain unchanged. The magnitude of the parameters of the selected hierarchical structures is the same as the magnitude of the parameters of the initial first network.
[0114] In this embodiment, the above-mentioned equal magnitude means that the difference between the number of parameters and the number of parameters of the initial first network is within a specified range.
[0115] In one embodiment, the processor 610 is also used to: during the parallel training process, obtain a total loss value according to a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained, and perform back propagation optimization on the initial image multi-classification model according to the total loss value.
[0116] Among them, obtaining the total loss value according to the first loss value of the loss function of the initial first network and the second loss value of the loss function of the second network to be trained may include: when the accuracy of the initial image multi-classification model is not lower than a specified threshold through parallel training, adding the first loss value of the loss function of the initial first network and the second loss value of the loss function of the second network to be trained to obtain the total loss value; when the accuracy of the initial image multi-classification model is lower than the specified threshold through parallel training, setting a first weight for the first loss value of the loss function of the initial first network, setting a second weight for the second loss value of the loss function of the second network to be trained, and the first weight is greater than the second weight, and performing weighted summation of the first loss value and the second loss value according to the first weight and the second weight to obtain the total loss value.
[0117] The electronic device provided in the present embodiment determines an initial image multi-classification model, wherein the initial image multi-classification model includes an initial first network and an initial second network, wherein the initial first network is an N-classification network for performing probability prediction of N categories on an input image and outputting N classification results, and the initial second network includes N binary classification networks for judging whether the input image belongs to a corresponding category and outputting a binary classification result, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; obtains a first training sample set, including images of N categories and images of the N+1th newly added category; uses the first training sample set to iteratively train the initial first network until convergence conditions are reached, and obtains a trained first network, wherein the trained first network is an N+1 classification network; adds a binary classification network to the initial second network to obtain a second network to be trained; and uses The first training sample set is used to iteratively train the second network to be trained. During the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set to fixed parameters to remain unchanged until the convergence condition is reached, and the trained second network is obtained. The trained second network includes N+1 binary classification networks; wherein, the training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute the trained image multi-classification model. Since the fixed parameters in the second network do not need to be trained during the parallel training process, the complexity of training and the maintenance cost of the model are reduced, the model converges quickly, and new categories are added quickly. It can handle changing or expanding data sets, has flexible applications, strong adaptability and scalability, high real-time performance, and can meet the rapid development of business needs. Moreover, the model uses a multi-branch network with different parameter magnitudes to convert N classification tasks into N binary classification tasks for training, realizing a training method of multi-dimensional basic network fusion, with strong feature diversity, output of results in different dimensions, high accuracy, and strong business generalization ability.
[0118] It should be understood that in the embodiment of the present invention, the radio frequency unit 601 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 610 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 601 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 601 can also communicate with the network and other electronic devices through a wireless communication system.
[0119] The electronic device provides users with wireless broadband Internet access through the network module 602, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0120] The audio output unit 603 can convert the audio data received by the RF unit 601 or the network module 602 or stored in the memory 609 into an audio signal and output it as sound. Moreover, the audio output unit 603 can also provide audio output related to a specific function performed by the electronic device 600 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 603 includes a speaker, a buzzer, a receiver, etc.
[0121] The input unit 604 is used to receive audio or video signals. The input unit 604 may include a graphics processor (GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 606. The image frame processed by the graphics processor 6041 can be stored in the memory 609 (or other storage medium) or sent via the radio frequency unit 601 or the network module 602. The microphone 6042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 601 in the case of a telephone call mode.
[0122] The electronic device 600 also includes at least one sensor 605, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 6061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 6061 and / or the backlight when the electronic device 600 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 605 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0123] The display unit 606 is used to display information input by the user or information provided to the user. The display unit 606 may include a display panel 6061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0124] The user input unit 607 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 607 includes a touch panel 6071 and other input devices 6072. The touch panel 6071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 6071 or near the touch panel 6071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 6071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 610, receives the command sent by the processor 610 and executes it. In addition, the touch panel 6071 can be implemented in various types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 6071, the user input unit 607 may also include other input devices 6072. Specifically, other input devices 6072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.
[0125] Furthermore, the touch panel 6071 may be overlaid on the display panel 6061. When the touch panel 6071 detects a touch operation on or near it, it is transmitted to the processor 610 to determine the type of touch event. Then, the processor 610 provides corresponding visual output on the display panel 6061 according to the type of touch event. Figure 6 In the figure, the touch panel 6071 and the display panel 6061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 6071 and the display panel 6061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0126] The interface unit 608 is an interface for connecting an external device to the electronic device 600. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 608 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 600 or may be used to transmit data between the electronic device 600 and an external device.
[0127] The memory 609 can be used to store software programs and various data. The memory 609 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 609 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0128] The processor 610 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 609 and calling data stored in the memory 609, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 610 may include one or more processing units; preferably, the processor 610 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 610.
[0129] The electronic device 600 may also include a power supply 611 (such as a battery) for supplying power to each component. Preferably, the power supply 611 may be logically connected to the processor 610 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0130] Preferably, an embodiment of the present invention further provides an electronic device, comprising a processor 610, a memory 609, and a computer program stored in the memory 609 and executable on the processor 610. When the computer program is executed by the processor 610, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0131] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0132] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0133] The computer-readable storage medium provided by the embodiment of the present invention reduces the complexity of training and the maintenance cost of the model, the model converges quickly, realizes the rapid addition of new categories, can handle changing or expanding data sets, is flexible in application, has strong adaptability and scalability, and is highly real-time, and can meet the rapid development of business needs. Moreover, the model uses a multi-branch network with different parameter magnitudes, has strong feature diversity, outputs results in different dimensions, has high accuracy, and has strong business generalization capabilities.
[0134] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0135] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0136] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0137] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0138] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0139] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0140] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0141] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0142] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A training method for an image multi-classification model, characterized in that: The method comprises: Determine an initial image multi-classification model, the initial image multi-classification model includes an initial first network and an initial second network, the initial first network is an N-classification network, the N-classification network is used to perform probability prediction of N categories on the input image, and output N classification results, the initial second network includes N binary classification networks, the binary classification networks are used to judge whether the input image belongs to the corresponding category, and output the binary classification results, and the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; Acquire a first training sample set, where the first training sample set includes images of the N categories and images of an N+1th newly added category; Iteratively training the initial first network using the first training sample set until a convergence condition is reached to obtain a trained first network, wherein the trained first network is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on the input image and output N+1 classification results; Adding a binary classification network to the initial second network to obtain a second network to be trained; using the first training sample set to iteratively train the second network to be trained, selecting parameters of the same magnitude as the parameters of the initial first network as training parameters to be updated during the training process, and setting the remaining parameters to be fixed parameters to remain unchanged until a convergence condition is reached, thereby obtaining a trained second network, wherein the trained second network includes N+1 binary classification networks; The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
2. The method according to claim 1, characterized in that The initial image multi-classification model is trained using a second training sample set, where the second training sample set includes images of the N categories.
3. The method according to claim 1, characterized in that During the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set to be fixed parameters and remain unchanged, including: During the training process, multiple hierarchical structures are selected according to the forward propagation direction; Set the parameters in the selected hierarchy to remain unchanged; Using the parameters in the remaining hierarchical structure of the second network to be trained as training parameters to be updated; The parameter magnitudes of the remaining hierarchical structures are of the same magnitude as the parameter magnitudes of the initial first network.
4. The method according to claim 1, characterized in that: During the training process, parameters of the same magnitude as the parameters of the initial first network are selected as training parameters to be updated, and the remaining parameters are set to be fixed parameters and remain unchanged, including: During the training process, multiple hierarchical structures are selected according to the back-propagation direction; The parameters in the selected hierarchy are used as training parameters for updating; Setting the parameters in the remaining hierarchical structure of the second network to be trained to remain unchanged as fixed parameters; The parameter magnitude of the selected hierarchical structure is the same as the parameter magnitude of the initial first network.
5. The method according to claim 1, characterized in that Also includes: In the process of parallel training, a total loss value is obtained according to a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained; Back-propagation optimization is performed on the initial image multi-classification model according to the total loss value.
6. The method according to claim 5, characterized in that The obtaining of a total loss value according to a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained comprises: Under the condition that the accuracy of the initial image multi-classification model is not less than a specified threshold value during parallel training, a first loss value of the loss function of the initial first network and a second loss value of the loss function of the second network to be trained are added to obtain a total loss value; When parallel training makes the accuracy of the initial image multi-classification model lower than a specified threshold, a first weight is set for a first loss value of the loss function of the initial first network, and a second weight is set for a second loss value of the loss function of the second network to be trained, and the first weight is greater than the second weight; according to the first weight and the second weight, the first loss value and the second loss value are weightedly summed to obtain a total loss value.
7. A training device for an image multi-classification model, characterized in that: The device comprises: A determination module, used to determine an initial image multi-classification model, wherein the initial image multi-classification model includes an initial first network and an initial second network, wherein the initial first network is an N-classification network, wherein the N-classification network is used to perform probability prediction of N categories on an input image and output N classification results, wherein the initial second network includes N binary classification networks, wherein the binary classification networks are used to determine whether an input image belongs to a corresponding category and output a binary classification result, and wherein the parameter magnitude of the initial second network is greater than the parameter magnitude of the initial first network; An acquisition module, configured to acquire a first training sample set, wherein the first training sample set includes images of the N categories and images of an N+1th newly added category; A first training module is used to iteratively train the initial first network using the first training sample set until a convergence condition is reached to obtain a trained first network, wherein the trained first network is an N+1 classification network, and the N+1 classification network is used to perform probability prediction of N+1 categories on an input image and output an N+1 classification result; A second training module is used to add a binary classification network to the initial second network to obtain a second network to be trained; use the first training sample set to iteratively train the second network to be trained, select parameters of the same magnitude as the parameters of the initial first network as training parameters to be updated during the training process, and set the remaining parameters to be fixed parameters and remain unchanged until a convergence condition is reached, thereby obtaining a trained second network, wherein the trained second network includes N+1 binary classification networks; The training of the initial first network and the second network to be trained is parallel training, and the trained first network and the trained second network constitute a trained image multi-classification model.
8. An electronic device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the method for training an image multi-classification model as claimed in any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the training method of the image multi-classification model as described in any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the steps of the method for training an image multi-classification model as described in any one of claims 1 to 6.
