Training method of agricultural multi-task model
Through dynamic adjustment and knowledge sharing mechanism to improve the performance of agricultural multi -tasking models, solve the problem of insufficient multi -tasking collaborative processing capabilities in traditional models in complex environments, and achieve efficient and intelligent decision -making.
Patent Information
- Application Number
- CN202411421560.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The traditional multi-task model lacks dynamic weight adjustment and knowledge sharing mechanisms in agricultural production, resulting in limited performance and difficulty in effectively coping with the needs of collaborative processing of multiple tasks in complex environments.
By dynamically adjust the weight of the sub -mission layers, and use the knowledge sharing mechanism between the sub -task layer to improve the performance of the agricultural multi -tasking model. Specific methods include the initial weight of target task complexity and historical performance scores, dynamically adjust weights, and allocate computing resources, use cross -task feature distillation technology for knowledge migration, comprehensively evaluate and optimize the performance of sub -task layers.
The efficient and intelligent decision -making of agricultural multi -tasking models in the complex agricultural environment has been realized, and the overall performance and generalization of the model have been improved.
Smart Images

Figure CN119338027A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural informatization and artificial intelligence technology, and in particular to a training method for an agricultural multi-task model. Background Art
[0002] In agricultural production, the application of intelligent technology is becoming more and more widespread. Traditional multi-task models usually rely on fixed weight distribution and lack dynamic adjustment capabilities, which limits the overall performance of multi-task models. In addition, in the process of processing multiple tasks, traditional multi-task models cannot fully utilize the advantages of related tasks due to insufficient knowledge sharing between multiple tasks, which limits the generalization ability of multi-task models. In other words, traditional multi-task models are difficult to effectively cope with the needs of collaborative processing of multiple tasks in complex environments. Summary of the invention
[0003] In response to the above problems, the present invention provides a training method for an agricultural multi-task model, which can improve the performance of the agricultural multi-task model by dynamically adjusting the weights of each sub-task layer and utilizing the knowledge sharing mechanism between sub-task layers, thereby ensuring the high efficiency of the intelligent decision-making of the agricultural multi-task model in a complex and changeable agricultural environment.
[0004] The technical solution of the present invention to solve the above technical problems is as follows:
[0005] The present invention provides a training method for an agricultural multi-task model, which is applied to the agricultural multi-task model, wherein the agricultural multi-task model includes multiple sub-task layers, and one sub-task layer is used to process one task. In the method, for a first sub-task layer, an initial weight of the first sub-task layer is set based on the complexity of a target task and a historical performance score corresponding to the first sub-task layer; the first sub-task layer is any sub-task layer among the multiple sub-task layers; the first sub-task layer is used to process the target task. Based on the initial weight of the first sub-task layer, computing resources are allocated to the first sub-task layer, and a training data set corresponding to the target task is input to the first sub-task layer; the training data set corresponding to the target task includes multiple training data. For any training data input to the first sub-task layer, a loss function corresponding to the first sub-task layer is determined based on the output of the first sub-task layer. Based on the initial weight, loss function and learning rate corresponding to the first sub-task layer, the weight corresponding to the first sub-task layer is adjusted. Based on the adjusted weights of each of the sub-task layers, computing resources are allocated to each of the sub-task layers.
[0006] Based on the above technical solution, the present invention can also be improved as follows.
[0007] Furthermore, the initial weight of the first subtask layer is set based on the complexity of the target task, the historical performance score corresponding to the first subtask layer, and a first preset rule. The first preset rule is:
[0008]
[0009] in, is the initial weight of the first subtask layer, α is the first preset adjustment coefficient, β is the second preset adjustment coefficient, C i is the complexity of the target task, H i Score the historical performance corresponding to the first subtask layer.
[0010] Further, based on the initial weight, loss function, learning rate and second preset rule corresponding to the first subtask layer, a target weight is determined. Based on the target weight, the weight corresponding to the first subtask layer is adjusted. The second preset rule is:
[0011]
[0012] in, is the target weight, is the initial weight corresponding to the first subtask layer, η is the learning rate corresponding to the first subtask layer, L i is the loss function corresponding to the first subtask layer.
[0013] Furthermore, the higher the weight corresponding to the first subtask layer after adjustment, the higher the computing resources allocated to the first subtask layer.
[0014] Further, for the first subtask layer, the processing data corresponding to the first subtask layer is determined; the processing data corresponding to the first subtask layer includes the task completion degree, resource consumption degree, completion accuracy and response time of the first subtask layer processing the training data corresponding to the target task; the first subtask layer processing the training data corresponding to the target task includes the first subtask layer outputting the corresponding prediction value based on the input training data corresponding to the target task. Based on the processing data corresponding to the first subtask layer and the adjusted weight of the first subtask layer, the historical performance score of the first subtask layer is updated.
[0015] Further, based on the ratio of the number of training data corresponding to the target task processed by the first subtask layer to the total number of training data corresponding to the target task, the task completion degree of the training data corresponding to the target task processed by the first subtask layer is determined. Based on the ratio of the actual resource consumption of the training data corresponding to the target task processed by the first subtask layer to the estimated resource consumption of the training data corresponding to the target task processed by the first subtask layer, the resource consumption degree of the training data corresponding to the target task processed by the first subtask layer is determined. Based on the ratio of the number of true values of the predicted values output by the first subtask layer for processing the training data corresponding to the target task to the total number of predicted values output by the first subtask layer for processing the training data corresponding to the target task, the completion accuracy of the training data corresponding to the target task processed by the first subtask layer is determined; wherein, when the predicted value output by the first subtask layer for processing the training data corresponding to the target task is less than a threshold value and the preset value of the training data corresponding to the target task, the predicted value output by the first subtask layer for processing the training data corresponding to the target task is a true value. Based on the ratio of the total time for the first subtask layer to process the training data corresponding to the target task to the total number of training data corresponding to the target task processed by the first subtask layer, the response time for the first subtask layer to process the training data corresponding to the target task is determined.
[0016] Furthermore, the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer are respectively normalized to obtain the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer after normalization. Based on the weighted summation of the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer after normalization, a comprehensive score of the first subtask layer is obtained. Based on the comprehensive score of the first subtask layer and the adjusted weight of the first subtask layer, the historical performance score of the first subtask layer is updated.
[0017] Further, for the first subtask layer, the correlation between the first subtask layer and each second subtask layer is calculated; the second subtask layer is a subtask layer different from the first subtask layer in the plurality of subtask layers. The second subtask layer with the highest correlation with the first subtask layer in each of the second subtask layers is determined as the target subtask layer. Based on the distillation loss function between the first subtask layer and the target subtask layer, the knowledge of the target subtask layer is distilled to the first subtask layer.
[0018] Further, based on a third preset rule, the historical performance score of the first subtask layer and the historical performance score of any second subtask layer, the correlation between the first subtask layer and any second subtask layer is calculated. The third preset rule is:
[0019]
[0020] Among them, R i,j is the correlation between the first subtask layer and any second subtask layer, T i Score the historical performance of the first subtask layer, T j Score the historical performance of any of the second subtask layers.
[0021] Further, the distillation loss function between the first subtask layer and the target subtask layer is:
[0022]
[0023] Among them, L distill is the distillation loss function between the first subtask layer and the target subtask layer, λ l is the third preset adjustment coefficient, is the characteristic function of the first layer structure included in the target subtask layer, It is the characteristic function of the first layer structure included in the first subtask layer.
[0024] The beneficial effects of the present invention are:
[0025] 1. Dynamic weight allocation mechanism
[0026] During the training process of the multi-task model, the weights of each sub-task layer are dynamically adjusted according to the loss function corresponding to each sub-task layer and the performance when processing training data. The convergence of the weight update of each sub-task layer is ensured through a smooth adjustment strategy, and the Sigmoid function is introduced to control the amplitude of the weight adjustment of each sub-task layer. After the weights of each sub-task layer are adjusted, they directly affect the subsequent task resource allocation and optimization strategy. The process of adjusting the weights of each sub-task layer is closely related to the optimization process of the model.
[0027] 2. Cross-task knowledge transfer
[0028] The cross-task feature distillation technology is used to calculate the feature sharing layer of the teacher model (target subtask layer) and the student model (first task layer) through feature correlation. During the optimization process, the student model learns the intermediate layer features of the teacher model through distillation, further improving the performance of the student model. The distillation loss function is based on the L2 distance between the features of the two, and controls the contribution of feature migration at each layer through the hierarchical adjustment coefficient.
[0029] 3. Comprehensive performance evaluation and optimization
[0030] The comprehensive performance evaluation is carried out through data normalization and weighted scoring mechanism. Normalizing the processed data corresponding to each subtask layer can ensure that the performance of different subtask layers is compared fairly. Based on the normalized processed data corresponding to each subtask layer, the historical performance score of each subtask layer can be obtained. The historical performance score of each subtask layer can be used to update the weight of each subtask layer in the next round to ensure that the optimization process of each subtask layer after each training is more reasonable.
[0031] In a second aspect, the present invention provides an electronic device comprising: a memory, one or more processors; the memory and the processor are coupled; wherein the memory stores computer program code, the computer program code comprises computer instructions, and when the computer instructions are executed by the processor, the electronic device executes a training method for an agricultural multi-task model as described in any one of the above-mentioned first aspects.
[0032] In a third aspect, a computer-readable storage medium is provided, comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute a training method for an agricultural multi-task model as described in any one of the first aspects.
[0033] In a fourth aspect, a computer program product is provided. When the computer program product is run on a computer, the computer executes the training method of an agricultural multi-task model as described in any one of the first aspects above.
[0034] It can be understood that the beneficial effects that can be achieved by the electronic device described in the second aspect, the computer-readable storage medium described in the third aspect, and the computer program product described in the fourth aspect provided above can be referred to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of the structure of the agricultural multi-task model provided by the present invention;
[0036] Figure 2 A schematic diagram of a flow chart of a training method for an agricultural multi-task model provided by the present invention;
[0037] Figure 3 A schematic diagram of training an agricultural multi-task model provided by the present invention;
[0038] Figure 4 A schematic diagram of obtaining historical performance scores of each subtask layer provided by the present invention;
[0039] Figure 5Schematic diagram of knowledge distillation between the teacher model and the student model provided by the present invention. DETAILED DESCRIPTION
[0040] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the present application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship, for example, A / B can represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. And, in the description of the present application, unless otherwise specified, "multiple" refers to two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish between the same items or similar items with substantially the same functions and effects. Those skilled in the art will understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not necessarily limit the differences. At the same time, in the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design.
[0041] The present invention provides a training method for an agricultural multi-task model, which is applied to an agricultural multi-task model. Figure 1 The agricultural multi-task model may include multiple sub-task layers (eg, sub-task layer 1, sub-task layer 2, ... sub-task layer N), wherein one sub-task layer is used to process one task.
[0042] Figure 2 A flow chart of the training method of the agricultural multi-task model provided by the present invention is shown in Figure 2 The training method of the agricultural multi-task model provided by the present invention comprises the following steps S201-S210:
[0043] S201: For a first subtask layer, an initial weight of the first subtask layer is set based on the complexity of the target task and the historical performance score corresponding to the first subtask layer.
[0044] The first subtask layer is any subtask layer among the multiple subtask layers, and the first subtask layer is used to process the target task.
[0045] For example, the agricultural multi-task model in the embodiment of the present application can be used to process tasks such as crop identification, pest and disease diagnosis, yield prediction, and agricultural policy interpretation. Among them, the target task can be any one of the tasks such as crop identification, pest and disease diagnosis, yield prediction, and agricultural policy interpretation.
[0046] In some embodiments, the initial weight of the first subtask layer may be set based on the complexity of the target task, the historical performance score corresponding to the first subtask layer, and the first preset rule.
[0047] In some embodiments, the first preset rule can be expressed as:
[0048]
[0049] in, is the initial weight of the first subtask layer, α is the first preset adjustment coefficient, β is the second preset adjustment coefficient, C i is the complexity of the target task, H i Score the historical performance corresponding to the first subtask layer.
[0050] It should be noted that those skilled in the art can set specific numerical values corresponding to the first preset adjustment coefficient α and the second preset adjustment coefficient β respectively based on actual scenarios and requirements, and the embodiments of the present application are not limited thereto.
[0051] S202: Allocate computing resources to the first subtask layer based on the initial weight of the first subtask layer, and input a training data set corresponding to the target task into the first subtask layer.
[0052] Among them, the training data set corresponding to the target task includes multiple training data. The higher the initial weight of the first subtask layer, the more computing resources are allocated to the first subtask layer. When training the agricultural multi-task model, the training data sets corresponding to multiple tasks can be input into the agricultural multi-task model, and then each subtask layer included in the agricultural multi-task model can receive the training data sets corresponding to the tasks that can be processed by each of them (or, part or all of the training data included in the training data set).
[0053] In some embodiments, various data such as climate, soil, and crop growth can be collected from agricultural scenarios, and each data can be standardized to obtain training data to ensure the consistency of model input data.
[0054] S203: For any training data input to the first subtask layer, based on the output of the first subtask layer, determine the loss function corresponding to the first subtask layer.
[0055] Taking the training data received by the first subtask layer as the first training data as an example, after receiving the first training data, the first subtask layer can output a predicted value for the first training data. Then, based on the gap between the predicted value of the first training data and the true value of the first training data, the loss function corresponding to the first subtask layer can be determined.
[0056] S204: Adjust the weight corresponding to the first subtask layer based on the initial weight, loss function and learning rate corresponding to the first subtask layer.
[0057] In some embodiments, a target weight may be determined based on the initial weight corresponding to the first subtask layer, the loss function, the learning rate, and the second preset rule. Thereafter, the weight corresponding to the first subtask layer may be adjusted based on the target weight.
[0058] In some embodiments, the second preset rule can be expressed as:
[0059]
[0060] in, is the target weight, is the initial weight corresponding to the first subtask layer, η is the learning rate corresponding to the first subtask layer, L i is the loss function corresponding to the first subtask layer.
[0061] It should be noted that those skilled in the art can set the learning rate η corresponding to the first subtask layer based on actual needs, and the embodiment of the present application is not limited thereto.
[0062] In some embodiments, the target weights may be normalized to ensure that the sum of the weights corresponding to each subtask layer is 1. Thereafter, the weight corresponding to the first subtask layer may be adjusted to the normalized target weight.
[0063] Among them, the target weight can be normalized by the following formula:
[0064]
[0065] S205: Allocate computing resources to each subtask layer based on the adjusted weight of each subtask layer.
[0066] Among them, the higher the weight corresponding to the first subtask layer after adjustment, the higher the computing resources allocated to the first subtask layer.
[0067] Based on S201-S205, see Figure 3In the process of training the agricultural multi-task model, the embodiment of the present application can allocate initial weights to each subtask layer by analyzing the task complexity of each subtask layer (e.g., subtask layer 1, subtask layer 2, ..., subtask layer N) and the historical performance score of the corresponding task processed by each subtask layer. After inputting the training data of the corresponding task to each subtask layer, the loss function corresponding to each subtask layer can be calculated in real time. As the training process is dynamically updated, the loss function corresponding to each subtask layer is also updated in real time. Based on the information such as the loss function corresponding to each subtask layer, the target weight corresponding to each subtask layer can be determined. By normalizing the target weights corresponding to each subtask layer and adjusting the weights of each subtask layer to the corresponding normalized target weights, the rationalization of the weights allocated to each subtask layer can be ensured. The weights allocated to each subtask layer directly affect the subsequent resource allocation and priority management of each subtask layer during operation. Subtask layers with higher weights will obtain more resources to optimize their performance, while subtask layers with lower weights will adjust (reduce) resource allocation according to their current weights.
[0068] S206: For the first subtask layer, determine the processing data corresponding to the first subtask layer.
[0069] The processing data corresponding to the first subtask layer includes the task completion degree, resource consumption degree, completion accuracy and response time of the training data corresponding to the target task processed by the first subtask layer. The processing of the training data corresponding to the target task by the first subtask layer includes the first subtask layer outputting the corresponding prediction value based on the input training data corresponding to the target task.
[0070] In some embodiments, the task completion degree of the first subtask layer processing the training data corresponding to the target task can be determined based on the ratio of the amount of training data corresponding to the target task processed by the first subtask layer to the total amount of training data corresponding to the target task.
[0071] Among them, the task completion degree of the first subtask layer processing the training data corresponding to the target task can be expressed as:
[0072]
[0073] Among them, KPI complete The task completion rate of the first subtask layer in processing the training data corresponding to the target task, "Number of completed tasks" is the number of training data corresponding to the target task processed by the first subtask layer, and Total tasks is the total number of training data corresponding to the target task. KPI complete It can reflect the timeliness and degree of achievement of task execution at the first subtask layer.
[0074] In some embodiments, the resource consumption of the training data corresponding to the target task processed by the first subtask layer can be determined based on the ratio of the actual resource consumption of the training data corresponding to the target task processed by the first subtask layer to the estimated resource consumption of the training data corresponding to the target task processed by the first subtask layer.
[0075] Among them, the resource consumption of the first subtask layer processing the training data corresponding to the target task can be expressed as:
[0076]
[0077] Among them, KPI resource The resource consumption of the first subtask layer for processing the training data corresponding to the target task, "Actual resource consumption" is the actual resource consumption of the first subtask layer for processing the training data corresponding to the target task, and "Estimated resource consumption" is the estimated resource consumption of the first subtask layer for processing the training data corresponding to the target task. KPI resource It can reflect the resource utilization and efficiency of the first subtask layer when executing tasks.
[0078] In some embodiments, the completion accuracy of the training data corresponding to the target task processed by the first subtask layer can be determined based on the ratio of the number of true values of the predicted values output by the first subtask layer corresponding to the target task processed by the first subtask layer to the total number of predicted values output by the first subtask layer corresponding to the target task processed by the first subtask layer.
[0079] Among them, when the predicted value output by the first subtask layer when processing the training data corresponding to the target task and the preset value of the training data corresponding to the target task are less than a threshold, the predicted value output by the first subtask layer when processing the training data corresponding to the target task is a true value.
[0080] Moreover, the completion accuracy of the training data corresponding to the target task processed by the first subtask layer can be expressed as:
[0081]
[0082] Among them, KPI accuracy The completion accuracy of the training data corresponding to the target task processed by the first subtask layer, the number of correct predictions, the number of true values of the predicted values output by the training data corresponding to the target task processed by the first subtask layer, and the total forecast, the total number of predicted values output by the training data corresponding to the target task processed by the first subtask layer. KPI accuracyIt can reflect the accuracy of the first subtask layer in performing tasks, especially in applications such as pest and disease prediction in agricultural scenarios.
[0083] In some embodiments, the response time of the first subtask layer processing the training data corresponding to the target task can be determined based on the ratio of the total time of the first subtask layer processing the training data corresponding to the target task to the total number of training data processed by the first subtask layer.
[0084] Among them, the response time of the first subtask layer processing the training data corresponding to the target task can be expressed as:
[0085]
[0086] Among them, KPI time The response time of the first subtask layer processing the training data corresponding to the target task, "Total response time" is the total time of the first subtask layer processing the training data corresponding to the target task, and "Number of tasks" is the total number of training data corresponding to the target task processed by the first subtask layer. KPI time It can reflect the timely response capability of the first subtask layer in processing the training data corresponding to the target task.
[0087] S207: Based on the processed data corresponding to the first subtask layer and the adjusted weight of the first subtask layer, update the historical performance score of the first subtask layer.
[0088] In some embodiments, the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer can be normalized to obtain the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer after normalization. Based on the weighted summation of the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer after normalization, a comprehensive score of the first subtask layer can be obtained. Based on the comprehensive score of the first subtask layer and the adjusted weight of the first subtask layer, the historical performance score of the first subtask layer can be updated.
[0089] In some embodiments, the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer can be normalized by the following formulas:
[0090]
[0091] This formula normalizes the processing data of each category (task completion, resource consumption, completion accuracy, and response time) to ensure that the performance of different subtask layers can be compared at the same level. Through this normalization process, it can ensure that the processing data corresponding to all subtask layers (task completion, resource consumption, completion accuracy, and response time) are compared on the same scale, eliminating the difference in indicator dimensions caused by the different nature of tasks that can be processed by different subtask layers.
[0092] In some embodiments, the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer after normalization can be weighted and summed by the following formula to obtain a comprehensive score for the first subtask layer:
[0093]
[0094] Among them, λ k is the weight of the kth processed data, and m is the total number of processed data. The weights of different processed data are set by expert experience or historical data to ensure that the core indicators corresponding to different subtask layers can be fully reflected.
[0095] In some embodiments, the historical performance score of the first subtask layer may be updated based on the following formula:
[0096]
[0097] The historical performance score of the first subtask layer can be used to evaluate the overall historical performance of the first subtask layer and serve as the basis for adjusting the weight of the first subtask layer in the next round.
[0098] In some embodiments, the historical performance scores of the first subtask layer may also be weighted to update the historical performance scores of the first subtask layer based on the weighted historical performance scores of the first subtask layer.
[0099] Among them, the historical performance score of the first subtask layer can be weighted based on the following formula:
[0100]
[0101] By evaluating the performance of each subtask layer through weighted scoring and dynamically adjusting the weight of each subtask layer based on the scoring results, the overall performance of the agricultural multi-task model can be optimized.
[0102] Based on S206-S207, see Figure 4After the agricultural multi-task model finishes executing each round of tasks, the performance of each subtask layer can be evaluated, and the corresponding processing data of each subtask layer can be normalized and weighted to obtain the historical performance score of each subtask layer. Based on the historical performance score of each subtask layer, the weight of each subtask layer can be dynamically adjusted.
[0103] S208: For the first subtask layer, calculate the correlation between the first subtask layer and each second subtask layer.
[0104] The second subtask layer is a subtask layer among the multiple subtask layers that is different from the first subtask layer.
[0105] In some embodiments, the correlation between the first subtask layer and any second subtask layer may be calculated based on the third preset rule, the historical performance score of the first subtask layer and the historical performance score of any second subtask layer.
[0106] In some embodiments, the third preset rule is:
[0107]
[0108] Among them, R i,j is the correlation between the first subtask layer and any second subtask layer, T i Score the historical performance of the first subtask layer, T j Score the historical performance of any of the second subtask layers.
[0109] S209: Determine the second subtask layer with the highest correlation with the first subtask layer among the second subtask layers as the target subtask layer.
[0110] S210: Based on the distillation loss function between the first subtask layer and the target subtask layer, distill the knowledge of the target subtask layer to the first subtask layer.
[0111] In the embodiment of the present application, the target subtask layer may also be referred to as a teacher model, and the first subtask layer may also be referred to as a student model. Figure 5 ,The difference between the features of the teacher model and the student model can be calculated through the distillation loss function, and the intermediate layer and output layer features in the teacher model can be passed to the student model to improve its performance.
[0112] In some embodiments, the distillation loss function between the first subtask layer and the target subtask layer is:
[0113]
[0114] Among them, L distill is the distillation loss function between the first subtask layer and the target subtask layer, λl is the third preset adjustment coefficient, is the characteristic function of the first layer structure included in the target subtask layer, It is the characteristic function of the first layer structure included in the first subtask layer.
[0115] Based on S208-S210, it can be seen that in order to enhance the synergy between the subtask layers, the embodiment of the present application transfers the intermediate layer features and output layer features of the task model (teacher model) with better performance to the student model through the knowledge transfer mechanism. Through feature distillation technology, the student model can learn effective features from the teacher model, thereby improving its performance in similar tasks.
[0116] In combination with S201-S209 of the embodiment of the present application, it can be seen that the embodiment of the present application significantly improves the performance of the agricultural multi-task model through mechanisms such as dynamic weight allocation, cross-task knowledge transfer and comprehensive performance evaluation. The method provided in the embodiment of the present application can achieve efficient collaborative processing of multiple tasks in a complex and changeable agricultural environment, and improve the ability and efficiency of intelligent decision-making of the agricultural multi-task model.
[0117] In some schemes, multiple embodiments of the present application can be combined, and the combined scheme can be implemented. Optionally, some operations in the process of each method embodiment are optionally combined, and / or the order of some operations is optionally changed. In addition, the execution order between the steps of each process is only exemplary and does not constitute a restriction on the execution order between the steps. There can also be other execution orders between the steps. It is not intended to indicate that the execution order is the only order in which these operations can be performed. A person of ordinary skill in the art will think of a variety of ways to reorder the operations described herein. In addition, it should be noted that the process details involved in a certain embodiment of this article are also applicable to other embodiments in a similar manner, or different embodiments can be used in combination.
[0118] In addition, some steps in the method embodiment may be equivalently replaced by other possible steps. Alternatively, some steps in the method embodiment may be optional and may be deleted in certain usage scenarios. Alternatively, other possible steps may be added to the method embodiment. Furthermore, the method embodiments may be implemented separately or in combination.
[0119] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above.
[0120] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0121] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0122] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (read only memory, ROM), random access memory (random access memory, RAM), disk or optical disk and other media that can store program code.
[0123] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A training method for an agricultural multi-task model, characterized in that: Applied to an agricultural multi-task model, the agricultural multi-task model includes a plurality of sub-task layers, one sub-task layer is used to process one task, and the method includes: For a first subtask layer, an initial weight of the first subtask layer is set based on the complexity of the target task and the historical performance score corresponding to the first subtask layer; the first subtask layer is any subtask layer among the multiple subtask layers; the first subtask layer is used to process the target task; Based on the initial weight of the first subtask layer, computing resources are allocated to the first subtask layer, and a training data set corresponding to the target task is input to the first subtask layer; the training data set corresponding to the target task includes a plurality of training data; For any training data input to the first subtask layer, determining a loss function corresponding to the first subtask layer based on an output of the first subtask layer; Adjusting the weight corresponding to the first subtask layer based on the initial weight, loss function and learning rate corresponding to the first subtask layer; Based on the adjusted weights of the subtask layers, computing resources are allocated to the subtask layers.
2. The method according to claim 1, characterized in that The step of setting the initial weight of the first subtask layer based on the complexity of the target task and the historical performance score corresponding to the first subtask layer includes: The initial weight of the first subtask layer is set based on the complexity of the target task, the historical performance score corresponding to the first subtask layer, and a first preset rule; the first preset rule is: in, is the initial weight of the first subtask layer, α is the first preset adjustment coefficient, β is the second preset adjustment coefficient, C i is the complexity of the target task, H i Score the historical performance corresponding to the first subtask layer.
3. The method according to claim 2, characterized in that The adjusting the weight corresponding to the first subtask layer based on the initial weight, loss function and learning rate corresponding to the first subtask layer includes: Determining a target weight based on an initial weight, a loss function, a learning rate, and a second preset rule corresponding to the first subtask layer; Based on the target weight, adjusting the weight corresponding to the first subtask layer; The second preset rule is: in, is the target weight, is the initial weight corresponding to the first subtask layer, η is the learning rate corresponding to the first subtask layer, L i is the loss function corresponding to the first subtask layer.
4. The method according to claim 3, characterized in that: The higher the weight corresponding to the first subtask layer after adjustment, the higher the computing resources allocated to the first subtask layer.
5. The method according to claim 4, characterized in that After allocating computing resources to each of the subtask layers based on the adjusted weights of each of the subtask layers, the method further includes: For the first subtask layer, determining the processing data corresponding to the first subtask layer; the processing data corresponding to the first subtask layer includes the task completion degree, resource consumption degree, completion accuracy and response time of the first subtask layer processing the training data corresponding to the target task; the first subtask layer processing the training data corresponding to the target task includes the first subtask layer outputting the corresponding prediction value based on the input training data corresponding to the target task; Based on the processed data corresponding to the first subtask layer and the adjusted weight of the first subtask layer, the historical performance score of the first subtask layer is updated.
6. The method according to claim 5, characterized in that The determining the processing data corresponding to the first subtask layer includes: Determining a task completion degree of processing the training data corresponding to the target task by the first subtask layer based on a ratio of the amount of training data corresponding to the target task processed by the first subtask layer to the total amount of training data corresponding to the target task; Determining the resource consumption of the first subtask layer for processing the training data corresponding to the target task based on a ratio of the actual resource consumption of the first subtask layer for processing the training data corresponding to the target task to the estimated resource consumption of the first subtask layer for processing the training data corresponding to the target task; Based on the ratio of the number of true values of the predicted values output by the first subtask layer when processing the training data corresponding to the target task to the total number of predicted values output by the first subtask layer when processing the training data corresponding to the target task, the completion accuracy of the first subtask layer processing the training data corresponding to the target task is determined; wherein, when the predicted value output by the first subtask layer when processing the training data corresponding to the target task and the preset value of the training data corresponding to the target task are less than a threshold value, the predicted value output by the first subtask layer when processing the training data corresponding to the target task is a true value; Based on the ratio of the total time for the first subtask layer to process the training data corresponding to the target task to the total number of training data corresponding to the target task processed by the first subtask layer, the response time for the first subtask layer to process the training data corresponding to the target task is determined.
7. The method according to claim 6, characterized in that The updating of the historical performance score of the first subtask layer based on the processed data corresponding to the first subtask layer and the adjusted weight of the first subtask layer includes: Normalizing the task completion degree, resource consumption degree, completion accuracy and response time of the training data corresponding to the target task processed by the first subtask layer, respectively, to obtain the task completion degree, resource consumption degree, completion accuracy and response time of the training data corresponding to the target task processed by the first subtask layer after normalization; Obtaining a comprehensive score for the first subtask layer based on a weighted summation of the task completion, resource consumption, completion accuracy, and response time of the training data corresponding to the target task processed by the first subtask layer after normalization; Based on the comprehensive score of the first subtask layer and the adjusted weight of the first subtask layer, the historical performance score of the first subtask layer is updated.
8. The method according to claim 7, characterized in that After allocating computing resources to each of the subtask layers based on the adjusted weights of each of the subtask layers, the method further includes: For the first subtask layer, calculating the correlation between the first subtask layer and each second subtask layer; the second subtask layer is a subtask layer different from the first subtask layer among the multiple subtask layers; Determine the second subtask layer with the highest correlation with the first subtask layer among the second subtask layers as the target subtask layer; Based on a distillation loss function between the first subtask layer and the target subtask layer, knowledge of the target subtask layer is distilled to the first subtask layer.
9. The method according to claim 8, characterized in that The calculating the correlation between the first subtask layer and each second subtask layer includes: Based on a third preset rule, the historical performance score of the first subtask layer and the historical performance score of any second subtask layer, the correlation between the first subtask layer and any second subtask layer is calculated; the third preset rule is: Among them, R i,j is the correlation between the first subtask layer and any second subtask layer, T i Score the historical performance of the first subtask layer, T j Score the historical performance of any of the second subtask layers.
10. The method according to claim 9, characterized in that The distillation loss function between the first subtask layer and the target subtask layer is: Among them, L distill is the distillation loss function between the first subtask layer and the target subtask layer, λ l is the third preset adjustment coefficient, is the characteristic function of the first layer structure included in the target subtask layer, It is the characteristic function of the first layer structure included in the first subtask layer.
Citation Information
Cited By
A horticultural robot autonomous decision-making method, system, device and medium
CN122947924A