Fine-grained multi-task hierarchical gradient balancing method
Through the fine-grained multi-task hierarchical gradient balance method, the problem of training conflicts between tasks in multi-task learning is solved, and more robust multi-task learning and performance improvement is achieved.
Patent Information
- Application Number
- CN202510195007.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-06-13
AI Technical Summary
The existing multi-task learning methods are prone to encounter training conflicts between tasks in actual deployment, resulting in performance degradation. The existing methods resolve gradient conflicts at the global level, ignoring the finer-grained gradient conflict balance requirements on each layer of network within the model.
A fine-grained multi-task hierarchical gradient balance method is proposed. By obtaining the degree of demand required by each specific task module for each service layer of the shared module, configuring the balance factor of the task in the target service layer, and adaptively updating the gradient balance weights to realize fine-grained gradient weight adjustment of each service layer of the shared module.
At the fine-grained level, weaken gradient conflicts, reduce competition between tasks, achieve more robust multi-task learning, and improve the performance of multiple tasks.
Smart Images

Figure CN120146152A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a fine-grained multi-task hierarchical gradient balancing method, a storage medium, a computer program product, and an electronic device. Background Art
[0002] In the related art, multi-task learning, as a major research direction in the field of machine learning, aims to improve the overall efficiency and performance by concurrently optimizing multiple interrelated tasks. This field has been widely applied in areas such as computer vision, natural language processing, speech recognition, and speech enhancement. A multi-task model usually includes a shared module and multiple task-specific prediction heads, concentrating a large number of parameters in the shared module to achieve more efficient inference and enhance the generalization of feature extraction. However, in actual deployment, directly executing multiple tasks on a unified model often encounters training conflicts between tasks, which can lead to a decrease in performance compared to training each task separately.
[0003] It should be noted that the information disclosed in the above background art section is only used to enhance the understanding of the background of the present invention, and thus may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0004] The present invention provides a fine-grained multi-task hierarchical gradient balancing method, a storage medium, a computer program product, and an electronic device, which can effectively consider the importance degree of each business layer of the shared module for different tasks, achieve multi-task balance at a finer-grained level, and thus can overcome the defects existing in the prior art to a certain extent.
[0005] Other features and advantages of the present invention will become apparent through the following detailed description, or be learned in part through the practice of the present invention.
[0006] According to a first aspect of the present invention, there is provided a fine-grained multi-task hierarchical gradient balancing method, the method comprising:
[0007] Constructing a multi-task model; the multi-task model includes: a shared module, and multiple task-specific modules;
[0008] Obtaining the demand degree of each task corresponding to each task-specific module for each business layer of the shared module;
[0009] Configuring a balance factor of the task at a target business layer based on the demand degree of each task for each business layer of the shared module;
[0010] Based on the balance factor configured for the target service layer of the task, adaptively update the gradient balance weights of each service layer according to the degree of demand, so as to achieve fine-grained gradient weight adjustment for each service layer of the shared module; until the multi-task model converges.
[0011] In some exemplary embodiments, the obtaining the degree of demand of each specific task module for each service layer of the shared module includes:
[0012] Estimate the degree of demand of the task for each service layer according to the loss function corresponding to the task and the influence deviation of the parameters of each service layer of the shared module on the loss function, and determine the corresponding demand score;
[0013] Perform normalization processing on the demand score.
[0014] In some exemplary embodiments, the configuring the balance factor of the task in the target service layer based on the degree of demand of each task for each service layer of the shared module includes:
[0015] Determine the target service layer corresponding to the maximum demand score according to the demand scores of the task in each service layer;
[0016] Configure the balance factor of the task in the target service layer for the task to have the maximum gradient update on the target service layer.
[0017] In some exemplary embodiments, the method further includes:
[0018] When it is determined that there is a second target service layer, reconfigure the balance factor of the task in the target service layer and the balance factor of the second target service layer; wherein, the demand score of the second target service layer is greater than the demand score of the target layer;
[0019] Configure the task to have the maximum gradient update in the second service layer according to the reconfigured balance factor, and reduce the gradient update of the task in the target service layer.
[0020] In some exemplary embodiments, the method further includes:
[0021] Configure the value of the hyperparameter according to the task type corresponding to the multi-task model; wherein, the hyperparameter is used to control the degree of action of the balance factor on the gradient update.
[0022] In some exemplary embodiments, the method further includes:
[0023] During the training of the multi-task model, increase the number of service layers that need to be gradient-adjusted in the shared module according to the increase of the training time.
[0024] In some exemplary embodiments, the method further includes:
[0025] The total gradient norm of each service layer after gradient weight adjustment is less than or equal to the original gradient norm.
[0026] According to a second aspect of the present invention, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the above-mentioned fine-grained multi-task hierarchical gradient balancing method.
[0027] According to a third aspect of the present invention, there is provided an electronic device, including:
[0028] A processor; and
[0029] A memory for storing executable instructions of the processor;
[0030] Wherein, the processor is configured to implement the above-mentioned fine-grained multi-task hierarchical gradient balancing method when executing the executable instructions.
[0031] According to a fourth aspect of the present invention, there is provided a computer program product having stored thereon a computer program which, when executed by a processor, implements the above-mentioned fine-grained multi-task hierarchical gradient balancing method.
[0032] The fine-grained multi-task hierarchical gradient balancing method provided by the embodiments of the present invention obtains the degree of demand of each specific task module for each service layer of the shared module; then configures the balance factor of the task in the target service layer based on the degree of demand of each task for each service layer of the shared module; based on the balance factor already configured for the task in the target service layer, adaptively updates the gradient balance weights of each service layer according to the degree of demand to achieve fine-grained gradient weight adjustment of each service layer of the shared module; until the multi-task model converges. This method considers the problem of balancing the hierarchical gradient demand conflicts in multi-task learning; by weakening the gradient updates of tasks with relatively low demand on each layer of the shared module, the gradient conflict is weakened at the fine-grained level, and the competition between each task and the remaining tasks at the positions where they are more in need compared to other tasks is also reduced. By considering the differences in the gradient update requirements of each task, more robust multi-task learning can be achieved. By implementing a progressive hierarchical gradient fine-tuning strategy to balance the hierarchical gradient update requirements during the multi-task learning process, the impact of gradient updates of less important tasks on specific network layers can be reduced.
[0033] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present invention. Description of the Drawings
[0034] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0035] Figure 1 A schematic diagram schematically showing a fine-grained multi-task hierarchical gradient balancing method according to an exemplary embodiment of the present invention;
[0036] Figure 2 A schematic diagram schematically showing a comparison of the principle of this method and the prior art principle according to an exemplary embodiment of the present invention;
[0037] Figure 3 A schematic diagram schematically showing a gradient update method when processing a segmentation task and a depth estimation task according to an exemplary embodiment of the present invention;
[0038] Figure 4 A schematic diagram showing the composition of an electronic device in an exemplary embodiment of the present invention. Detailed implementation manners
[0039] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this invention will be more complete and comprehensive, and the concept of the exemplary embodiments will be fully conveyed to those skilled in the art. The features, structures, or characteristics described can be combined in any suitable manner in one or more embodiments.
[0040] In addition, the accompanying drawings are only schematic illustrations of the present invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus repeated descriptions thereof will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0041] In related technologies, the main reasons for training conflicts in multi-task models are as follows: the design of the loss function and the different training speeds of multiple tasks caused by differences in data distribution, which lead to asynchronous updates between multiple tasks. The existing methods for solving task conflicts in multi-task learning can be divided into loss-based and gradient-based methods. The loss-based method considers balancing the magnitudes of the loss functions on multiple branches, aiming to balance the magnitude of the final backpropagation of the loss function by adjusting the task weights or modifying the loss function itself, thereby alleviating conflicts. On the other hand, the gradient-based method considers that the gradient directions of multiple tasks in the model sharing part are conflicting, aiming to align the task gradient directions, and achieving the optimal solution of the joint gradient under a specific loss function by remapping the unaligned gradient angles or solving the dual problem of the joint gradient direction. Most existing methods solve multi-task conflicts at the global level by focusing on the overall loss weights of the model or the final gradients of the model sharing module, usually ignoring the need for finer-grained gradient conflict balance on each layer of the network inside the model.
[0042] Taking the example of simultaneously solving the multi-tasks of semantic segmentation and depth estimation, both belong to the image pixel classification tasks. Usually, it is hoped to combine the two tasks into one to achieve an efficient and coupled multi-task model. During training, the loss functions for the two tasks are the cross-entropy loss and the L1 loss respectively; the semantic segmentation task needs to classify the overall pixels of the image and requires more shallow global features; the depth estimation task depends more on the local abstract information of the picture and requires more deep local features. These will lead to training conflicts between the two during actual deployment, which are more manifested in the differences in the update requirements of different tasks for different parts of the model. The previous methods based on loss weights and global gradient balance of the shared module consider modifying the direction or magnitude of the gradient as a whole. For example, the dynamic weight adaptation (DWA) method based on loss magnitude or the gradient and loss normalization (GradNorm) method modify the loss weights as a whole through the output of the backend part of the model, apply a larger weight to the depth estimation task in subsequent training, and amplify the gradient of the depth estimation task. This can enhance the utilization rate of the deep local features of the model by the depth estimation task, but at the same time, it also amplifies the occupation of the gradient by the depth estimation task during the update of the shallow features. Although the depth estimation task is enhanced, it also prevents the model from learning the knowledge required by the semantic segmentation task in the shallow layer and cannot improve the performance of multiple tasks simultaneously. Therefore, reasonably judging the degree of gradient update requirements of each task for each layer of the model and completing the learning of this task with a larger weight at the model position where the model needs it more can reduce multi-task conflicts at a fine-grained level and achieve simultaneous improvement in the performance of multiple tasks.
[0043] For example, the existing multi-task balancing method is first the overall gradient adjustment based on loss magnitude. This method realizes more training on the weak task branch by adjusting the weights of the loss functions on each task. This way has an impact on the gradients of the multi-task model sharing module The adjustment process can be expressed as:
[0044]
[0045] It can be intuitively seen that adjusting the weight ω j can more easily achieve multi-task gradient balance update. Existing research work of this kind has explored various ways to adaptively adjust ω j : Based on the change rate of the loss function, use a larger ω j to accelerate slow task learning; based on the positive correlation between the loss update rate and the gradient, establish the optimal gradient through the change of task loss, and thus update ω by gradually approaching the current gradient to the optimal gradient j ; or based on the teacher-student distance, increase the weight ω of the slower training task through the performance gap between each branch and the corresponding teacher model j .
[0046] Although the method of directly adjusting the overall weights of multiple tasks can achieve gradient balance, it often cannot fully solve the gradient conflict problem. Therefore, some work considers making each branch of multiple tasks converge as the optimization goal, and taking the direction and amplitude of adjusting as the way to solve the optimization goal. This kind of work considers directly performing a remapping operation on the gradient to make the joint gradient most conducive to the improvement of multi-task comprehensive performance. Usually, a mapping function is used to transform the direction and magnitude of the gradient of each specific task in the shared module by the shared module. If such a mapping function is denoted as Ψ(·), the adjustment process of the multi-task shared module gradient based on remapping can be expressed as:
[0047]
[0048] The mapping function is usually determined by the optimization goal of multiple tasks and the method used to solve the optimization problem. This method also realizes global gradient balance on the multi-task shared module.
[0049] It can be seen from the above formula that the competition in multi-task training stems from the different demand goals of each task, which leads to conflicts in the gradient update of the shared module. Adjusting the gradient direction and magnitude can weaken the conflict. Although many works have proved that the method of achieving multi-task gradient balance at the global level can improve multi-task performance, these methods still cannot fundamentally solve the negative impact on the remaining tasks after adjusting the gradient of a single task branch; that is, enhancing a specific single task branch will inevitably lead to varying degrees of performance reduction in the remaining branches. These methods balance the gradient globally and do not consider the hierarchical gradient differences of the multi-task model, and often cannot ensure the gradient balance on all shared modules of the multi-task model.
[0050] In view of the disadvantages and deficiencies of the prior art, a fine-grained multi-task hierarchical gradient balancing method is provided in the present exemplary embodiment. Refer to Figure 1 As shown, the fine-grained multi-task hierarchical gradient balancing method may specifically include the following steps:
[0051] Step S11, constructing a multi-task model; the multi-task model includes: a shared module, and multiple specific task modules;
[0052] Step S12, obtaining the degree of demand of each specific task module for each business layer of the shared module;
[0053] Step S13, configuring a balance factor of the task for the target business layer based on the degree of demand of each task for each business layer of the shared module;
[0054] Step S14, based on the balance factor already configured for the task for the target business layer, adaptively updating the gradient balance weights of each business layer according to the degree of demand, so as to achieve fine-grained gradient weight adjustment for each business layer of the shared module; until the multi-task model converges.
[0055] Next, each step of the fine-grained multi-task hierarchical gradient balancing method in the present exemplary embodiment will be described in more detail with reference to the accompanying drawings and embodiments.
[0056] In step S11, a multi-task model is constructed; the multi-task model includes: a shared module, and multiple specific task modules.
[0057] Exemplarily, a multi-task model based on target requirements may be first constructed, such as a multi-task model for functions such as image classification and text recognition. The multi-task model includes a shared module with a large number of parameters, and multiple specific task modules with a small number of parameters.
[0058] When training the multi-task model, an input data set may be pre-constructed where N is the number of data; assuming that these data sets have K label sets at the same time, which are respectively: representing the true value labels on K tasks.
[0059] Define Φ(·) and respectively represent the shared module and the task-specific module of the jth task. The total loss function L of typical multi-task learning MTL is usually obtained by summing the losses of each specific task, and can be expressed as:
[0060]
[0061] where ω jrepresents the loss function weight of the j-th task. It can also be seen from this formula that the shared module Φ(·) is used by multiple tasks simultaneously, but each training data x i has different training labels for different tasks
[0062] In step S12, obtain the degree of demand of each specific task module's task for each business layer of the shared module.
[0063] Exemplarily, in the above step S12, the obtaining the degree of demand of each specific task module's task for each business layer of the shared module includes:
[0064] Estimate the degree of demand of the task for each business layer according to the loss function corresponding to the task and the influence deviation of the parameters of each business layer of the shared module on the loss function, and determine the corresponding demand score; perform normalization processing on the demand score.
[0065] Specifically, to comprehensively improve the performance of multiple tasks, it is feasible to gradually balance the multi-task gradient conflict with a small step size at the local level until the global gradient is balanced.
[0066] Specifically, for fine-grained balancing of multi-task conflicts, it is necessary to clarify the differences in the degree of demand of each task for different positions of the multi-task shared module. If the multi-task model shared module Φ(·) is regarded as composed of different components, that is, Φ(·) = {φ 1 (·), φ 2 (·),..., φ Q (·)}; where Q represents the number of business layers included in the shared module. Among them, the division of the number of business layers of the shared module can be determined according to computing resources and time. For example, according to the non-linear layer (ReLU), batch normalization layer (BN), downsampling operation (Pooling) or random division.
[0067] Due to task and data changes, each layer of the shared module will be activated to different degrees. The degree of demand of the task for this layer can be judged by the change in the loss function when a certain layer is deleted. Specifically, when it is necessary to judge the degree of demand of task j for the q-th layer of the shared module, if the degree of demand is expressed as then the formula can be expressed as:
[0068]
[0069] Among them, represents the loss function of task j, The difference between and j represents the influence deviation of the parameter φ
[0070] An approximate estimate is required here The condition is: Assume φ j (·) is small enough compared to Φ(·) and exists. Use the first-order Taylor approximation to estimate as:
[0071]
[0072] Therefore, by taking the partial derivative with respect to the parameter φ j it can be used to judge the demand degree of each layer of the shared module for the task, as the importance of each layer for the corresponding task. The competition of multiple tasks on a specific layer q is reflected as the difference between. To better compare the relative importance differences between tasks, assume that the total demand of each task for all layers of the shared module is specific. Then, for different tasks, the evaluation of the importance differences of the layer demands of each task should not be based on the absolute modulus of the gradient of each layer otherwise, the task with a larger loss amplitude will dominate the multi-task model.
[0073] Therefore, the importance of each layer of the same task needs to be normalized to obtain the relative importance of each layer for the corresponding task. The formula can include:
[0074]
[0075] By calculating the hierarchical relative demand of each task j, j ∈ {1, 2,..., K} for the multi-task shared module Φ(·) q ∈ {1, 2,..., Q}, the demand differences of different tasks on the specific layer j of the shared module can be obtained. This difference can be used to guide the fine-grained hierarchical gradient balance of multi-task adaptation.
[0076] For example, can be used to judge the layer in the shared module where gradient adjustment is required at this time. Among them, t represents the current training round, and t max represents the preset total number of training rounds.
[0077] And through calculate the demand scores of each task j on the q layer that meets the conditions respectively.
[0078] Use formula to normalize the demand scores of each task on each layer.
[0079] In step S13, based on the demand degrees of each task for each service layer of the shared module, configure the balance factor of the task on the target service layer.
[0080] Exemplarily, configuring the balance factor of the task in the target service layer based on the demand degrees of each task for each service layer of the shared module includes:
[0081] Determine the target service layer corresponding to the maximum demand score according to the demand scores of the task in each service layer;
[0082] Configure the balance factor of the task in the target service layer for the task to have the maximum gradient update on the target service layer.
[0083] Exemplarily, the method further includes: when it is determined that there is a second target service layer, reconfiguring the balance factor of the task in the target service layer and the balance factor of the second target service layer; wherein, the demand score of the second target service layer is greater than the demand score of the target layer; configuring the task to have the maximum gradient update on the second service layer according to the reconfigured balance factor, and reducing the gradient update of the task on the target service layer.
[0084] Specifically, the training conflicts of the multi-task model mainly come from the gradient conflicts of multiple tasks. In the past, the work of globally balancing multi-task gradient conflicts can be summarized as adjusting the gradient amplitude and direction from an overall perspective according to the update requirements of multiple tasks. Therefore, starting from the update requirements at a finer-grained level can achieve better global gradient balance for multiple tasks.
[0085] This method improves on the previous methods. First, it shows the impact of the global gradient balance strategy on local gradient updates. Taking the gradient update on the parameters of the q-th layer as an example, multiple tasks update the gradient of the parameters φ of the q-th layer q The updated gradient is expressed as:
[0086]
[0087] It can be seen that for a specific task j, the same weight ω is used for the network parameters of each layer j For the gradient is adjusted, and the weight is usually determined by the change rate of the loss function. These methods often ignore the different demand degrees of each task for different parts of the model. For example, the semantic segmentation task pays more attention to shallow global knowledge, and the depth estimation task pays more attention to deep local information; blindly balancing gradients globally cannot well achieve the balance of parameter gradient updates for each layer, and the multi-task model can only achieve sub-optimal performance improvement in the end.
[0088] Therefore, this method hopes to establish an adaptive gradient balance weight for each layer, which is expressed by the formula:
[0089]
[0090] Among them,
[0091] If the symbol represents the multi-task sharing module as a coupled connection of layer parameters The multi-task sharing module hierarchical gradient balancing strategy can be expressed as:
[0092]
[0093] To obtain it is stipulated that at time t, represents task j 1 the demand for the parameters of the q-th layer of the shared module by task j is greater than that of task j 2 , to achieve the balance of the overall multi-task gradient update demand, it is necessary to ensure that each task performs more gradient updates on the most needed parameters. Therefore, in the update of the q-th layer of the shared module, according to the differences in the importance of each task, the gradients of the tasks with relatively low demand for the parameters of this layer need to be reduced. It can be expressed as:
[0094]
[0095] where α is a hyperparameter used to control the effect of the balance factor When α is set to be large, it will be more likely to approach 0 or 1.
[0096] This process can be expressed as, if then the updated gradient of task j at the q-th layer should be reduced by a certain amount to reduce the conflict of multiple gradients and ensure the learning of the task that most needs to perform gradient updates on the parameters of this layer.
[0097] When holds, the update demand of task j for the parameters of the q-th layer is greater than that of any other task. At this time, it is necessary to ensure the gradient update of task j to the greatest extent. Through the fine-grained gradient balance weights guided by the multi-task hierarchical requirements can be obtained. Through this weight, each task can obtain a greater update on the parameters where gradient updates are most needed, thereby reducing the gradient conflict on each layer of parameters and achieving the overall gradient balance.
[0098] For example, it can be to perform fine-grained gradient weight adjustment on each task on the layer {q|q≥t·Q / t max}}. Specifically,
[0099] when the demand score of task j on the current layer q is the largest: configure to ensure the largest gradient update of task j on the current layer q;
[0100] When When the demand score of task l for the current layer q is greater: According to Reduce the gradient update of task j on the current layer q;
[0101] Use Update the parameters of the multi-task model sharing module, and repeat the above steps until the model converges or reaches the maximum number of training epochs.
[0102] In step S14, based on the balance factor configured for the task in the target service layer, adaptively update the gradient balance weights of each service layer according to the demand degree to achieve fine-grained gradient weight adjustment of each service layer of the sharing module; until the multi-task model converges.
[0103] Exemplarily, to achieve better gradient balance on the multi-task model, it is necessary to ensure conflict reduction while achieving multi-task convergence as much as possible. This requires estimating the update result of each step of the model to determine whether each gradient update will promote the convergence of the loss function. According to the above analysis, the loss function of the multi-task model at time t+1 is In the derivation of this step, it is assumed that represents all the parameters of the multi-task model, and the loss function can be simplified to If the step size of the multi-task model update is α, and the gradient of the loss function satisfies H-Lipschitz continuity, that is Then Compared with the previous moment the difference of
[0104]
[0105] where g represents the multi-task update gradient after weight adjustment.
[0106] The key to the convergence of the multi-task model is that each step of the update will make the final loss smaller, that is Therefore, it is necessary to satisfy That is And Therefore, the total adjusted gradient norm should not be greater than the original gradient norm, so it is necessary to ensure that the gradient adjustment weights of each layer to ensure the convergence of the multi-task loss function.
[0107] In this method, the total gradient update of the multi-task model needs to calculate the local gradients of each task layer by layer, which is expressed as This requires a long calculation delay and a large amount of resource occupation. To optimize the calculation delay of the whole process, the whole adjustment process can be modified to That is, the number of parameters that need to be adjusted layer by layer increases with time. At this time, the hierarchical gradient weight balance parameter can be expressed as:
[0108]
[0109] That is, the number of parameters for hierarchical gradient adjustment gradually increases as time t increases: where t max represents the preset total number of training epochs.
[0110] Therefore, this method does not require adjusting the gradients of all parameters of the multi-task sharing module simultaneously during the entire training process. At the same time, gradually increasing the number of parameters to be adjusted can also achieve more stable fine-grained gradient adjustment.
[0111] For the initial multi-task model T that needs gradient adjustment 0 , when the multi-task model converges or reaches the maximum number of training epochs, the model T after fine-grained gradient balance at this time is output 1 .
[0112] Exemplarily, this method was implemented on an 8 * NVIDIA GeForce 3090 server using the PyTorch framework, and the hyperparameter α was selected from [0.01, 0.1, 0.5, 0.7, 1.0, 1.5]. On the Cityscapes dataset, we used the Adam optimizer with a learning rate of 1e-4. This training model had a total of 200 epochs, and the learning rate decayed to 0.5 of the original value every 100 epochs.
[0113] Reference Figure 2 shows the description of previous work on the existing technical solution and the explanation of the present invention. Taking a multi-task model with two tasks as an example; first, it can be seen that the gradient backpropagation of the multi-task model updates from deep to shallow. The previous gradient conflict balance algorithm judges the different requirements of multiple tasks according to the training loss update rate of each task, and increases the learning weight of the task with slower training in the subsequent process, denoted as ω 1 > ω 2 , and the gradient of each layer task is obtained by summing the gradients of all tasks:
[0114]
[0115] where represents the gradient of the multi-task model including the shared module Φ(·) and multiple task-specific modules , ω j is the weight applied to each task for balancing the gradient, and the symbol represents the coupled connection of the total gradient of the multi-task sharing module as the parameter gradients of each layer
[0116] This kind of work can balance the gradient conflicts of multiple tasks from a global perspective, but it often ignores the differences in the degree of demand for different position parameters of the multi-task shared module by different tasks. For example: in Figure 2 Task 1 shown in the middle requires deeper parameters for update more (the gradient update demand of Task 1 for deeper parameters is higher), while Task 2 requires shallower parameter update more. This discovery is shown more clearly in Figure 3 . On this basis, after weighting the gradients on the global parameters with a unified weight, as shown in Figure 2 (a), the global gradient weighting can make Task 1 perform more updates on the deeper parameters it needs most, but it will also perform larger updates on the shallower parameters. And performing more updates on the shallow features that Task 1 doesn't care about will not only fail to further enhance the performance of Task 1, but will instead lead to a decline in the performance of Task 2.
[0117] Based on this discovery, in the principle of the present invention shown in Figure 2 (b), by hierarchically reducing the gradients of tasks with relatively lower demand, the gradient conflicts of multiple tasks for each layer of the shared layer are balanced more finely; enabling each task to perform better updates on the parameters it needs most. The multi-task gradient adjustment process of the present invention can be expressed as:
[0118]
[0119] Among them, the balance parameter for controlling the gradient weight of the q-th layer of the j-th task has a calculation process of:
[0120]
[0121] That is, the number of parameters for hierarchical gradient adjustment gradually increases as time t increases: Among them, t max represents the preset total number of training epochs. In this way, on the one hand, less training latency is achieved, and on the other hand, more stable hierarchical gradient conflict adjustment can be ensured.
[0122] Exemplarily, on the Cityscapes dataset, the experimental results compared with the state-of-the-art multi-task balance method are shown in Table 1.
[0123] Table 1
[0124]
[0125] Among them, the comprehensive performance improvement index is obtained by summing the improvement ratios of each task relative to the initial MTL method. The calculation formula is:
[0126]
[0127] Among them, They respectively represent the performance of the comparison method and the baseline method on task i.
[0128] As can be seen from the results, our method can well achieve a better balance between multiple tasks, with a 1.59% higher comprehensive performance than the sub-optimal result AMTL.
[0129] In addition, the present invention can be efficiently applied to the multi-task dataset for handwritten recognition (MultiMNIST). The construction process of the dataset is as follows: randomly and uniformly sample two different images. Then place one image in the upper left corner and the other in the lower right corner. The two tasks in the multi-task learning problem are to classify the numbers in the upper left corner (task L) and the lower right corner (task R) respectively, and the results are shown in Table 2.
[0130] Table 2
[0131]
[0132] The method provided by the embodiment of the present invention works on solving the multi-task balance problem at the deep model level. This fine-grained adjustment identifies the real trigger factors of task conflicts: the differences in gradient update requirements, and can achieve more robust multi-task learning. And this method proposes an approximate method for parameter importance to quantify the demand degree of each task for each layer, and realizes the balance of hierarchical gradient update requirements in the multi-task learning process through a progressive hierarchical gradient fine-tuning strategy. This method can reduce the impact of less important task gradient updates on specific network layers.
[0133] This method points out that: 1) The conflicts in the multi-task model training process are mainly gradient conflicts, which are mainly caused by different requirements of different tasks for parameters; the conflicts can be reduced by adjusting the gradient amplitude and direction of each task. 2) The previous multi-task conflict reduction strategies based on global weight adjustment cannot achieve the optimal performance. The present invention proposes a more fine-grained multi-task hierarchical gradient adjustment strategy; according to the differences in the demand degrees of different tasks for different parameters of the multi-task shared module, the gradient amplitude of the task with relatively lower demand is reduced on a specific layer, so as to gradually reduce the multi-task gradient conflict at a fine-grained level. 3) Use Lipschitz continuity to prove the convergence of this method, and propose a progressive increase in the number of multi-task adjusted parameters based on the way of curriculum learning to achieve reduced latency and better convergence effect.
[0134] It should be noted that the above-mentioned drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present invention, rather than for limiting purposes. It is easy to understand that the processes shown in the above-mentioned drawings do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be executed synchronously or asynchronously in, for example, multiple modules.
[0135] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present invention, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0136] Figure 4 The schematic diagram of the electronic device suitable for implementing the embodiments of the present invention is shown.
[0137] It should be noted that Figure 4 The shown electronic device 1000 is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.
[0138] As Figure 4 shown, the electronic device 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 1002 or the programs loaded from the storage section 1008 into the random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, ROM 1002, and RAM 1003 are connected to each other via a bus 1004. The input / output (I / O) interface 1005 is also connected to the bus 1004.
[0139] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed so that the computer program read from it can be installed into the storage section 1008 as needed.
[0140] In particular, according to an embodiment of the present invention, the processes described below with reference to the flowchart can be implemented as computer software programs. For example, an embodiment of the present invention includes a computer program product that includes a computer program carried on a storage medium, and the computer program contains program codes for performing the methods shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication section 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.
[0141] It should be noted that the storage medium shown in the embodiments of the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or combined with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program codes. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any storage medium other than a computer-readable storage medium, and this storage medium can send, propagate, or transmit a program for use by or combined with an instruction execution system, apparatus, or device. The program codes contained on the storage medium can be transmitted by any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code, and the above-mentioned module, segment of a program, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0143] The units described in the embodiments of the present invention can be implemented in software or in hardware, and the described units can also be provided in a processor. Among them, the names of these units do not, in some cases, constitute a limitation on the unit itself.
[0144] It should be noted that, on the other hand, the present application also provides a storage medium, which may be included in an electronic device; or it may exist separately without being assembled into the electronic device. The above storage medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device is caused to implement the methods described in the following embodiments. For example, the electronic device may implement each step of the method as Figure 1 shown.
[0145] In one embodiment, the present application provides a computer program product, including a computer program, which when executed by a processor implements the steps in the above method embodiments.
[0146] In addition, the above accompanying drawings are only schematic illustrations of the processes included in the methods according to the exemplary embodiments of the present invention, rather than for limiting purposes. It is easy to understand that the processes shown in the above accompanying drawings do not indicate or limit the chronological order of these processes. Additionally, it is also easy to understand that these processes can be executed, for example, synchronously or asynchronously in multiple modules.
[0147] Other embodiments of the present invention will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention herein. This application is intended to cover any variations, uses, or adaptations of the invention following the general principles of the invention and including known or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are pointed out by the claims.
[0148] It should be understood that the present invention is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is defined only by the appended claims.
Claims
1. A fine-grained multi-task hierarchical gradient balancing method, characterized in that: The method comprises: Constructing a multi-task model; the multi-task model includes: a shared module and a plurality of specific task modules; Obtain the degree of demand of tasks corresponding to each specific task module for each business layer of the shared module; Based on the degree of demand of each task for each business layer of the shared module, configure the balance factor of the task in the target business layer; Based on the balancing factor configured for the task at the target business layer, the gradient balancing weights of each business layer are adaptively updated according to the degree of demand, so as to achieve fine-grained gradient weight adjustment of each business layer of the shared module; until the multi-task model converges.
2. The method according to claim 1, characterized in that The step of obtaining the degree of demand of the tasks corresponding to each specific task module on each business layer of the shared module includes: According to the loss function corresponding to the task and the influence deviation of the parameters of each business layer of the shared module on the loss function, estimate the degree of demand of the task for each business layer and determine the corresponding demand score; The demand scores are normalized.
3. The method according to claim 2, characterized in that The configuring the balance factor of the task at the target business layer based on the degree of demand of each task for each business layer of the shared module includes: Determine the target business layer corresponding to the maximum demand score according to the demand scores of the task at each business layer; A balance factor of the task at the target service layer is configured so that the task has a maximum gradient update at the target service layer.
4. The method according to claim 3, characterized in that The method further comprises: When it is determined that there is a second target business layer, reconfigure the balance factor of the task at the target business layer and the balance factor of the second target business layer; wherein the demand score of the second target business layer is greater than the demand score of the target layer; According to the reconfigured balance factor, the task is configured to have the maximum gradient update at the second business layer, and the gradient update of the task at the target business layer is reduced.
5. The method according to claim 3, characterized in that: The method further comprises: The value of a hyperparameter is configured according to the task type corresponding to the multi-task model; wherein the hyperparameter is used to control the degree of effect of the balance factor on the gradient update.
6. The method according to claim 1, characterized in that The method further comprises: When training a multi-task model, the number of business layers that require gradient adjustment in the shared module is increased as the training time increases.
7. The method according to claim 1, characterized in that The method further comprises: After the gradient weight is adjusted, the total gradient modulus of each business layer is less than or equal to the original gradient modulus.
8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the fine-grained multi-task hierarchical gradient balancing method according to any one of claims 1 to 7 is implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the fine-grained multi-task hierarchical gradient balancing method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the fine-grained multi-task hierarchical gradient balancing method according to any one of claims 1 to 7 by executing the executable instructions.