CN112766493B - Training method and device for multitask neural network, electronic equipment and storage medium - Google Patents

Training method and device for multitask neural network, electronic equipment and storage medium Download PDF

Info

Publication number
CN112766493B
CN112766493B CN202110069465.2A CN202110069465A CN112766493B CN 112766493 B CN112766493 B CN 112766493B CN 202110069465 A CN202110069465 A CN 202110069465A CN 112766493 B CN112766493 B CN 112766493B
Authority
CN
China
Prior art keywords
task
target
gradient
parameter
neural network
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110069465.2A
Other languages
Chinese (zh)
Other versions
CN112766493A (en
Inventor
游山
宋玉茹
楼赞
王飞
钱晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sensetime Technology Development Co Ltd
Original Assignee
Beijing Sensetime Technology Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sensetime Technology Development Co Ltd filed Critical Beijing Sensetime Technology Development Co Ltd
Priority to CN202110069465.2A priority Critical patent/CN112766493B/en
Publication of CN112766493A publication Critical patent/CN112766493A/en
Application granted granted Critical
Publication of CN112766493B publication Critical patent/CN112766493B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/483Multiproc
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

The present disclosure provides a training method, an apparatus, an electronic device and a storage medium for a multitask neural network, wherein the method comprises: acquiring a training sample, and processing the training sample through a multi-task neural network to obtain a prediction result of each task; determining a loss function of each task according to the prediction result of each task, and constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized; solving the multi-target gradient optimization model to obtain a weight value of each task and a parameter value of a direction correction parameter of the gradient descending direction of the target task; and determining a sharing parameter of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task. The embodiment of the disclosure can promote the learning of the target task and improve the learning effect of the target task in the multitask neural network by setting the preference for learning the target task and the auxiliary task.

Description

Training method and device for multitask neural network, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to a method and an apparatus for training a multitask neural network, an electronic device, and a storage medium.
Background
At present, the multi-task learning is a novel and practical problem in the field of deep learning, and aims to learn a plurality of related tasks simultaneously, so that the overall precision is promoted through interaction among the tasks, the learning efficiency of a network is improved, and the reasoning time is shortened. Existing frameworks include soft and hard parameter sharing. Under hard parameter (e.g., task sharing parameters) sharing, multiple tasks share the network fabric agent and collectively train the parameters of the part. Hard parameter sharing is more generalized than soft parameter (e.g., private parameters and models per task) sharing.
In existing multi-task learning, often some tasks are of interest to the trainer (i.e., target tasks), while the rest of the tasks (i.e., privileged tasks) are used to assist in training only some of the tasks of interest to the trainer. However, in general, in the conventional multi-task learning, which is a deep learning algorithm, a target task and an auxiliary task are usually trained together, but the importance of the target task and the importance of the auxiliary task are the same in the training process, so that the importance of the target task cannot be highlighted or the help provided by a privileged task for the target task cannot be utilized in the conventional training method, and the effect of the target task is poor.
Disclosure of Invention
The embodiment of the disclosure at least provides a training method and device of a multitask neural network, electronic equipment and a storage medium.
In a first aspect, an embodiment of the present disclosure provides a method for training a multitask neural network, including: acquiring a training sample, and processing the training sample through a multi-task neural network to obtain a prediction result of each task; wherein the multitasking comprises: a target task and an auxiliary task; determining a loss function of each task according to the prediction result of each task, and constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized; solving the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises the following steps: the weight value of each task and the parameter value of the gradient descending direction correction parameter of the target task; the direction correction parameter is used for representing the training priority degree of the target task; and determining the sharing parameters of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task.
In the embodiment of the disclosure, the learning bias of each task can be determined according to the weight value by determining the weight value of each task, wherein the learning bias can be used for describing the training speed of the target task and the auxiliary task. Therefore, a preferred learning of the target task and the auxiliary task can be achieved by determining the weight value of each task. Meanwhile, in the embodiment of the disclosure, by determining the parameter value of the direction correction parameter in the gradient descending direction of the target task, the training of the target task can be biased better under the condition that the target task and the auxiliary task do not conflict in the training process, so that the learning of the target task and the auxiliary task with preference is further realized. The learning of the target task can be promoted by setting the preference for learning the target task and the auxiliary task, and the learning effect of the target task in the multi-task neural network is improved.
In an optional implementation manner, the solving the multi-objective gradient optimization model to obtain the optimization result of the variable to be optimized includes: performing multi-target solution on the target function based on the target constraint condition to obtain a pareto solution; and determining the weight value of each task and the parameter value of the direction correction parameter of the descending direction of the gradient of the target task according to the pareto solution.
In the embodiment of the disclosure, a multi-objective solution is performed on an objective function through an objective constraint condition to obtain a pareto solution, and then a mode of determining a weight value of each task and a parameter value of a direction correction parameter of a descending direction of a gradient of an objective task according to the pareto solution is used, so that a multi-task learning problem can be converted into a multi-objective optimization problem, and the weight value of each task and the parameter value of the direction correction parameter of the descending direction of the gradient of the objective task are rapidly determined.
In an alternative embodiment, the multi-objective gradient optimization model includes: an objective function and an objective constraint, the objective function comprising: a first function and a second function, wherein the first function is used for representing the weighted sum of the gradient and the weight value of each task, and the second function is used for representing the correction direction of the target task relative to the gradient descending direction of the auxiliary task; the target constraint condition comprises the following constraint parameters: the weight parameter of each task and the direction correction parameter of the gradient descending direction of the target task.
In the embodiment of the disclosure, by setting the objective function as the first function and the second function and setting the objective constraint condition by the constraint parameter, when the objective function is solved by using the objective constraint condition, a weighted value of each task can be dynamically solved, so that a multi-task is preferably learned, and further, when the auxiliary task and the objective task conflict, the learning of the objective task is promoted by the weighted value. Meanwhile, the direction correction parameters are restricted by constructing the target restriction condition, and the learning of the target task is favored under the condition that the auxiliary task and the target task are not in conflict.
In an alternative embodiment, the target constraint includes: a weight parameter α of the auxiliary task j Satisfies the following conditions: alpha is more than or equal to 0 j Less than or equal to C1; the direction correction parameter beta ij Satisfies the following conditions: beta is not less than 0 ij Not more than C2, and
Figure BDA0002905500090000031
wherein alpha is j Weight parameter, β, representing the jth auxiliary task ij A direction correction parameter L representing a direction of a gradient of the ith target task with respect to the jth auxiliary task p The task index representing the auxiliary task is set, C1 represents a preset privilege parameter, and C2 represents a training priority parameter of a target task, wherein C belongs to (0, 1), and the preset privilege parameter is used for representing the training priorities of the target task and the auxiliary task.
In the embodiment of the present disclosure, by setting the target constraint condition, values of weight parameters of the target task and the auxiliary task may be controlled, so that a gradient descending direction of the target task is controlled according to the values of the weight parameters. Meanwhile, the gradient descending direction of the target task can be corrected under the condition that the auxiliary task and the target task are not in conflict, so that the training process of the multi-task neural network is more inclined to learn the target task.
In an optional implementation manner, the solving the multi-objective gradient optimization model to obtain the optimization result of the variable to be optimized includes: decomposing the objective function into a plurality of sub-functions based on the constraint expression mode of the variable to be optimized in the objective constraint condition; and solving the variables to be optimized in each subfunction through a coordinate descent algorithm to obtain the weight value of each task and the parameter value of the direction correction parameter of the gradient descent direction of the target task.
In an alternative embodiment, the plurality of sub-functions includes: the device comprises a first sub-function and a second sub-function, wherein the first sub-function is a function determined based on a weight parameter of each task and a target semi-positive definite matrix, the second sub-function is a function determined based on the direction correction parameter and the target semi-positive definite matrix, and the target semi-positive definite matrix is a semi-positive definite matrix determined according to a target function.
When solving the optimization problem with constraints, the expression form of the variable to be optimized under the constraint condition will affect the solving mode of the corresponding subfunction, therefore, in the embodiment of the disclosure, the variable to be optimized is divided into two optimized modes according to the mode whether the variable to be optimized in the constraint parameters has equality constraints, so that the solving rate of the multi-objective gradient optimization model can be increased, and a more accurate solving result can be obtained.
In an optional embodiment, the determining a shared parameter of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task includes: determining a corrected gradient descending direction of the target task based on the weight value of each task and the parameters of the direction correction parameters of the gradient descending direction of the target task; updating a sharing parameter of the multitask neural network based on the initial sharing parameter of the multitask and the modified gradient descent direction.
In the embodiment of the disclosure, by correcting the shared parameters of the plurality of tasks by the weight value of each task and the parameter value of the correction parameter in the gradient descending direction of the target task, learning of the target task and the auxiliary task with preference can be realized by determining the weight value of each task, and the target task and the auxiliary task are trained with preference under the condition that the target task and the auxiliary task do not conflict in the training process, so that learning of the target task and the auxiliary task with preference is further realized.
In an optional embodiment, the method further comprises: acquiring an image to be processed; and classifying the images to be processed by adopting the trained multi-task neural network to obtain an image processing result of the images, wherein the image processing result comprises the image processing result of each task.
In an alternative embodiment, the processing object of each task in the multitask neural network is to-be-processed image data input into the multitask neural network.
In the embodiment of the disclosure, the image can be processed through the multi-task neural network after training, and for the target task concerned by the trainer, the processing precision and the processing efficiency of the target task can be improved, so that a more accurate image processing result is obtained.
In a second aspect, an embodiment of the present disclosure further provides a training apparatus for a multitask neural network, including: the acquisition unit is used for acquiring training samples and processing the training samples through a multi-task neural network to obtain a prediction result of each task; wherein the multitasking comprises: a target task and an auxiliary task; a first determining unit, configured to determine a loss function of each task according to the prediction result of each task; the construction unit is used for constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized; the solving unit is used for solving the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises: the weight value of each task and the parameter value of the gradient descending direction correction parameter of the target task; the direction correction parameter is used for representing the training priority degree of the target task; and the second determining unit is used for determining the sharing parameters of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, this disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
FIG. 1 is a flow chart illustrating a method for training a multitask neural network provided by an embodiment of the present disclosure;
FIG. 2 illustrates a slack descent diagram for a target task and an auxiliary task provided by an embodiment of the present disclosure;
FIG. 3 is a schematic diagram illustrating a gradient descent direction modification provided by an embodiment of the disclosure;
FIG. 4 is a schematic diagram illustrating a training apparatus for a multitasking neural network provided by an embodiment of the present disclosure;
fig. 5 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the disclosure, provided in the accompanying drawings, is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making any creative effort, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of a, B, and C, and may mean including any one or more elements selected from the group consisting of a, B, and C.
It has been found that in the existing multi-task learning, some tasks are often concerned by the trainer (i.e. target tasks), and the rest tasks (i.e. privileged tasks) are only used for assisting the trainer in training the concerned tasks. However, in general, in the conventional multi-task learning, which is a deep learning algorithm, a target task and an auxiliary task are usually trained together, but the importance of the target task and the importance of the auxiliary task are the same in the training process, so that the importance of the target task cannot be highlighted or the help provided by a privileged task for the target task cannot be utilized in the conventional training method, and the effect of the target task is poor.
Based on the research, the present disclosure provides a training method of a multitask neural network, in the training method, after a training sample is obtained, the training sample is processed through the multitask neural network to obtain a prediction result of each task, then a loss function of each task is determined according to the prediction result of each task, and a multi-objective gradient optimization model is further constructed according to the gradient of the loss function and a preset variable to be optimized; then, the multi-target gradient optimization model can be solved to obtain the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task. After the weight value of each task is obtained, the learning bias of each task can be determined according to the weight value, wherein the learning bias can be used for describing the training speed of the target task and the auxiliary task. Therefore, the preferred learning of the objective task and the auxiliary task can be achieved by determining the weight value of each task. Meanwhile, in the embodiment of the disclosure, by determining the parameter value of the direction correction parameter in the gradient descending direction of the target task, the training of the target task can be biased better under the condition that the target task and the auxiliary task do not conflict in the training process, so that the learning of the target task and the auxiliary task with preference is further realized. The learning of the target task can be promoted by setting the preference for learning the target task and the auxiliary task, and the learning effect of the target task in the multi-task neural network is improved.
To facilitate understanding of the present embodiment, first, a training method for a multitask neural network disclosed in the embodiments of the present disclosure is described in detail, where an execution subject of the training method for a multitask neural network provided in the embodiments of the present disclosure is generally an electronic device with certain computing power, and the electronic device includes, for example: a terminal device, which may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal Digital Assistant (PDA), a handheld device, a computing device, a vehicle mounted device, a wearable device, or a server or other processing device. In some possible implementations, the training method of the multitasking neural network may be implemented by a processor calling computer readable instructions stored in a memory.
Referring to fig. 1, a flowchart of a training method of a multitask neural network provided in an embodiment of the present disclosure is shown, where the method includes steps S101 to S107, where:
s101: acquiring a training sample, and processing the training sample through a multi-task neural network to obtain a prediction result of each task; wherein the multitasking comprises: a target task and an auxiliary task.
In the embodiment of the present disclosure, the processing object of each task in the multitask neural network is to-be-processed image data input into the multitask neural network. The target task refers to a main task concerned by the trainer, and the auxiliary task may be a task that is concerned by the trainer to a lesser degree than the target task, or the auxiliary task may be understood as a task that assists the target task in training during the training of the target task. The target task can be one, and the auxiliary tasks can be multiple.
The training samples are processed through the multi-task neural network, a plurality of prediction results can be obtained, and each task corresponds to one prediction result. For example, the multiple tasks of the multitask neural network include face detection and face recognition, and at this time, after a training sample is processed by the multitask neural network, a face detection result and a face recognition result may be obtained, where the face detection result is used to represent whether the training sample includes a face, and the face recognition result is used to represent object information to which the face included in the training sample belongs.
S103: determining a loss function of each task according to the prediction result of each task; and constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized.
In the embodiment of the disclosure, the multi-objective gradient optimization model is a multi-objective gradient optimization problem, which can be understood as a multi-objective gradient descent problem with preference. The preference is the training priority of the target task and the auxiliary task, and the training priority can understand the convergence speed of the loss function of the target task and the auxiliary task. The faster the convergence rate, the higher the training priority of the corresponding task, which may be understood as being more preferable to learn the task.
The biased learning of a plurality of tasks can be realized by the biased multi-target gradient descent problem. For example, the target task is a task concerned by a trainer, and the target task can be preferably learned through the multi-objective gradient optimization model. The learning of the target task with preference means that the value of the loss function of the target task is preferentially close to the extreme point by controlling the gradient descending direction of the loss function of the target task.
S105: solving the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises: the weight value of each task and the parameter value of the gradient descending direction correction parameter of the target task; and the direction correction parameters are used for representing the training priority degree of the target task.
In the embodiment of the present disclosure, an optimization result of a variable to be optimized may be obtained by solving the multi-objective gradient optimization model, where the optimization result includes: the weight value of each task in the multitask neural network and the parameter value of the direction correction parameter of the gradient descending direction of the target task.
In the embodiment of the present disclosure, the weight value of each task may be used to indicate the training priority of the target task and/or the auxiliary task, where the higher the weight value is, the higher the training priority of the task corresponding to the weight value is represented. In the process of learning the task, the task is trained preferentially, so that the value of the loss function of the task is controlled to be preferentially close to the extreme point (or the convergence speed of the loss function of the task is controlled to be increased).
Therefore, in the embodiment of the present disclosure, the training priority of the target task may be set by controlling the weight value of each task, for example, the target task may be trained by controlling the priority by the weight value.
In the embodiment of the present disclosure, in addition to obtaining the weight value, a parameter value of a direction correction parameter of a gradient descent direction of the target task may be obtained through solving, and then the gradient descent direction of the target task is corrected by using the parameter value of the direction correction parameter, so as to control a preference degree (i.e., a training priority degree) to the target task in a task training process.
In the process of multi-task training, if training conflict does not occur between the target task and the auxiliary task, the gradient descending direction of the target task can be corrected through the direction correction parameters, so that the convergence speed of the loss function of the target task is increased, and the target task is preferably learned.
It should be noted that, in the embodiment of the present disclosure, the fact that no training conflict occurs between the target task and the auxiliary task may be understood as: the loss function values for both the target task and the auxiliary task fall along the gradient descent direction. Conversely, the occurrence of a training conflict between the target task and the auxiliary task can be understood as: the loss function value of only one of the target task and the auxiliary task decreases in the gradient decreasing direction.
In the embodiment of the disclosure, by determining the weight value of each task, the learning of the target task can be promoted when the target task and the auxiliary task conflict; meanwhile, by determining the parameter value of the direction correction parameter, the learning of the target task can be favored when the training conflict does not occur between the target task and the auxiliary task.
S107: and determining the sharing parameters of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task.
In the embodiment of the disclosure, after the weight value of each task and the parameter value of the direction correction parameter are determined, the sharing parameter of the multitask neural network can be determined, so that the training of the multitask neural network is realized.
In the embodiment of the disclosure, after the training samples are obtained, the training samples are processed through a multi-task neural network to obtain a prediction result of each task, then a loss function of each task is determined according to the prediction result of each task, and a multi-objective gradient optimization model is further constructed according to the gradient of the loss function and a preset variable to be optimized; then, the multi-target gradient optimization model can be solved to obtain the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task. After obtaining the weight value of each task, the learning bias of each task can be determined according to the weight value, wherein the learning bias can be used for describing the training speed of the target task and the auxiliary task. Therefore, a preferred learning of the target task and the auxiliary task can be achieved by determining the weight value of each task. Meanwhile, in the embodiment of the disclosure, by determining the parameter value of the direction correction parameter in the gradient descending direction of the target task, the target task can be trained preferentially under the condition that the target task and the auxiliary task do not conflict with each other in the training process, so that the target task and the auxiliary task can be learned preferentially. The learning of the target task can be promoted by setting the preference for learning the target task and the auxiliary task, and the learning effect of the target task in the multi-task neural network is improved.
In embodiments of the present disclosure, multitasking in a multitasking neural network includes image processing tasks, including, for example, image-based recognition tasks and detection tasks, or image classification tasks that include multiple dimensions. For image data to be processed in an image processing task, matrix operations related to the image data are more, most of the matrix operations are more complex, and a plurality of image processing tasks need to consume a lot of computing resources when being processed respectively. By adopting the method provided by the embodiment of the disclosure, the gradient descent speed can be increased, so that the training efficiency of the multitask neural network is effectively improved, the consumed computing resources are reduced, and the computing efficiency of the terminal equipment is improved. In addition, the multi-task neural network obtained through training has good performance in various image processing tasks.
In an embodiment of the present disclosure, the multi-objective gradient optimization model includes: an objective function and an objective constraint, the objective function comprising: a first function and a second function, wherein the first function is used for representing the weighted sum of the gradient and the weight value of each task, and the second function is used for representing the correction direction of the gradient descending direction of the target task relative to the auxiliary task; the target constraint condition comprises the following constraint parameters: the weight parameter of each task and the direction correction parameter of the gradient descending direction of the target task.
In the disclosed embodiment, the objective function in the multi-objective gradient optimization model can be expressed as the following formula:
Figure BDA0002905500090000121
wherein the first function is expressed as->
Figure BDA0002905500090000122
A second function expressed as +>
Figure BDA0002905500090000123
In the above formula, α represents a vector representation of a weight parameter, in which a weight value of each task is contained; beta represents the vector representation of the directional correction parameters, in which vector each target task is contained with respect to the respective secondaryAnd correcting the parameters in the gradient descending direction of the auxiliary task. M represents indexes of a plurality of tasks, and M belongs to M; alpha is alpha m Represents the weight of the mth task, theta represents the sharing parameter of a plurality of tasks, and m (theta) represents the penalty function for the mth task,
Figure BDA0002905500090000125
represents the loss function l m A gradient of (θ); beta is a beta ij A direction correction parameter, L, representing a gradient descent direction of the ith target task relative to the jth auxiliary task t Index set, L, representing target tasks p Set of indices representing auxiliary tasks,/ i (θ) represents the penalty function for the ith target task, l j (θ) represents a loss function for the jth auxiliary task, based on the value of the variable sum>
Figure BDA0002905500090000126
Representing a loss function l i (theta) gradient,. ANG->
Figure BDA0002905500090000127
Representing a loss function l j A gradient of (θ).
In the embodiment of the present disclosure, the target constraint condition of the multi-target gradient optimization model is a constraint condition constructed based on the weight parameter of each task and the direction correction parameter of the gradient descending direction of the target task. By adopting the method of solving the objective function by adopting the objective constraint condition, the dynamic solution of the weighted value of each task can be realized, so that the multi-task learning is realized preferentially, and the learning of the objective task is promoted by the weighted value when the auxiliary task and the objective task conflict. Meanwhile, the direction correction parameters are restricted by constructing the target restriction condition, and the learning of the target task is favored under the condition that the auxiliary task and the target task are not in conflict.
In an alternative embodiment, the target constraint includes: weight parameter alpha of auxiliary task j Satisfies the following conditions: alpha is more than or equal to 0 j Less than or equal to C1; the direction correction parameter beta ij Satisfies the following conditions: beta is not less than 0 ij Not more than C2, and
Figure BDA0002905500090000124
wherein alpha is j Weight parameter, β, representing the jth auxiliary task ij A direction correction parameter L representing a direction of a gradient of the ith target task with respect to the jth auxiliary task p The task index representing the auxiliary task is set, C1 represents a preset privilege parameter, and C2 represents a training priority parameter of a target task, wherein C belongs to (0, 1), and the preset privilege parameter is used for representing the training priorities of the target task and the auxiliary task. In the embodiment of the present disclosure, the preset privilege parameter is used for controlling the gradient descending direction of the target task by controlling the value of the weight parameter.
In general, the above target constraint can be expressed as the following formula:
Figure BDA0002905500090000131
in the embodiment of the present disclosure, C1 represents a preset privilege parameter, a value of C1 is a preset value, and a weight value of each task can be controlled by controlling the value of C1, which is described below with reference to fig. 2. Fig. 2 is a schematic diagram showing the slack descent of the target task and the auxiliary task. As can be seen from FIG. 2, assume that α 1 Is a weight value of the target task, alpha 2 Is the weight value of the auxiliary task. When the value of C1 is small (e.g., C1= 0.2), the weight value α of the target task 1 Weight value alpha greater than auxiliary task 2 . At this time, it can be shown that when learning the target task and the auxiliary task, the target task can be preferentially learned with preference. When the value of C1 is large (e.g., C1= 1), the weight value α of the auxiliary task 2 Weight value alpha greater than target task 1 . At this time, it can be shown that there is a preference to preferentially learn the privileged task when learning the target task and the auxiliary task. Therefore, in the embodiment of the present disclosure, by setting the preset privilege parameter in advance, the target task may be controlledAnd the value of the weight parameter of the auxiliary task, so that the gradient descending direction of the target task is controlled according to the value of the weight parameter.
In the embodiment of the present disclosure, as can be seen from the above description, in the case that the auxiliary task and the target task do not conflict, the gradient descending direction of the target task may also be corrected, so that the training process of the multitask neural network is more biased to learning the target task. Fig. 3 is a schematic diagram illustrating a correction in the gradient descending direction. Let us assume, α 1 Is a weight value of the target task, alpha 2 Is the weight value of the auxiliary task.
Figure BDA0002905500090000132
Is the gradient falling direction of the target task, is greater than>
Figure BDA0002905500090000133
The direction of gradient descent of the assist task is the direction of gradient descent of the assist task, and the direction of gradient descent of the target task can be corrected when the loss functions of both the assist task and the target task descend along the corresponding direction of gradient descent. When the gradient descending direction of the target task is corrected, the gradient descending direction of the target task can be increased>
Figure BDA0002905500090000141
To make the correction. The gradient descending direction of the target task can be further pushed to the target task by correcting the gradient descending direction of the target task, so that the loss function of the target task is preferentially close to the extreme point. For example, as shown in FIG. 3, may be based on a formula->
Figure BDA0002905500090000142
And correcting the gradient descending direction of the target task. As can be seen from FIG. 3, after correction of the direction of gradient decrease of the target task, a decision is made as to whether a value is greater or less than the predetermined value>
Figure BDA0002905500090000143
And
Figure BDA0002905500090000144
the vector sum of (2) is close to the target task, so that the gradient descending direction of the target task is increased, and at the moment, the gradient descending direction is pushed to the target task. Wherein, beta 12 And the direction correction parameters are used for representing the training priority degree of the target task. In the embodiment of the present disclosure, the value of the direction correction parameter may be controlled by C2, so that the learning preference of the target task and the auxiliary task is controlled by C2.
It should be understood that the physical meanings of the training priority and the training preference are not the same. The training priority refers to a priority order of the target task and the auxiliary task in the training process, for example, the training priority of the target task is higher than that of the auxiliary task, so that the target task is preferentially trained in the training process of the target task and the auxiliary task. The training priority level is a training priority level of a task with a high training priority level relative to a task with a low training priority level when the training priority level is determined. For example, as shown in FIG. 2, if the weight value of the target task is α 1 Weight value alpha greater than auxiliary task 2 Then it indicates that the training priority of the target task is higher than the training priority of the auxiliary task. As shown in the figure 3 of the drawings,
Figure BDA0002905500090000145
and &>
Figure BDA0002905500090000146
The vector sum of (2) can represent the training priority of the target task relative to the auxiliary task when the training priority of the target task is higher than the training priority of the auxiliary task, and as can be seen from fig. 3, the larger the vector sum, the larger the training priority of the target task relative to the auxiliary task, and the smaller the vector sum, the smaller the training priority of the target task relative to the auxiliary task.
After describing the specific structure of the multi-objective gradient optimization model, the construction process of the multi-objective gradient optimization model and the solving process of the multi-objective gradient optimization model will be described in the following embodiments.
The first step is the construction process of the multi-objective gradient optimization model.
In embodiments of the present disclosure, a multi-task learning problem is transformed into a multi-objective optimization problem. Assuming that the number of multitask is M, the index of the task is set to L, and the sharing parameter of the multitask neural network is represented as theta. As shown in FIG. 3, in the disclosed embodiment, the objective of the multi-objective optimization problem is to determine the objective after task modification
Figure BDA0002905500090000153
And &>
Figure BDA0002905500090000154
And d.
Based on this, after the correction of the target task can be determined by the following minimization problem
Figure BDA0002905500090000155
And &>
Figure BDA0002905500090000156
D:
the formula I is as follows:
Figure BDA0002905500090000151
where v represents the variable to be optimized.
Next, the dual problem of equation one above can be determined, depicted as equation two:
Figure BDA0002905500090000152
α m represents a weight value of the mth task>
Figure BDA0002905500090000157
Representing the gradient of the loss function for the mth task. For the second formula, a Pareto optimal solution of the second formula can be determined, so that the weight value of each task is determined according to the Pareto optimal solution.
In bookIn the disclosed embodiment, in order to realize the learning with preference on the target task, the auxiliary task can be applied to the learning process of the target task. For the inequality constraint in the above formula one, the following inequality constraint may be modified:
Figure BDA0002905500090000158
wherein it is present>
Figure BDA0002905500090000159
A gradient of a loss function representing the target task,
Figure BDA00029055000900001510
representing the gradient of the loss function of the auxiliary task. The gradient descending direction of the auxiliary task can be smaller than v through the inequality constraint, and the inequality constraint is as follows: />
Figure BDA00029055000900001511
And &>
Figure BDA00029055000900001512
And respectively restricting the convergence speed of the gradient descent of the target task and the convergence speed of the gradient descent of the auxiliary task. Wherein, when the auxiliary task and the target task conflict, the judgment can be carried out by modifying inequality constraint->
Figure BDA00029055000900001513
The convergence speed of the gradient decline of the auxiliary task is controlled, so that the convergence speed of the gradient decline of the auxiliary task is reduced. At this time, the relaxation variable ξ may be set i In order to reduce the convergence speed of the gradient descent of the auxiliary task, where ξ i >0. Thus, the inequality can be bound +>
Figure BDA00029055000900001514
The modification is as follows: />
Figure BDA00029055000900001515
For the dual problem described in equation two, the following constraints are also included:
Figure BDA0002905500090000164
where C1 is a default privilege parameter. The weight value of each task can be controlled by C1.
In the embodiment of the present disclosure, when there is no conflict between the target task and the auxiliary task, in order to increase the convergence rate of the gradient descent of the target task, the gradient descent direction of the target task may also be modified, and at this time, the following constraint conditions may be set:
Figure BDA0002905500090000165
to properly relax this constraint, a learnable relaxation variable η is also introduced ij >0. At this time, the constraint: />
Figure BDA0002905500090000166
Can be modified into the following steps:
Figure BDA0002905500090000167
as can be seen from the above description, in the embodiment of the present disclosure, the multi-objective gradient optimization model may be composed of two parts: a slack descent part of the auxiliary task and a gradient direction modification part of the target task. Based on the two parts, the multi-objective gradient optimization model can be described as a structure described by the following formula three:
Figure BDA0002905500090000161
in the multi-objective gradient optimization model described above,
Figure BDA0002905500090000162
for adjusting the amount of privilege an auxiliary task can attain, i.e. to the extent that the auxiliary task can be ignored during training, be asserted>
Figure BDA0002905500090000163
The degree of learning the target task with priority when the loss functions of the auxiliary task and the target task both fall in the gradient direction is expressed to accelerate the convergence rate of the gradient fall of the target task.
Aiming at the third formula, the dual problem of the problem is formalized into a fourth formula by using a Lagrange multiplier:
Figure BDA0002905500090000171
as can be seen from the above description, in the embodiment of the present disclosure, learning of the target task and the auxiliary task with preference can be achieved by determining the weight value of each task. Meanwhile, in the embodiment of the disclosure, by determining the parameter value of the direction correction parameter in the gradient descending direction of the target task, the target task can be trained preferentially under the condition that the target task and the auxiliary task do not conflict with each other in the training process, so that the target task and the auxiliary task can be learned preferentially. The learning of the target task can be promoted by setting the preference for learning the target task and the auxiliary task, and the learning effect of the target task in the multitask neural network is improved.
And secondly, solving the multi-target gradient optimization model.
In the embodiment of the present disclosure, after the multi-objective gradient optimization model is constructed in the manner described above, the multi-objective gradient optimization model may be solved.
In an optional implementation manner of the embodiment of the present disclosure, step S105, solving the multi-objective gradient optimization model to obtain an optimization result of the variable to be optimized, includes:
performing multi-target solution on the target function based on the target constraint condition to obtain a pareto solution; and determining the weight value of each task and the parameter value of the direction correction parameter of the descending direction of the gradient of the target task according to the pareto solution.
In the embodiment of the disclosure, a multi-objective solving method may be adopted to solve the objective function, so as to obtain the pareto solution. Wherein paretolysin comprises: the weight value α of each task and the parameter value β of the direction correction parameter in the falling direction of the gradient of the target task.
The problem of finding a pareto solution can be translated into a constrained quadratic optimization problem by lagrange multipliers. In the embodiment of the disclosure, a hybrid block optimization algorithm is designed through an expression mode of constraint parameters in a target constraint condition. In the hybrid block optimization algorithm, the optimization variables are divided into two blocks to be optimized respectively according to whether the optimization variables in the constraint parameters have equality constraint or not.
In an optional embodiment, solving the multi-objective gradient optimization model to obtain an optimization result of the variable to be optimized includes:
(1) Decomposing the objective function into a plurality of sub-functions based on the constraint expression mode of the variable to be optimized in the objective constraint condition;
(2) And solving the variable to be optimized in each subfunction through a coordinate descent algorithm to obtain the weight value of each task and the parameter value of the direction correction parameter of the gradient descent direction of the target task.
In the embodiment of the disclosure, the constraint condition about the variable to be optimized can be determined in the target constraint condition, and then whether equality constraint is included is determined according to the constraint condition of the variable to be optimized, so that the algorithm divides the variable to be optimized into two blocks to be optimized respectively according to whether equality constraint exists in the variable to be optimized in the constraint parameter. Wherein, the variable to be optimized can be understood as the variable to be solved by the multi-objective gradient optimization model.
According to the content described by the formula four, the weight parameter of each task in the variable to be optimized contains equality constraint, and the direction correction parameter in the variable to be optimized does not contain equality constraint, so that the weight parameter and the direction correction parameter can be divided into two parts to be optimized respectively. At this time, the formula four may be split into a plurality of subfunctions, and then each subfunction is solved by a coordinate descent algorithm to obtain a weight value of each task and a parameter value of a direction correction parameter of a gradient descent direction of the target task.
When solving the optimization problem with constraints, the expression form of the constraints affects the solving mode of the corresponding subfunction, so that in the embodiment of the disclosure, the algorithm divides the variable to be optimized into two optimized modes according to whether the variable to be optimized in the constraint parameters has equality constraints, so that the solving rate of the multi-objective gradient optimization model can be increased, and a more accurate solving result can be obtained.
In an embodiment of the present disclosure, the plurality of sub-functions includes: the device comprises a first sub-function and a second sub-function, wherein the first sub-function is a function determined based on a weight parameter of each task and a target semi-positive definite matrix, the second sub-function is a function determined based on the direction correction parameter and the target semi-positive definite matrix, and the target semi-positive definite matrix is a semi-positive definite matrix determined according to a target function. .
In the disclosed embodiment, the first sub-function may be expressed as:
Figure BDA0002905500090000191
in the disclosed embodiment, the second sub-function may be expressed as:
Figure BDA0002905500090000192
in the embodiment of the present disclosure, Q is expressed as a target semi-positive determination matrix, and the determination process of Q may be expressed as:
for the above equation three, it is assumed that,
Figure BDA0002905500090000193
and is
Figure BDA0002905500090000194
In this case, the formula III can be rewritten as:
Figure BDA0002905500090000195
To the above
Figure BDA0002905500090000196
It can be understood that: a first matrix consisting of alpha and beta, multiplied by a second matrix and further multiplied by the first matrix consisting of alpha and beta, that is to say, the formula->
Figure BDA0002905500090000197
Can be converted into: and multiplying the first matrix by the second matrix by the first matrix, wherein the second matrix is the target semi-positive definite matrix Q.
In the embodiment of the present disclosure, after the multi-objective gradient optimization model is solved in the manner described above, and the weight value of each task and the parameter value of the direction correction parameter of the gradient descent direction of the target task are obtained, the shared parameter of the multi-task neural network may be determined based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descent direction of the target task.
In an alternative embodiment, in step S107, determining a shared parameter of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task, includes:
(1) And determining the corrected gradient descending direction of the target task based on the weight value of each task and the parameters of the direction correction parameters of the gradient descending direction of the target task.
In the embodiment of the present disclosure, the modified gradient descent direction of the target task may be calculated by a formula:
Figure BDA0002905500090000203
. Wherein it is present>
Figure BDA0002905500090000205
And is and
Figure BDA0002905500090000204
(2) And updating the shared parameters of the multitask neural network based on the initial shared parameters of the tasks and the corrected gradient descent direction.
After the corrected gradient descent direction of the target task is determined, the shared parameters of the multitask neural network can be updated according to a formula:
Figure BDA0002905500090000206
in the embodiment of the present disclosure, besides the shared parameter needs to be updated, the private parameter of each task may also be updated, and for each task, the gradient of each task may be calculated by a formula:
Figure BDA0002905500090000201
thereafter, the private parameters for each task may be updated according to the formula: />
Figure BDA0002905500090000202
In the embodiment of the disclosure, in the process of training the multitask neural network, if there are a plurality of training samples, the training samples may be firstly batch-processed to obtain a plurality of groups of training samples, and then the multitask neural network is trained by adopting a batch mini-batch processing mode.
Therefore, in the embodiment of the present disclosure, for each batch, if it is determined that the loss function value of each task converges to the preset threshold, or the number of times of adjusting the network parameter of the multitask neural network reaches the preset number, the current batch is ended, and the next batch of training samples is updated, so as to enter the next batch process.
In the embodiment of the present disclosure, after the multitask neural network is trained and obtained according to the above-described manner, the image to be processed may be obtained; then, classifying the images to be processed by adopting the trained multitask neural network to obtain an image processing result of the images, wherein the image processing result comprises the image processing result of each task.
It will be understood by those of skill in the art that in the above method of the present embodiment, the order of writing the steps does not imply a strict order of execution and does not impose any limitations on the implementation, as the order of execution of the steps should be determined by their function and possibly inherent logic.
Based on the same inventive concept, the embodiment of the present disclosure further provides a training apparatus for a multi-task neural network corresponding to the training method for the multi-task neural network, and as the principle of the apparatus in the embodiment of the present disclosure for solving the problem is similar to the training method for the multi-task neural network described above in the embodiment of the present disclosure, the implementation of the apparatus may refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 4, a schematic diagram of a training apparatus for a multitask neural network provided in an embodiment of the present disclosure is shown, where the apparatus includes: the system comprises an acquisition unit 41, a first determination unit 42, a construction unit 43, a solving unit 44 and a second determination unit 45; wherein the content of the first and second substances,
the acquiring unit 41 is configured to acquire a training sample, and process the training sample through a multi-task neural network to obtain a prediction result of each task; the multitasking comprises the following steps: a target task and an auxiliary task;
a first determining unit 42, configured to determine a loss function of each task according to the prediction result of each task;
a constructing unit 43, configured to construct a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized;
the solving unit 44 is configured to solve the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises: the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task; the direction correction parameter is used for representing the training priority degree of the target task;
a second determining unit 45, configured to determine a shared parameter of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task.
In the embodiment of the disclosure, the learning bias of each task can be determined according to the weight value by determining the weight value of each task, wherein the learning bias can be used for describing the training speed of the target task and the auxiliary task. Therefore, a preferred learning of the target task and the auxiliary task can be achieved by determining the weight value of each task. Meanwhile, in the embodiment of the disclosure, by determining the parameter value of the direction correction parameter in the gradient descending direction of the target task, the training of the target task can be biased better under the condition that the target task and the auxiliary task do not conflict in the training process, so that the learning of the target task and the auxiliary task with preference is further realized. The learning of the target task can be promoted by setting the preference for learning the target task and the auxiliary task, and the learning effect of the target task in the multi-task neural network is improved.
In a possible embodiment, the solving unit 44 is configured to: performing multi-target solution on the target function based on a target constraint condition to obtain a pareto solution; and determining the weight value of each task and the parameter value of the direction correction parameter of the descending direction of the gradient of the target task according to the pareto solution.
In one possible embodiment, the multi-objective gradient optimization model includes: an objective function and an objective constraint, the objective function comprising: a first function and a second function, wherein the first function is used for representing the weighted sum of the gradient and the weight value of each task, and the second function is used for representing the correction direction of the target task relative to the gradient descending direction of the auxiliary task; the target constraint condition comprises the following constraint parameters: the weight parameter of each task and the direction correction parameter of the gradient descending direction of the target task.
In one possible embodiment, the target constraints include: a weight parameter α of the auxiliary task j Satisfies the following conditions: alpha is more than or equal to 0 j Less than or equal to C1; the direction correction parameter beta ij Satisfies the following conditions: beta is not less than 0 ij Not more than C2, and
Figure BDA0002905500090000221
wherein alpha is j Weight parameter, β, representing the jth auxiliary task ij A direction correction parameter L representing a direction of a gradient of the ith target task with respect to the jth auxiliary task p The task index representing the auxiliary task is set, C1 represents a preset privilege parameter, and C2 represents a training priority parameter of a target task, wherein C belongs to (0, 1), and the preset privilege parameter is used for representing the training priorities of the target task and the auxiliary task.
In a possible embodiment, the solving unit 44 is further configured to: decomposing the objective function into a plurality of sub-functions based on the constraint expression mode of the variable to be optimized in the objective constraint condition; and solving the variable to be optimized in each subfunction through a coordinate descent algorithm to obtain a weight value of each task and a parameter value of a direction correction parameter of the gradient descent direction of the target task.
In one possible implementation, the plurality of sub-functions includes: the first sub-function is a function determined based on a weight parameter of each task and a target semi-positive definite matrix, the second sub-function is a function determined based on the direction correction parameter and the target semi-positive definite matrix, and the target semi-positive definite matrix is a semi-positive definite matrix determined according to a target function. .
In a possible implementation, the second determining unit 45 is further configured to: determining a corrected gradient descending direction of the target task based on the weight value of each task and the parameters of the direction correction parameters of the gradient descending direction of the target task; updating a sharing parameter of the multitask neural network based on the initial sharing parameter of the plurality of tasks and the modified gradient descent direction.
In one possible embodiment, the apparatus is further configured to: acquiring an image to be processed; and classifying the images to be processed by adopting the trained multi-task neural network to obtain an image processing result of the images, wherein the image processing result comprises the image processing result of each task.
In an alternative embodiment, the processing object of each task in the multitask neural network is to-be-processed image data input into the multitask neural network.
Corresponding to the training method of the multitask neural network in fig. 1, an embodiment of the present disclosure further provides an electronic device 500, and as shown in fig. 5, a schematic structural diagram of the electronic device 500 provided in the embodiment of the present disclosure includes:
a processor 51, a memory 52, and a bus 53; the storage 52 is used for storing execution instructions and includes a memory 521 and an external storage 522; the memory 521 is also referred to as an internal memory, and is configured to temporarily store the operation data in the processor 51 and the data exchanged with the external memory 522 such as a hard disk, the processor 51 exchanges data with the external memory 522 through the memory 521, and when the electronic device 500 operates, the processor 51 and the memory 52 communicate with each other through the bus 53, so that the processor 51 executes the following instructions:
acquiring a training sample, and processing the training sample through a multi-task neural network to obtain a prediction result of each task; wherein the multitasking comprises: a target task and an auxiliary task; determining a loss function of each task according to the prediction result of each task, and constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized; solving the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises: the weight value of each task and the parameter value of the gradient descending direction correction parameter of the target task; the direction correction parameter is used for representing the training priority degree of the target task; and determining the sharing parameters of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task.
The embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, performs the steps of the training method for a multitask neural network described in the above method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure further provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute the steps of the training method described in the foregoing method embodiments, which may be specifically referred to in the foregoing method embodiments and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, but not to limit the technical solutions, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes and substitutions do not depart from the spirit and scope of the embodiments disclosed herein, and they should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (11)

1. A method for training a multitask neural network, comprising:
acquiring a training sample, and processing the training sample through a multi-task neural network to obtain a prediction result of each task; wherein the multitasking comprises: a target task and an auxiliary task; the processing object of each task in the multitask neural network is image data to be processed input into the multitask neural network, the target task comprises one of face detection and face recognition, and the auxiliary task comprises the other of face detection and face recognition;
determining a loss function of each task according to the prediction result of each task, and constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized;
solving the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises: the weight value of each task and the parameter value of the gradient descending direction correction parameter of the target task; the direction correction parameter is used for representing the training priority degree of the target task; the weight value of each task can be used for indicating a training priority of a target task and/or an auxiliary task, and the training priority is used for indicating the convergence speed of the loss function of the target task and the auxiliary task;
determining a sharing parameter of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task;
and performing synchronous face detection and face recognition on the image to be processed by adopting the multitask neural network determined by the multi-round sharing parameters to obtain a face detection result and a face recognition result of the image to be processed.
2. The method according to claim 1, wherein solving the multi-objective gradient optimization model to obtain the optimization result of the variable to be optimized comprises:
performing multi-target solution on the target function based on the target constraint condition to obtain a pareto solution;
and determining the weight value of each task and the parameter value of the direction correction parameter of the descending direction of the gradient of the target task according to the pareto solution.
3. The method of claim 1 or 2, wherein the multi-objective gradient optimization model comprises: an objective function and an objective constraint condition;
the objective function includes: a first function and a second function, wherein the first function is used for representing the weighted sum of the gradient and the weight value of each task, and the second function is used for representing the correction direction of the target task relative to the gradient descending direction of the auxiliary task;
the target constraint condition comprises the following constraint parameters: the weight parameter of each task and the direction correction parameter of the gradient descending direction of the target task.
4. The method of claim 3, wherein the target constraints comprise:
a weight parameter α of the auxiliary task j Satisfies the following conditions: alpha is more than or equal to 0 j Less than or equal to C1; the direction correction parameter beta ij Satisfies the following conditions: beta is not less than 0 ij Less than or equal to C2, and
Figure FDA0004001213880000021
wherein alpha is j Weight parameter, β, representing the jth auxiliary task ij A direction correction parameter L representing a direction of a gradient of the ith target task with respect to the jth auxiliary task p A set of task indices representing auxiliary tasks, C1 representing a preset privilege parameter, and C2 representing a training priority parameter of a target task, wherein C ∈ (0, 1), and the preset privilege parameter is used for characterizing the target task and the auxiliary taskThe training priority of (2).
5. The method according to claim 3, wherein solving the multi-objective gradient optimization model to obtain the optimization result of the variable to be optimized comprises:
decomposing the objective function into a plurality of sub-functions based on the constraint expression mode of the variable to be optimized in the objective constraint condition;
and solving the variable to be optimized in each subfunction through a coordinate descent algorithm to obtain a weight value of each task and a parameter value of a direction correction parameter of the gradient descent direction of the target task.
6. The method of claim 5, wherein the plurality of sub-functions comprises: the first sub-function is a function determined based on a weight parameter of each task and a target semi-positive definite matrix, the second sub-function is a function determined based on the direction correction parameter and the target semi-positive definite matrix, and the target semi-positive definite matrix is a semi-positive definite matrix determined according to a target function.
7. The method according to any one of claims 1 to 6, wherein the determining the shared parameter of the multitask neural network based on the weight value of each task and the parameter value of the direction correction parameter of the gradient descending direction of the target task comprises:
determining a corrected gradient descending direction of the target task based on the weight value of each task and the parameters of the direction correction parameters of the gradient descending direction of the target task;
updating a sharing parameter of the multitask neural network based on the initial sharing parameter of the multitask and the modified gradient descent direction.
8. The method according to any one of claims 1 to 7, further comprising:
acquiring an image to be processed;
and classifying the images to be processed by adopting the trained multi-task neural network to obtain an image processing result of the images, wherein the image processing result comprises the image processing result of each task.
9. An apparatus for training a multitask neural network, comprising:
the device comprises an acquisition unit, a prediction unit and a prediction unit, wherein the acquisition unit is used for acquiring a training sample and processing the training sample through a multi-task neural network to obtain a prediction result of each task; wherein the multitasking comprises: a target task and an auxiliary task; the processing object of each task in the multitask neural network is image data to be processed which is input into the multitask neural network, the target task comprises one of face detection and face recognition, and the auxiliary task comprises the other of face detection and face recognition;
a first determining unit, configured to determine a loss function of each task according to the prediction result of each task;
the construction unit is used for constructing a multi-objective gradient optimization model based on the gradient of the loss function and a preset variable to be optimized;
the solving unit is used for solving the multi-target gradient optimization model to obtain an optimization result of the variable to be optimized; the optimization result comprises: the weight value of each task and the parameter value of the gradient descending direction correction parameter of the target task; the direction correction parameter is used for representing the training priority degree of the target task; the weight value of each task can be used for indicating a training priority of a target task and/or an auxiliary task, and the training priority is used for indicating the convergence speed of the loss function of the target task and the auxiliary task;
and the second determination unit is used for determining the sharing parameters of the multitask neural network based on the weight value of each task and the parameter values of the direction correction parameters of the gradient descending direction of the target task, and performing synchronous face detection and face recognition on the image to be processed by adopting the multitask neural network determined by multiple rounds of sharing parameters to obtain the face detection result and the face recognition result of the image to be processed.
10. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the method of training a multitasking neural network according to any one of claims 1 to 8.
11. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method of training a multitask neural network according to any one of claims 1 to 8.
CN202110069465.2A 2021-01-19 2021-01-19 Training method and device for multitask neural network, electronic equipment and storage medium Active CN112766493B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110069465.2A CN112766493B (en) 2021-01-19 2021-01-19 Training method and device for multitask neural network, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110069465.2A CN112766493B (en) 2021-01-19 2021-01-19 Training method and device for multitask neural network, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112766493A CN112766493A (en) 2021-05-07
CN112766493B true CN112766493B (en) 2023-04-07

Family

ID=75703208

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110069465.2A Active CN112766493B (en) 2021-01-19 2021-01-19 Training method and device for multitask neural network, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112766493B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113506270B (en) * 2021-07-13 2022-04-12 北京建筑大学 Method, system and storage medium for processing inferior vena cava image
US11527074B1 (en) * 2021-11-24 2022-12-13 Continental Automotive Technologies GmbH Systems and methods for deep multi-task learning for embedded machine vision applications
CN114494817A (en) * 2022-01-26 2022-05-13 北京百度网讯科技有限公司 Image processing method, model training method, related device and electronic equipment
CN114860405B (en) * 2022-05-17 2023-01-31 北京百度网讯科技有限公司 Parameter updating method and device of multitask model and storage medium
WO2024103291A1 (en) * 2022-11-16 2024-05-23 华为技术有限公司 Federated learning method and communication apparatus

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117953A (en) * 2018-09-11 2019-01-01 北京迈格威科技有限公司 Network parameter training method and system, server, client and storage medium
WO2019169816A1 (en) * 2018-03-09 2019-09-12 中山大学 Deep neural network for fine recognition of vehicle attributes, and training method thereof
CN110892418A (en) * 2017-05-19 2020-03-17 渊慧科技有限公司 Multitasking neural network system
CN112183750A (en) * 2020-11-05 2021-01-05 平安科技(深圳)有限公司 Neural network model training method and device, computer equipment and storage medium
CN112232407A (en) * 2020-10-15 2021-01-15 杭州迪英加科技有限公司 Neural network model training method and device for pathological image sample
WO2021007812A1 (en) * 2019-07-17 2021-01-21 深圳大学 Deep neural network hyperparameter optimization method, electronic device and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8041545B2 (en) * 2005-04-28 2011-10-18 Vladimir Sevastyanov Gradient based methods for multi-objective optimization

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110892418A (en) * 2017-05-19 2020-03-17 渊慧科技有限公司 Multitasking neural network system
WO2019169816A1 (en) * 2018-03-09 2019-09-12 中山大学 Deep neural network for fine recognition of vehicle attributes, and training method thereof
CN109117953A (en) * 2018-09-11 2019-01-01 北京迈格威科技有限公司 Network parameter training method and system, server, client and storage medium
WO2021007812A1 (en) * 2019-07-17 2021-01-21 深圳大学 Deep neural network hyperparameter optimization method, electronic device and storage medium
CN112232407A (en) * 2020-10-15 2021-01-15 杭州迪英加科技有限公司 Neural network model training method and device for pathological image sample
CN112183750A (en) * 2020-11-05 2021-01-05 平安科技(深圳)有限公司 Neural network model training method and device, computer equipment and storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Ozan Sener等.Multi-Task Learning as Multi-Objective Optimization.《arXiv》.2018,第1-15页. *
Zhao Chen等.GradNorm: Gradient Normalization for Adaptive Loss Balancing in Deep Multitask Networks.《arXiv》.2018,第1-12页. *
丁我爱.梯度⼿术-多任务学习优化⽅法[NeurIPS 2020].《https://zhuanlan.zhihu.com/p/338553869》.2020,第1-12页. *
刘建军等.基于模型的多目标优化问题方法研究.《系统仿真学报》.2020,第2138-2145. *

Also Published As

Publication number Publication date
CN112766493A (en) 2021-05-07

Similar Documents

Publication Publication Date Title
CN112766493B (en) Training method and device for multitask neural network, electronic equipment and storage medium
Muhuri et al. On arrival scheduling of real-time precedence constrained tasks on multi-processor systems using genetic algorithm
CN111738488A (en) Task scheduling method and device
CN109144719A (en) Cooperation discharging method based on markov decision process in mobile cloud computing system
CN117153260B (en) Spatial transcriptome data clustering method, device and medium based on contrast learning
CN111343259B (en) Binary code-based cloud task scheduling method, server and storage medium
CN114675975B (en) Job scheduling method, device and equipment based on reinforcement learning
CN108229536A (en) Optimization method, device and the terminal device of classification prediction model
Li et al. Satisfying optimization method based on goal programming for fuzzy multiple objective optimization problem
CN112819157A (en) Neural network training method and device and intelligent driving control method and device
CN109325530A (en) Compression method based on the depth convolutional neural networks on a small quantity without label data
CN115714820A (en) Distributed micro-service scheduling optimization method
CN116257363A (en) Resource scheduling method, device, equipment and storage medium
CN113705929B (en) Spring festival holiday load prediction method based on load characteristic curve and typical characteristic value fusion
Abbasi Yadkori et al. Near minimax optimal players for the finite-time 3-expert prediction problem
Liu et al. Quantum-inspired African vultures optimization algorithm with elite mutation strategy for production scheduling problems
CN112965813B (en) AI platform resource regulation and control method, system and medium
CN110867224B (en) Multi-granularity Spark super-trust fuzzy method for large-scale brain pathology segmentation
CN117011118A (en) Model parameter updating method, device, computer equipment and storage medium
Guan et al. HierRL: Hierarchical reinforcement learning for task scheduling in distributed systems
WO2022057459A1 (en) Tensorcore-based int4 data type processing method and system, device, and medium
Li et al. Global Opposition Learning and Diversity ENhancement based Differential Evolution with exponential crossover for numerical optimization
CN114064235A (en) Multitask teaching and learning optimization method, system and equipment
de Freitas Cunha et al. On the impact of MDP design for reinforcement learning agents in resource management
Deng et al. Sample Complexity Characterization for Linear Contextual MDPs

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant