Multi-task learning model training method, device, electronic device and storage medium
By performing differential balance conversion and loss value calculation in the multi-task learning model, the problem of excessive difference in task loss values in multi-task learning model training is solved, and the robustness and training balance of the model are improved.
Patent Information
- Application Number
- CN202210505196.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-05-10
AI Technical Summary
During the training process of the multi-task learning model, the loss values of different tasks are too different, resulting in unbalanced model training and poor robustness.
By obtaining the training picture set and the pre-built multi-task learning model, the encoder is used for convolution pooling, the label analysis value and the real value of the task category are calculated, the task loss value is calculated, and the difference balance conversion is performed to obtain the standard task loss value and target loss value, and update the model parameters to balance the loss values of different tasks.
It improves the training balance and robustness of the multi-task learning model, avoids the excessive impact of a single task loss value on the model gradient, and enhances the generalization performance of the model.
Smart Images

Figure CN114913371B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to artificial intelligence technology, and in particular to a multi-task learning model training method, device, electronic device and storage medium. Background Art
[0002] In recent years, deep learning has greatly improved the performance of various computer vision tasks, and multi-task learning jointly learns multiple tasks in one model to achieve better generalization performance and lower memory usage. The combination of the two, namely multi-task learning model training research, has attracted more and more attention.
[0003] However, in the current training process of multi-task learning models, the loss values of different tasks vary greatly, resulting in the model training being dominated by a certain task, while other tasks are not trained, resulting in poor robustness of the trained model. Summary of the invention
[0004] The present invention provides a multi-task learning model training method, device, electronic device and storage medium, the main purpose of which is to improve the robustness of the trained model.
[0005] Obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories;
[0006] Obtain a pre-built multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with a plurality of decoders, and the decoders correspond to the task categories one by one;
[0007] Using the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set;
[0008] Using the decoder corresponding to the task category to calculate each feature data in the feature data set, to obtain a label analysis value corresponding to the task category;
[0009] Confirming the true value of the label corresponding to the task category according to the task label corresponding to the task category of the training image corresponding to the feature data;
[0010] Calculate the task loss value between the label analysis value and the label true value corresponding to the task category using the preset loss function corresponding to the task category;
[0011] Performing differential balance conversion on the task loss value to obtain a standard task loss value, and using all the standard task loss values to perform calculation to obtain a target loss value;
[0012] When the target loss value is greater than or equal to the loss threshold, updating the parameters of the multi-task learning model, and returning to the step of performing convolution pooling on the training picture set for a preset number of times using the encoder;
[0013] When the target loss value is less than the loss threshold, the trained multi-task learning model is output.
[0014] Optionally, performing a differential balance conversion on the task loss value to obtain a standard task loss value includes:
[0015] Performing gradient conversion on the loss function corresponding to each of the tasks to obtain the corresponding gradient function;
[0016] The label analysis value and the label true value corresponding to each task category are used as function parameters to calculate the gradient function corresponding to the task category to obtain the gradient of the task category;
[0017] Calculating according to the gradient of the task category to obtain the weight of the task category;
[0018] The standard task loss value of the task category is calculated based on the weight and task loss value of the task category.
[0019] Optionally, performing a differential balance conversion on the task loss value to obtain a standard task loss value includes:
[0020] Calculate the proportion of each task loss value in all task loss values to obtain the loss value proportion;
[0021] Taking the inverse of the loss value ratio of the task loss value, to obtain the loss value weight of the task loss value;
[0022] Calculate each task loss value and the corresponding loss value weight to obtain the corresponding standard task loss value.
[0023] Optionally, the using the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain the feature data set includes:
[0024] Randomly select a preset number of training pictures from the training picture set to obtain a training picture subset;
[0025] Performing a preset number of convolution pooling operations on each training image in the training image subset to obtain corresponding feature data;
[0026] All the feature data are aggregated to obtain the feature data set.
[0027] Optionally, the calculating using all the standard task loss values to obtain a target loss value includes:
[0028] Each of the standard task loss values is normalized, and all normalized standard task loss values are summed to obtain the target loss value.
[0029] In order to solve the above problems, the present invention also provides a multi-task learning model training device, the device comprising:
[0030] A loss value calculation module is used to obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories; obtain a pre-constructed multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with multiple decoders, and the decoders correspond to the task categories one by one; use the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set; use the decoder corresponding to the task category to calculate each feature data in the feature data set to obtain a label analysis value corresponding to the task category; confirm the label true value corresponding to the task category according to the task label corresponding to the task category of the training picture corresponding to the feature data; use the preset loss function corresponding to the task category to calculate the task loss value between the label analysis value corresponding to the task category and the label true value;
[0031] A loss value conversion module, used to perform differential balance conversion on the task loss value to obtain a standard task loss value, and use all the standard task loss values to perform calculations to obtain a target loss value;
[0032] The model training module is used to update the parameters of the multi-task learning model when the target loss value is greater than or equal to the loss threshold, and return to the convolution pooling step of performing a preset number of convolutions and pooling on the training picture set using the encoder; when the target loss value is less than the loss threshold, output the trained multi-task learning model.
[0033] Optionally, the calculating using all the standard task loss values to obtain a target loss value includes:
[0034] Performing gradient conversion on the loss function corresponding to each of the tasks to obtain the corresponding gradient function;
[0035] The label analysis value and the label true value corresponding to each task category are used as function parameters to calculate the gradient function corresponding to the task category to obtain the gradient of the task category;
[0036] Calculating according to the gradient of the task category to obtain the weight of the task category;
[0037] The standard task loss value of the task category is calculated based on the weight and task loss value of the task category.
[0038] Optionally, the calculating using all the standard task loss values to obtain a target loss value includes:
[0039] Calculate the proportion of each task loss value in all task loss values to obtain the loss value proportion;
[0040] Taking the inverse of the loss value ratio of the task loss value, to obtain the loss value weight of the task loss value;
[0041] Calculate each task loss value and the corresponding loss value weight to obtain the corresponding standard task loss value.
[0042] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0043] a memory storing at least one computer program; and
[0044] A processor executes the computer program stored in the memory to implement the multi-task learning model training method described above.
[0045] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the multi-task learning model training method described above.
[0046] The embodiment of the present invention uses the preset loss function corresponding to the task category to calculate the task loss value between the label analysis value and the label true value corresponding to the task category; performs a differential balance conversion on the task loss value to obtain a standard task loss value, and uses all the standard task loss values for calculation to obtain a target loss value; balances the loss values of different tasks to avoid the influence of a single loss value on the model gradient, thereby increasing the training degree of each task in the multi-task learning model and improving the robustness of the trained model; therefore, the multi-task learning model training method, device, electronic device and readable storage medium proposed in the embodiment of the present invention improve the robustness of the trained model. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A flowchart of a multi-task learning model training method provided by an embodiment of the present invention;
[0048] Figure 2 A schematic diagram of a module of a multi-task learning model training device provided by an embodiment of the present invention;
[0049] Figure 3A schematic diagram of the internal structure of an electronic device for implementing a multi-task learning model training method provided by an embodiment of the present invention;
[0050] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0051] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0052] The embodiment of the present invention provides a multi-task learning model training method. The execution subject of the multi-task learning model training method includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided in the embodiment of the present application. In other words, the multi-task learning model training method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.
[0053] Reference Figure 1 FIG. 1 is a flow chart of a multi-task learning model training method provided by an embodiment of the present invention. In the embodiment of the present invention, the multi-task learning model training method includes:
[0054] S1. Obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories;
[0055] In the embodiment of the present invention, training a multi-task learning model is to train multiple related tasks, and all the task categories are interrelated. For example, the multiple tasks trained are gender recognition and face detection, then the task categories are gender recognition task and face detection task, and the task label corresponding to the gender recognition task is male or female; the face detection task label is the regional coordinates of the face.
[0056] S2. Obtain a pre-built multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with a plurality of decoders, and the decoders correspond to the task categories one by one;
[0057] The multi-task learning model in the embodiment of the present invention is composed of an encoder connected in parallel with decoders corresponding to multiple task categories, wherein the encoder contains network parameters shared by all tasks; further, each task corresponds to a decoder, and the decoder contains task-specific network parameters.
[0058] Optionally, the encoder in the embodiment of the present invention is a deep learning network including multiple convolutional layers and pooling layers, and the decoder is composed of a fully connected layer and a preset activation function.
[0059] S3, using the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set;
[0060] In an embodiment of the present invention, the encoder is used to perform convolution pooling on the training picture set for a preset number of times to obtain the feature data set, including:
[0061] Randomly select a preset number of training pictures from the training picture set to obtain a training picture subset;
[0062] Performing a preset number of convolution pooling operations on each training image in the training image subset to obtain corresponding feature data;
[0063] All the feature data are aggregated to obtain the feature data set.
[0064] Furthermore, the convolution pooling described in the embodiment of the present invention includes convolution processing and pooling processing, the convolution processing is convolution using a preset convolution kernel, and the pooling processing is maximum pooling or average pooling.
[0065] Specifically, in another embodiment of the present invention, convolution pooling is performed a preset number of times on each training picture in the training picture subset to obtain corresponding feature data, including: using the convolution layer in the encoder to convolve the training picture to obtain corresponding convolution data; using the pooling layer in the encoder to average pool the convolution data to obtain feature data, wherein the sum of the number of convolution layers and pooling layers in the encoder is equal to the preset number of times.
[0066] S4, using the decoder corresponding to the task category to calculate each feature data in the feature data set to obtain a label analysis value corresponding to the task category;
[0067] In the embodiment of the present invention, the decoder corresponding to the task category is used to calculate each feature data in the feature data set to obtain a label analysis value corresponding to the task category, including:
[0068] Each feature data in the feature data set is calculated using the activation function in the decoder corresponding to the task category to obtain a label analysis value corresponding to the task category.
[0069] Furthermore, in the embodiment of the present invention, the following activation function formula is used to calculate each feature data in the feature data set, including:
[0070]
[0071] Among them, μ t represents the label analysis value corresponding to the task category, and s represents the feature data in the feature data set.
[0072] S5, confirming the true value of the label corresponding to the task category according to the task label corresponding to the task category of the training image corresponding to the feature data;
[0073] In the embodiment of the present invention, the consistency between the label analysis value predicted by the model and the actual corresponding task label is better measured, and the true value of the label corresponding to the task category is confirmed according to the task category of the training image corresponding to the feature data.
[0074] For example, if the task label corresponding to the task category is a gender label, then when the task label is "male", the actual value of the label corresponding to the task label is 1; when the task label is "female", the actual value of the label corresponding to the task label is 0.
[0075] S6, using the preset loss function corresponding to the task category to calculate the task loss value between the label analysis value corresponding to the task category and the label true value;
[0076] In the embodiment of the present invention, each task category corresponds to a preset loss function, and the loss functions corresponding to each task category may be the same or different.
[0077] Specifically, the loss function described in the embodiment of the present invention includes but is not limited to a logarithmic loss function, a square loss function, an absolute value loss function, a cross entropy loss function, and the like.
[0078] In another embodiment of the present invention, the task loss value can be stored in a blockchain node, utilizing the high throughput characteristics of the blockchain node to improve data access efficiency.
[0079] S7, performing differential balance conversion on the task loss value to obtain a standard task loss value, and using all the standard task loss values to perform calculation to obtain a target loss value;
[0080] In the embodiment of the present invention, the task loss values of different tasks decrease with different gradients. In order to avoid the absolute influence of the task loss value of the task with a fast decrease caused by the difference of different loss values being too large, the tasks corresponding to the task loss values without gradient decrease are basically not trained, thereby making the training invalid. Therefore, it is necessary to perform a differential balance conversion on the task loss values to obtain a standard task loss value, and use all the standard task loss values to calculate to obtain a target loss value. Specifically, in the embodiment of the present invention, the task loss values are differentially balanced to obtain a standard task loss value, including:
[0081] Performing gradient conversion on the loss function corresponding to each of the tasks to obtain the corresponding gradient function;
[0082] Optionally, the gradient function in the embodiment of the present invention is a function representing the rate of change of the loss function. Therefore, the gradient conversion operation in the embodiment of the present invention may be a derivative or partial derivative operation of the loss function.
[0083] The label analysis value and the label true value corresponding to each task category are used as function parameters to calculate the gradient function corresponding to the task category to obtain the gradient of the task category;
[0084] Calculating according to the gradient of the task category to obtain the weight of the task category;
[0085] In detail, in the embodiment of the present invention, the greater the absolute value of the gradient, the greater the impact on the loss value of the corresponding task category. Therefore, in order to balance this impact, in the embodiment of the present invention, the inverse of the gradient of each task category is used as the weight of the task category; since the gradient can be a negative value, the weight cannot be a negative value; in the embodiment of the present invention, the absolute value of the gradient of the task category is taken to obtain the standard gradient of the task category; the inverse of the standard gradient of the task category is taken to obtain the weight of the task category.
[0086] Calculate the task loss value based on the task category weight and task loss value to obtain the standard task loss value of the task category;
[0087] Specifically, in the embodiment of the present invention, the weight and the task loss value of each task category are multiplied to obtain the standard task loss value of the task category.
[0088] All the standard task loss values are calculated to obtain the target loss value.
[0089] Furthermore, in an embodiment of the present invention, all the standard task loss values are used for calculation to obtain a target loss value, including: summing up all the standard task loss values to obtain the target loss value.
[0090] In another embodiment of the present invention, in order to reduce the consumption of subsequent computing resources, each of the standard task loss values is normalized, and all normalized standard task loss values are summed to obtain the target loss value.
[0091] In another embodiment of the present invention, the task loss value is subjected to differential balance conversion to obtain a standard task loss value, including:
[0092] Calculate the proportion of each task loss value in all task loss values to obtain the loss value proportion;
[0093] Specifically, the embodiment of the present invention calculates the ratio of the task loss value to the sum of all the task loss values to obtain the loss value proportion.
[0094] Taking the inverse of the loss value ratio of the task loss value, to obtain the loss value weight of the task loss value;
[0095] Calculate each task loss value and the corresponding loss value weight to obtain the corresponding standard task loss value.
[0096] For example: the loss value weight of task loss value A is 0.1, and task loss value A is 0.5, then the standard task loss value of task loss value A is 0.5*0.1=0.05.
[0097] S8, determining whether the target loss value is less than a preset loss threshold;
[0098] In detail, in order to measure whether the training accuracy of the model meets the preset requirements in the embodiment of the present invention, it is determined whether the target loss value is less than the loss threshold.
[0099] S9, when the target loss value is greater than or equal to the loss threshold, update the parameters of the multi-task learning model, and return to the step of performing convolution pooling on the training picture set for a preset number of times using the encoder;
[0100] In the embodiment of the present invention, when the target loss value is greater than or equal to the loss threshold, it means that the model accuracy of the multi-task learning model does not meet the requirements, and therefore, it is necessary to change the parameters of the multi-task learning model and continue training. Specifically, the embodiment of the present invention uses a gradient descent algorithm to update the model parameters of the multi-task learning model to obtain an updated multi-task learning model.
[0101] S10. When the target loss value is less than the loss threshold, output the trained multi-task learning model.
[0102] In the embodiment of the present invention, when the target loss value is less than the loss threshold, the multi-task learning model at this time is output to obtain a trained multi-task learning model.
[0103] like Figure 2 , which is a functional module diagram of the multi-task learning model training device of the present invention.
[0104] The multi-task learning model training device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the multi-task learning model training device can include a loss value calculation module 101, a loss value conversion module 102, and a model training module 103. The module described in the present invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0105] In this embodiment, the functions of each module / unit are as follows:
[0106] The loss value calculation module 101 is used to obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories; obtain a pre-constructed multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with multiple decoders, and the decoders correspond to the task categories one by one; use the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set; use the decoder corresponding to the task category to calculate each feature data in the feature data set to obtain a label analysis value corresponding to the task category; confirm the label true value corresponding to the task category according to the task label corresponding to the task category of the training picture corresponding to the feature data; use the preset loss function corresponding to the task category to calculate the task loss value between the label analysis value corresponding to the task category and the label true value;
[0107] The loss value conversion module 102 is used to perform differential balance conversion on the task loss value to obtain a standard task loss value, and use all the standard task loss values to perform calculations to obtain a target loss value;
[0108] The model training module 103 is used to update the parameters of the multi-task learning model when the target loss value is greater than or equal to the loss threshold, and return to the convolution pooling step of performing a preset number of convolutions and pooling on the training picture set using the encoder; when the target loss value is less than the loss threshold, output the trained multi-task learning model.
[0109] In detail, each module described in the multi-task learning model training device 100 in the embodiment of the present invention is used in the same manner as described above. Figure 1 The multi-task learning model training method described in is the same technical means and can produce the same technical effects, so I will not go into details here.
[0110] like Figure 3 , which is a schematic diagram of the structure of an electronic device for implementing a multi-task learning model training method according to the present invention.
[0111] The electronic device may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a multi-task learning model training program.
[0112] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 can also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 can also include both an internal storage unit of the electronic device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device, such as the code of the multi-task learning model training program, but also can be used to temporarily store data that has been output or is to be output.
[0113] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as multi-task learning model training programs, etc.) stored in the memory 11, and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0114] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The communication bus 12 is configured to realize connection and communication between the memory 11 and at least one processor 10, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0115] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0116] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to various components. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure classification circuits, power converters or inverters, power status indicators, etc. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0117] Optionally, the communication interface 13 may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices.
[0118] Optionally, the communication interface 13 may also include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0119] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0120] The multi-task learning model training program stored in the memory 11 in the electronic device is a combination of multiple computer programs. When running in the processor 10, it can achieve:
[0121] Obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories;
[0122] Obtain a pre-built multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with a plurality of decoders, and the decoders correspond to the task categories one by one;
[0123] Using the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set;
[0124] Using the decoder corresponding to the task category to calculate each feature data in the feature data set, to obtain a label analysis value corresponding to the task category;
[0125] Confirming the true value of the label corresponding to the task category according to the task label corresponding to the task category of the training image corresponding to the feature data;
[0126] Calculate the task loss value between the label analysis value and the label true value corresponding to the task category using the preset loss function corresponding to the task category;
[0127] Performing differential balance conversion on the task loss value to obtain a standard task loss value, and using all the standard task loss values to perform calculation to obtain a target loss value;
[0128] When the target loss value is greater than or equal to the loss threshold, updating the parameters of the multi-task learning model, and returning to the step of performing convolution pooling on the training picture set for a preset number of times using the encoder;
[0129] When the target loss value is less than the loss threshold, the trained multi-task learning model is output.
[0130] Specifically, the specific implementation method of the processor 10 for the above computer program can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0131] Furthermore, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0132] An embodiment of the present invention may further provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program may implement:
[0133] Obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories;
[0134] Obtain a pre-built multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with a plurality of decoders, and the decoders correspond to the task categories one by one;
[0135] Using the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set;
[0136] Using the decoder corresponding to the task category to calculate each feature data in the feature data set, to obtain a label analysis value corresponding to the task category;
[0137] Confirming the true value of the label corresponding to the task category according to the task label corresponding to the task category of the training image corresponding to the feature data;
[0138] Calculate the task loss value between the label analysis value and the label true value corresponding to the task category using the preset loss function corresponding to the task category;
[0139] Performing differential balance conversion on the task loss value to obtain a standard task loss value, and using all the standard task loss values to perform calculation to obtain a target loss value;
[0140] When the target loss value is greater than or equal to the loss threshold, updating the parameters of the multi-task learning model, and returning to the step of performing convolution pooling on the training picture set for a preset number of times using the encoder;
[0141] When the target loss value is less than the loss threshold, the trained multi-task learning model is output.
[0142] Furthermore, the computer-usable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0143] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0144] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0145] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0146] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0147] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0148] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0149] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0150] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A multi-task learning model training method, characterized in that: The method comprises: Obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories; Obtain a pre-built multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with a plurality of decoders, and the decoders correspond to the task categories one by one; Randomly selecting a preset number of training pictures from the training picture set to obtain a training picture subset, using the encoder to perform a preset number of convolution pooling operations on each training picture in the training picture subset to obtain corresponding feature data, and summarizing all of the feature data to obtain the feature data set; Using the decoder corresponding to the task category to calculate each feature data in the feature data set, to obtain a label analysis value corresponding to the task category; Confirming the true value of the label corresponding to the task category according to the task label corresponding to the task category of the training image corresponding to the feature data; Calculate the task loss value between the label analysis value and the label true value corresponding to the task category using the preset loss function corresponding to the task category; Calculate the proportion of each task loss value in all task loss values to obtain the loss value proportion, take the inverse of the loss value proportion of the task loss value as the loss value weight of the task loss value, use each task loss value and the corresponding loss value weight to calculate the standard task loss value corresponding to each task, normalize each standard task loss value, and sum all normalized standard task loss values to obtain the target loss value; When the target loss value is greater than or equal to the loss threshold, updating the parameters of the multi-task learning model, and returning to the step of performing convolution pooling on the training picture set for a preset number of times using the encoder; When the target loss value is less than the loss threshold, the trained multi-task learning model is output.
2. The multi-task learning model training method according to claim 1, characterized in that: The calculation of the proportion of each task loss value in all task loss values to obtain the loss value proportion, taking the inverse of the loss value proportion of the task loss value as the loss value weight of the task loss value, and using each task loss value and the corresponding loss value weight to calculate the standard task loss value corresponding to each task, includes: Performing gradient conversion on the loss function corresponding to each task to obtain the corresponding gradient function; The label analysis value and the label true value corresponding to each task category are used as function parameters to calculate the gradient function corresponding to the task category to obtain the gradient of the task category; Calculating according to the gradient of the task category to obtain the weight of the task category; The standard task loss value of the task category is calculated based on the weight and task loss value of the task category.
3. A multi-task learning model training device, used to implement the multi-task learning model training method according to any one of claims 1 to 2, characterized in that: include: A loss value calculation module is used to obtain a training picture set, wherein each training picture in the training picture set contains task labels corresponding to multiple task categories; obtain a pre-constructed multi-task learning model, wherein the multi-task learning model is composed of an encoder connected in parallel with multiple decoders, and the decoders correspond to the task categories one by one; use the encoder to perform convolution pooling on the training picture set for a preset number of times to obtain a feature data set; use the decoder corresponding to the task category to calculate each feature data in the feature data set to obtain a label analysis value corresponding to the task category; confirm the label true value corresponding to the task category according to the task label corresponding to the task category of the training picture corresponding to the feature data; use the preset loss function corresponding to the task category to calculate the task loss value between the label analysis value corresponding to the task category and the label true value; A loss value conversion module is used to calculate the proportion of each task loss value in all task loss values to obtain the loss value proportion, take the inverse of the loss value proportion of the task loss value as the loss value weight of the task loss value, use each task loss value and the corresponding loss value weight to calculate the standard task loss value corresponding to each task, and sum all the standard task loss values to obtain the target loss value; The model training module is used to update the parameters of the multi-task learning model when the target loss value is greater than or equal to the loss threshold, and return to the convolution pooling step of performing a preset number of convolutions and pooling on the training picture set using the encoder; when the target loss value is less than the loss threshold, output the trained multi-task learning model.
4. The multi-task learning model training device according to claim 3, characterized in that: The calculation of the proportion of each task loss value in all task loss values to obtain the loss value proportion, taking the inverse of the loss value proportion of the task loss value as the loss value weight of the task loss value, and using each task loss value and the corresponding loss value weight to calculate the standard task loss value corresponding to each task, includes: Performing gradient conversion on the loss function corresponding to each task to obtain the corresponding gradient function; The label analysis value and the label true value corresponding to each task category are used as function parameters to calculate the gradient function corresponding to the task category to obtain the gradient of the task category; Calculating according to the gradient of the task category to obtain the weight of the task category; The standard task loss value of the task category is calculated based on the weight and task loss value of the task category.
5. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the multi-task learning model training method as described in any one of claims 1 to 2.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the multi-task learning model training method as described in any one of claims 1 to 2 is implemented.
