A method, device and medium for step-by-step training of neural network based on category information
By selecting the set of unlabeled samples with the nearest similarity among N categories, and only updating the data with large changes in weights, the problems of low training accuracy and long storage reading and writing in the existing technology are solved, and the problem of low training accuracy and long storage reading and writing time is realized. More efficient neural network training and updates.
Patent Information
- Application Number
- CN202210031259.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-12
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2042-01-12
AI Technical Summary
When training neural networks, the category information is not fully utilized, resulting in low training accuracy and long storage reading and writing time. Especially when the number of categories is large, the calculation and storage resources are too much, and the fixed number of categories is difficult to converge. It takes a long training time.
By selecting n unlabeled category sample sets from N categories, performing iterative calculations and updating neural network weight data, using the sample set with the most recent similarity for training, only the weight data with large changes are updated, and the weight update of the entire network weight is reduced. , improve training accuracy and efficiency.
It improves the training accuracy and update efficiency of neural networks, saves the update time of storage areas, and solves the problems of low training accuracy and long storage read and write time in the prior art.
Smart Images

Figure CN114358284B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and storage medium for step-by-step training of a neural network based on category information. Background Art
[0002] Neural networks often need to contain category information to complete multi-category tasks such as classification, detection of different categories, or regression. Often, this category information is also uncertain and needs to be optimized during the training process. This category information is often stored as network weights in specific layers of the neural network for training and reasoning. The more categories there are, the more weights are required, and the slower the training and reasoning of these layers. Alternatively, the neural network can be trained step by step using samples of a limited number of categories each time.
[0003] When training a neural network with a fixed number of categories (such as softmax loss), if there are too many categories (such as millions of categories), a large amount of computing and storage resources will be occupied in the layer containing category information, and sometimes even training cannot be performed due to too many required resources. Methods that do not require a fixed number of categories (such as triplet loss) often have difficulty converging, require a long training time, and cannot train category weights.
[0004] In response to the above problems, the previous application 201910538093.6 solved some of the defects, but brought new problems. That is, during the training process, if the neural network is trained step by step using samples of a limited number of categories each time, a random method is used when selecting samples, and the category information cannot be fully utilized, resulting in the accuracy of the trained neural network still not being high enough. This is the first problem; secondly, the current neural network is large in scale. If all weight data are updated in each training, it will take a long time to read and write the storage area. Summary of the invention
[0005] The present invention proposes the following technical solutions to address one or more technical deficiencies in the above-mentioned prior art.
[0006] A method for step-by-step training of a neural network based on category information, the method comprising:
[0007] An acquisition step of acquiring initial weight data of the neural network and storing the initial weight data in a designated storage area;
[0008] A selection step, selecting n unlabeled category sample sets from the N category training sample sets to be trained;
[0009] A training step, using the selected n unlabeled category sample sets to iteratively calculate the neural network to obtain a trained neural network;
[0010] An updating step, updating the weight data of the trained neural network model with the initial weight data in the designated storage area;
[0011] Among them, N is much larger than n, and n is greater than or equal to 2.
[0012] Furthermore, the sample set is an image sample set, a text sample set or a voice sample set.
[0013] Furthermore, the operation of the selection step is: randomly select a category training sample set from all unlabeled category training sample sets in the N category training sample sets to be trained, and then select n-1 category training sample sets with the closest similarity to the selected category training sample set from the remaining unlabeled category training sample sets, and then mark the n category training sample sets, and arrange the samples in the n category training sample sets in random order.
[0014] Furthermore, if all categories in the N-category training sample set are labeled, all labels are reset to unlabeled.
[0015] Furthermore, the operation of the updating step is: the initial weight data is stored in the designated storage area according to the layers of the neural network, the weight data of the trained neural network model is obtained, the weight data whose changes exceed a first threshold and the corresponding layers of the neural network are determined, and the initial weight data in the designated storage area is updated based on the weight data whose changes exceed the first threshold and the corresponding layers of the neural network.
[0016] The present invention also proposes a device for step-by-step training of a neural network based on category information, the device comprising:
[0017] An acquisition unit, which acquires initial weight data of the neural network and stores the initial weight data in a designated storage area;
[0018] A selection unit selects n unlabeled category sample sets from the N category training sample sets to be trained;
[0019] A training unit, using the selected n unlabeled category sample sets to iteratively calculate the neural network to obtain a trained neural network;
[0020] An updating unit, which updates the initial weight data in the designated storage area with the weight data of the trained neural network model;
[0021] Among them, N is much larger than n, and n is greater than or equal to 2.
[0022] Furthermore, the sample set is an image sample set, a text sample set or a voice sample set.
[0023] Furthermore, the operation of the selection unit is: randomly select a category training sample set from all unlabeled category training sample sets in the N category training sample sets to be trained, and then select n-1 category training sample sets with the closest similarity to the selected category training sample set from the remaining unlabeled category training sample sets, and then mark the n category training sample sets, and arrange the samples in the n category training sample sets in random order.
[0024] Furthermore, if all categories in the N-category training sample set are labeled, all labels are reset to unlabeled.
[0025] Furthermore, the operation of the updating unit is as follows: the initial weight data is stored in the designated storage area according to the layers of the neural network, the weight data of the trained neural network model is obtained, the weight data whose changes exceed a first threshold and the corresponding layers of the neural network are determined, and the initial weight data in the designated storage area is updated based on the weight data whose changes exceed the first threshold and the corresponding layers of the neural network.
[0026] The present invention also proposes a device for step-by-step training of a neural network based on category information, the device comprising a processor and a memory, the processors being connected to each other via a bus, the memory storing a computer program, and the processor implementing any of the above methods when executing the computer program on the memory.
[0027] The present invention further provides a computer-readable storage medium, wherein the storage medium stores computer program code, and when the computer program code is executed by a computer, any of the above methods is executed.
[0028] The technical effect of the present invention is: a method, device, equipment and storage medium for step-by-step training of a neural network based on category information of the present invention, the method comprising: an acquisition step, acquiring initial weight data of the neural network, and storing the initial weight data in a designated storage area; a selection step, selecting n unlabeled category sample sets from N category training sample sets to be trained; a training step, using the selected n unlabeled category sample sets to iteratively calculate the neural network to obtain a trained neural network; an updating step, updating the initial weight data in the designated storage area with the weight data of the trained neural network model; in the present invention, n category unlabeled sample sets are selected from N categories and labeled to train the neural network, and the category information of the samples is fully utilized during the training process, thereby improving the training accuracy of the neural network. In the present invention, n samples with the greatest similarity are selected from the N category sample sets. The training is performed using a set of category samples with the closest similarity. Since the n category sample sets have a high similarity, the sample similarity mainly affects the weights of the corresponding layers of the neural network, that is, the weights of some layers can be updated instead of the weights of the entire neural network, thereby improving the speed of updating the storage area. In the present invention, the weight data of the neural network are stored in the storage area according to the corresponding layers. After training with n category sample sets with the closest similarity, only the weights of some layers change greatly. Therefore, the weight data with a large change are selected for update, and the remaining data are not updated. For example, the first threshold is set to 5%, that is, the weight data with a change of more than 5% is selected, and then the corresponding layer is determined, so that the initial weight data in the designated storage area can be updated based on the weight data with a change of more than the first threshold and the corresponding neural network layer, thereby saving update time, improving update efficiency, and ensuring the training speed of the neural network. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Other features, objects and advantages of the present application will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings.
[0030] Figure 1 4 is a flowchart of a method for step-by-step training of a neural network based on category information according to an embodiment of the present invention.
[0031] Figure 2 4 is a structural diagram of a device for step-by-step training of a neural network based on category information according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It should also be noted that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0033] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0034] Figure 1 A method for step-by-step training of a neural network based on category information of the present invention is shown, the method comprising:
[0035] Acquisition step S101, acquiring initial weight data of the neural network, and storing the initial weight data in a designated storage area;
[0036] Select step S102, selecting n unlabeled category sample sets from the N category training sample sets to be trained;
[0037] In the training step S103, the neural network is iteratively calculated using the selected n unlabeled category sample sets to obtain a trained neural network; the arrival calculation is performed at least once, and generally requires iterative calculation multiple times to meet the training requirements.
[0038] Update step S104, update the weight data of the trained neural network model with the initial weight data in the designated storage area; wherein N is much larger than n, n is greater than or equal to 2, for example, N is in the order of millions or tens of millions, for example, N=1000000, for example, n is in the order of tens of thousands, for example, n=10000.
[0039] In one embodiment, the sample set is an image sample set, a text sample set or a voice sample set, for example, for specific image recognition, such as recognizing a person's identity through a face in an image, or recognizing the type of an object through an image feature of an object in an image, or recognizing a person's behavior through a person's features in an image, etc. By inputting the image features of the image to be recognized into an image recognition model, a corresponding image recognition result can be obtained, such as a person's identity, a type of object, a person's behavior, etc. Similarly, text recognition and voice recognition are also similar processing operations.
[0040] In the present invention, a set of unlabeled samples of n categories are selected from N categories and labeled before training a neural network. In the training process, the category information of the samples is fully utilized, the training accuracy of the neural network is improved, and the defects in the prior art are solved. This is an important inventive point of the present invention.
[0041] In one embodiment, the operation of the selection step S102 is: randomly select a category training sample set from all unlabeled category training sample sets in the N category training sample sets to be trained, and then select n-1 category training sample sets with the closest similarity to the selected category training sample set from the remaining unlabeled category training sample sets, and then mark the n category training sample sets, and shuffle the samples in the n category training sample sets. If all categories in the N category training sample sets are marked, reset all marks to unlabeled. The similarity calculation can be cosine distance, etc., of course, it can also be other methods for calculating similarity. For example, the text can use Hamming distance similarity, etc., and the samples in each sample set can also be clustered to obtain the representative element of each category, and the similarity between the sets is calculated through the representative element in each set.
[0042] In the present invention, n category sample sets with the closest similarity are selected from N category sample sets for training. Since the n category sample sets have high similarity, the sample similarity mainly affects the weights of the corresponding layers of the neural network, that is, the weights of some layers can be updated instead of the weights of the entire neural network, thereby improving the speed of updating the storage area. This is another important inventive point of the present invention.
[0043] In one embodiment, the operation of the updating step S104 is as follows: the initial weight data is stored in the designated storage area according to the layers of the neural network, the weight data of the trained neural network model is obtained, the weight data whose changes exceed a first threshold and the corresponding layers of the neural network are determined, and the initial weight data in the designated storage area is updated based on the weight data whose changes exceed the first threshold and the corresponding layers of the neural network.
[0044] In the present invention, the weight data of the neural network is stored in the storage area according to the corresponding layer. After training with n sets of category samples with the closest similarity, only the weights of some layers change greatly. Therefore, the weight data with a large change are selected for update, and the remaining data are not updated. For example, the first threshold is set to 5%, that is, the weight data with a change of more than 5% is selected, and then the corresponding layer is determined. Therefore, the initial weight data in the designated storage area can be updated based on the weight data with a change of more than the first threshold and the corresponding neural network layer, which saves update time, improves update efficiency, and ensures the training speed of the neural network. This is an important invention of the present invention. After the samples of N categories are trained, the update of the weight data of the entire neural network is realized.
[0045] Figure 2 A device for step-by-step training of a neural network based on category information of the present invention is shown, and the device comprises:
[0046] An acquisition unit 201 acquires initial weight data of the neural network and stores the initial weight data in a designated storage area;
[0047] A selection unit 202 selects n unlabeled category sample sets from the N category training sample sets to be trained;
[0048] The training unit 203 uses the selected n unlabeled category sample sets to iteratively calculate the neural network to obtain a trained neural network; the arrival calculation is calculated at least once, and generally requires iterative calculation multiple times to meet the training requirements.
[0049] The updating unit 204 updates the initial weight data in the designated storage area with the weight data of the trained neural network model; wherein N is much larger than n, and n is larger than or equal to 2, such as N is in the order of millions or tens of millions, such as N=1000000, and n is in the order of tens of thousands, such as n=10000.
[0050] In one embodiment, the sample set is an image sample set, a text sample set or a voice sample set, for example, for specific image recognition, such as recognizing a person's identity through a face in an image, or recognizing the type of an object through an image feature of an object in an image, or recognizing a person's behavior through a person's features in an image, etc. By inputting the image features of the image to be recognized into an image recognition model, a corresponding image recognition result can be obtained, such as a person's identity, a type of object, a person's behavior, etc. Similarly, text recognition and voice recognition are also similar processing operations.
[0051] In the present invention, a set of unlabeled samples of n categories are selected from N categories and labeled before training a neural network. In the training process, the category information of the samples is fully utilized, the training accuracy of the neural network is improved, and the defects in the prior art are solved. This is an important inventive point of the present invention.
[0052] In one embodiment, the operation of the selection unit 202 is: randomly select a category training sample set from all unlabeled category training sample sets in the N category training sample sets to be trained, then select n-1 category training sample sets with the closest similarity to the selected category training sample set from the remaining unlabeled category training sample sets, then mark the n category training sample sets, and shuffle the samples in the n category training sample sets. If all categories in the N category training sample sets are marked, reset all marks to unlabeled. The similarity calculation can be cosine distance, etc., of course, it can also be other methods for calculating similarity, for example, text can use Hamming distance similarity, etc., and the samples in each sample set can also be clustered to obtain the representative element of each category, and the similarity between the sets is calculated through the representative element in each set.
[0053] In the present invention, n category sample sets with the closest similarity are selected from N category sample sets for training. Since the n category sample sets have high similarity, the sample similarity mainly affects the weights of the corresponding layers of the neural network, that is, the weights of some layers can be updated instead of the weights of the entire neural network, thereby improving the speed of updating the storage area. This is another important inventive point of the present invention.
[0054] In one embodiment, the operation of the update unit 204 is as follows: the initial weight data is stored in the designated storage area according to the layers of the neural network, the weight data of the trained neural network model is obtained, the weight data whose changes exceed a first threshold and the corresponding layers of the neural network are determined, and the initial weight data in the designated storage area is updated based on the weight data whose changes exceed the first threshold and the corresponding layers of the neural network.
[0055] In the present invention, the weight data of the neural network is stored in the storage area according to the corresponding layer. After training with n sets of category samples with the closest similarity, only the weights of some layers change greatly. Therefore, the weight data with a large change are selected for update, and the remaining data are not updated. For example, the first threshold is set to 5%, that is, the weight data with a change of more than 5% is selected, and then the corresponding layer is determined. Therefore, the initial weight data in the designated storage area can be updated based on the weight data with a change of more than the first threshold and the corresponding neural network layer, which saves update time, improves update efficiency, and ensures the training speed of the neural network. This is an important invention of the present invention. After the samples of N categories are trained, the update of the weight data of the entire neural network is realized.
[0056] In one embodiment of the present invention, a device for step-by-step training of a neural network based on category information is proposed, the device includes a processor and a memory, the processors are connected to each other via a bus, a computer program is stored in the memory, and the processor implements the above method when executing the computer program in the memory. The device can be a desktop computer, a server, a notebook, an intelligent terminal, etc.
[0057] In one embodiment of the present invention, a computer storage medium is provided, on which a computer program is stored. When the computer program on the computer storage medium is executed by a processor, the above method is implemented. The computer storage medium can be a hard disk, DVD, CD, flash memory or other memory.
[0058] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0059] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the devices described in the various embodiments of the present application or certain parts of the embodiments.
[0060] Finally, it should be noted that the above embodiments are only intended to illustrate rather than limit the technical solutions of the present invention. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the present invention can still be modified or replaced by equivalents. Any modification or partial replacement that does not depart from the spirit and scope of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A method for step-by-step training of a neural network based on category information, characterized in that: The method includes: An acquisition step of acquiring initial weight data of the neural network and storing the initial weight data in a designated storage area; The selection step selects n unlabeled category sample sets from the N category training sample sets to be trained, and the specific steps include: randomly selecting a category training sample set from all the unlabeled category training sample sets in the N category training sample sets to be trained, and then selecting n-1 category training sample sets with the closest similarity to the selected category training sample set from the remaining unlabeled category training sample sets, and then marking the n category training sample sets, and arranging the samples in the n category training sample sets in random order, wherein the sample set is an image sample set, a text sample set or a voice sample set; A training step, using the selected n unlabeled category sample sets to iteratively calculate the neural network to obtain a trained neural network; An updating step, updating the initial weight data in the designated storage area with the weight data of the trained neural network model, specifically comprising: storing the initial weight data in the designated storage area according to the layers of the neural network, acquiring the weight data of the trained neural network model, determining the weight data whose changes exceed a first threshold and the corresponding layers of the neural network, and updating the initial weight data in the designated storage area based on the weight data whose changes exceed the first threshold and the corresponding layers of the neural network; Among them, N is much larger than n, and n is greater than or equal to 2.
2. The method according to claim 1, characterized in that If all categories in the N-category training sample set are labeled, all labels are reset to unlabeled.
3. A device for step-by-step training of a neural network based on category information, characterized in that: The device includes: An acquisition unit, which acquires initial weight data of the neural network and stores the initial weight data in a designated storage area; A selection unit selects n unlabeled category sample sets from N category training sample sets to be trained, and the specific steps include: randomly selecting a category training sample set from all unlabeled category training sample sets in the N category training sample sets to be trained, and then selecting n-1 category training sample sets with the closest similarity to the selected category training sample set from the remaining unlabeled category training sample sets, and then marking the n category training sample sets, and arranging the samples in the n category training sample sets in random order, wherein the sample set is an image sample set, a text sample set or a voice sample set; A training unit, using the selected n unlabeled category sample sets to iteratively calculate the neural network to obtain a trained neural network; An updating unit updates the initial weight data in the designated storage area with the weight data of the trained neural network model, and the specific steps include: storing the initial weight data in the designated storage area according to the layers of the neural network, acquiring the weight data of the trained neural network model, determining the weight data whose changes exceed a first threshold and the corresponding layers of the neural network, and updating the initial weight data in the designated storage area based on the weight data whose changes exceed the first threshold and the corresponding layers of the neural network; Among them, N is much larger than n, and n is greater than or equal to 2.
4. The device according to claim 3, characterized in that If all categories in the N-category training sample set are labeled, all labels are reset to unlabeled.
5. A computer storage medium having a computer program stored thereon, wherein when the computer program on the computer storage medium is executed by a processor, the method according to any one of claims 1 to 2 is implemented.
Citation Information
Patent Citations
Selection method for fuzzy neural network sample on basis of active learning
CN102063642A
Neural network model training method and apparatus, electronic device and computer storage medium
CN108229676A
Data processing method, device and system and storage medium
CN110288085A
Neural network model training method and training system
CN110751286A
Classification model training method and device based on small samples, and electronic equipment
CN113919418A
