Agricultural model migration method and system, electronic device, and storage medium
Patent Information
- Application Number
- CN202611007423.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-09-25
AI Technical Summary
[0005]基于上述现有技术的不足,本申请提供了一种农业模型的迁移方法及系统、电子设备、存储介质,以解决现有技术无法保证迁移的农业模型的准确性的问题
[0070]本申请提供的一种农业模型的迁移方法,获取目标域和源域的训练数据。然后利用从源域和目标域的训练数据中提取出的元特征,计算源域与目标域的相似度,并根据源域与目标域的相似度,确定源域的域权重。接着基于源域的训练数据及其域权重,对待迁移的目标模型进行训练,其中,利用源域对应的域权重进行加权计算训练时的损失值,从而充分考虑各域间的差异,使模型偏向于与目标域相似的源域,进而可以有效提高迁移后的模型的准确性。然后分别在目标域与源域的各个共同切分维度上,对当前训练后的目标模型的迁移效果进行留一队列交叉验证,得到当前评估指标,从而考虑农业的特性,从目标域可以划分的农业特性维度上进行数据划分,并对迁移模型进行评估。最后根据当前评估指标计算源域对应的迁移衰减率,以根据迁移衰减率执行对应预警级别的迁移控制操作,从而可以根据定义的模型的迁移衰减率,及时进行相应的操作调整数据,进而可以相应地调整模型的效果。其中,在预警级别为指定预警级别时,调整资格门控矩阵。资格门控矩阵包括多个资格标识。每个资格标识表征一个任务中,从源域迁移至目标域的组合参与模型训练和推理的资格状态,从而可以及时禁用不适用数据,避免其对模型迁移造成影响,进而也可以保证模型准确性。所以实现了一种可以对农业模型进行准确迁移的方法,从而保证迁移模型的预测准确性。
Smart Images

Figure CN122819367A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent agricultural technology, and in particular to a method and system for transferring agricultural models, electronic devices, and storage media. Background Technology
[0002] With the rapid development of digital agriculture, machine learning-based agricultural models play a crucial role in tasks such as yield prediction. However, the applicability of the same agricultural model varies significantly under different climate zones and planting methods. Therefore, obtaining a suitable model is essential for newly established target domains without supporting data.
[0003] Currently, the main approaches are as follows: The first is single-domain training combined with naive transfer learning. Specifically, after training the model using data from the source domain, the trained model is directly deployed to the target domain for prediction applications. The second is hybrid domain training. Specifically, samples from different regions, years, or greenhouse conditions are mixed indiscriminately and then used to train the model uniformly, which is then applied to the target domain. The third is introducing methods for general domain adaptation. For example, methods such as Domain-Adversarial Neural Network (DANN) based on adversarial training or Correlation Alignment (CORAL) are used to train a general domain model, which is then applied to the target domain.
[0004] However, single-domain training can easily lead to significant differences, resulting in decreased model accuracy. Mixed-domain training ignores inter-domain differences, causing the model to favor the domain with more samples and failing to assess the reliability of each domain, thus also compromising model accuracy. Furthermore, general-domain training methods do not consider the unique characteristics of agriculture, which, unlike image and text scenarios, typically exhibits significant inter-domain differences, leading to lower model accuracy. Summary of the Invention
[0005] In view of the shortcomings of the prior art, this application provides a method and system for migrating agricultural models, an electronic device, and a storage medium to solve the problem that the prior art cannot guarantee the accuracy of the migrated agricultural models.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] The first aspect of this application provides a method for transferring agricultural models, including:
[0008] Obtain training data for the target and source domains;
[0009] The similarity between the source domain and the target domain is calculated using meta-features extracted from the training data of the source domain and the target domain.
[0010] The domain weight of the source domain is determined based on the similarity between the source domain and the target domain.
[0011] Based on the training data of the source domain and its domain weights, the target model to be transferred is trained; wherein, the loss value during training is calculated by weighting the domain weights corresponding to the source domain.
[0012] Leave-one-out cross-validation is performed on the transfer performance of the currently trained target model on each common segmentation dimension of the target domain and the source domain to obtain the current evaluation index.
[0013] Calculate the migration attenuation rate corresponding to the source domain based on the current evaluation index;
[0014] The migration control operation corresponding to the warning level is executed according to the migration decay rate; wherein, when the warning level is a specified warning level, the eligibility gating matrix is adjusted; the eligibility gating matrix includes multiple eligibility identifiers; each eligibility identifier represents the eligibility status of a combination of migrations from the source domain to the target domain in a task to participate in model training and inference.
[0015] Optionally, in the above-described transfer method for agricultural models, the step of calculating the similarity between the source domain and the target domain using meta-features extracted from the training data of the source domain and the target domain includes:
[0016] Meta-features of the source domain and the target domain are extracted from the training data of the source domain and the target domain, respectively.
[0017] The meta-features of the source domain and the target domain are vectorized to obtain the meta-feature vectors of the source domain and the target domain;
[0018] Based on the meta-feature vectors of the source domain and the target domain, the distance between the source domain and the target domain is calculated, and the distance is converted into the similarity between the source domain and the target domain through a kernel function.
[0019] Optionally, in the above-described agricultural model transfer method, training the target model to be transferred based on the training data of the source domain and its domain weights includes:
[0020] Each training sample data from the training data in the source domain is input into the target model to be transferred for prediction, and the prediction results of each training sample data are obtained.
[0021] The loss of the prediction results of each training sample data is weighted according to the domain weight of the source domain to obtain the current loss value;
[0022] The parameters of the target model are updated using the current loss value to obtain the trained target model.
[0023] Optionally, in the above-described agricultural model transfer method, the step of performing leave-one-out cross-validation on the transfer performance of the currently trained target model across each common segmentation dimension of the target domain and the source domain to obtain the current evaluation metric includes:
[0024] The test sample data left out on the common segmentation dimension is input into the target model for prediction to obtain the test results; wherein, the test sample data left out includes the left-out queue samples of the source domain on the common segmentation dimension and / or the left-out queue samples of the target domain on the common segmentation dimension;
[0025] Based on the test results, each current evaluation metric is calculated; wherein, the current evaluation metric includes at least the root mean square error of state prediction, the counterfactual direction consistency rate, and the cross-scenario consistency index.
[0026] Optionally, in the migration method of the above agricultural model, calculating the migration decay rate corresponding to the source domain based on the current evaluation index includes:
[0027] Based on the current evaluation metrics, determine the performance metrics of the target model in the source domain, and obtain the performance metrics of the target model in the target domain;
[0028] The difference between the performance index of the target model in the source domain and the performance index in the target domain is divided by the performance index in the source domain to obtain the migration decay rate corresponding to the source domain.
[0029] Optionally, in the migration method of the above agricultural model, the step of performing migration control operations corresponding to the early warning level based on the migration decay rate includes:
[0030] If the migration decay rate is within the mild decay rate range, a suggestion is made to increase the data in the target domain for model fine-tuning.
[0031] If the migration decay rate is in the moderate decay rate range, then a suggestion is given to recalculate the domain weights of the source domain and retrain, and to add data from the target domain to fine-tune the model.
[0032] If the migration decay rate is within the range of severe decay rates, then the combination of migrating from the source domain to the target domain is marked as prohibited in the eligibility gating matrix.
[0033] Optionally, the above-mentioned transfer method for agricultural models also includes:
[0034] The eligibility gating matrix is queried when training the target model or when using the target model for inference.
[0035] If the eligibility identifier of the target combination in the eligibility gating matrix is marked as prohibited, then the source domain data corresponding to the target combination is prohibited from participating in training or inference; wherein, the target combination is the combination currently used for training or inference that has been migrated from the source domain to the target domain.
[0036] A second aspect of this application provides a transfer system for agricultural models, comprising:
[0037] The data acquisition unit is used to acquire training data from the target domain and the source domain.
[0038] A similarity calculation unit is used to calculate the similarity between the source domain and the target domain using meta-features extracted from the training data of the source domain and the target domain.
[0039] The weight determination unit is used to determine the domain weight of the source domain based on the similarity between the source domain and the target domain.
[0040] The training unit is used to train the target model to be transferred based on the training data of the source domain and its domain weights; wherein, the loss value during training is calculated by weighting the domain weights corresponding to the source domain.
[0041] The performance evaluation unit is used to perform leave-one-out cross-validation on the transfer performance of the currently trained target model on each common segmentation dimension of the target domain and the source domain, respectively, to obtain the current evaluation index.
[0042] The attenuation calculation unit is used to calculate the migration attenuation rate corresponding to the source domain based on the current evaluation index.
[0043] The early warning operation unit is used to perform migration control operations corresponding to the early warning level according to the migration decay rate; wherein, when the early warning level is a specified early warning level, the qualification gating matrix is adjusted; the qualification gating matrix includes multiple qualification identifiers; each qualification identifier represents the qualification status of a combination of migrations from the source domain to the target domain in a task to participate in model training and inference.
[0044] Optionally, in the above-described agricultural model migration system, the similarity calculation unit includes:
[0045] The feature extraction unit is used to extract meta-features of the source domain and the target domain from the training data of the source domain and the target domain, respectively.
[0046] A vectorization unit is used to vectorize the meta-features of the source domain and the target domain to obtain the meta-feature vectors of the source domain and the target domain.
[0047] The distance calculation unit is used to calculate the distance between the source domain and the target domain based on the meta-feature vectors of the source domain and the target domain, and convert the distance into the similarity between the source domain and the target domain through a kernel function.
[0048] Optionally, in the above-described agricultural model transfer system, the training unit includes:
[0049] The input unit is used to input each training sample data in the training data of the source domain into the target model to be transferred for prediction, so as to obtain the prediction results of each training sample data.
[0050] The loss calculation unit is used to weight the loss of the prediction results of each training sample data according to the domain weight of the source domain to obtain the current loss value;
[0051] The parameter update unit is used to update the parameters of the target model using the current loss value to obtain the trained target model.
[0052] Optionally, in the above-described agricultural model migration system, the effect evaluation unit includes:
[0053] The prediction unit is used to input the reserved test sample data on the common segmentation dimension into the target model for prediction to obtain test results; wherein, the reserved test sample data includes the reserved queue samples of the source domain on the common segmentation dimension and / or the reserved queue samples of the target domain on the common segmentation dimension;
[0054] The indicator calculation unit is used to calculate various current evaluation indicators based on the test results; wherein, the current evaluation indicators include at least the root mean square error of state prediction, the counterfactual direction consistency rate, and the cross-scenario consistency index.
[0055] Optionally, in the migration system of the above-described agricultural model, the attenuation calculation unit includes:
[0056] The performance determination unit is used to determine the performance performance index of the target model in the source domain based on the current evaluation index, and to obtain the performance performance index of the target model in the target domain.
[0057] The attenuation rate calculation unit is used to divide the difference between the performance index of the target model in the source domain and the performance index in the target domain by the performance index in the source domain to obtain the migration attenuation rate corresponding to the source domain.
[0058] Optionally, in the above-described agricultural model migration system, the early warning operation unit includes:
[0059] The first operation unit is used to provide a suggestion to increase the data of the target domain for model fine-tuning when the migration attenuation rate is in a mild attenuation rate range.
[0060] The second operation unit is used to provide feedback suggestions on recalculating the domain weights of the source domain and retraining, and adding data from the target domain to fine-tune the model when the migration decay rate is in a moderate decay rate range.
[0061] The third operation unit is used to mark the combination of migrating from the source domain to the target domain as prohibited in the qualification gating matrix when the migration decay rate is in the range of severe decay rate.
[0062] Optionally, the above-mentioned agricultural model transfer system also includes:
[0063] A query unit is used to query the eligibility gating matrix when training the target model or when using the target model for inference.
[0064] A disabling unit is used to prohibit source domain data corresponding to a target combination from participating in training or inference when the qualification identifier of the target combination in the qualification gating matrix is marked as prohibited; wherein, the target combination is a combination currently used for training or inference that has been migrated from the source domain to the target domain.
[0065] A third aspect of this application provides an electronic device, comprising:
[0066] Memory and processor;
[0067] The memory is used to store programs;
[0068] The processor is used to execute the program, which, when executed, is specifically used to implement the agricultural model migration method as described in any of the above.
[0069] A fourth aspect of this application provides a computer storage medium for storing a computer program, which, when executed by a processor, is used to implement the migration method of the agricultural model as described in any of the preceding claims.
[0070] This application provides a transfer learning method for agricultural models, which involves acquiring training data for both the target and source domains. Then, using meta-features extracted from the training data, the similarity between the source and target domains is calculated, and the domain weights of the source domain are determined based on this similarity. Next, the target model to be transferred is trained based on the training data and its domain weights. The loss value during training is calculated using the corresponding domain weights of the source domain, thus fully considering the differences between domains and biasing the model towards the source domain, which is similar to the target domain, thereby effectively improving the accuracy of the transferred model. Then, leave-one-out cross-validation is performed on the transfer performance of the currently trained target model along each common segmentation dimension between the target and source domains to obtain the current evaluation index. Considering the characteristics of agriculture, data is segmented according to the agricultural characteristic dimensions that can be used to divide the target domain, and the transfer model is evaluated. Finally, the transfer decay rate corresponding to the source domain is calculated based on the current evaluation index. Transfer control operations with corresponding warning levels are executed based on the transfer decay rate, allowing for timely adjustments to the data based on the defined model transfer decay rate, thereby adjusting the model's performance accordingly. Specifically, when the warning level reaches a specified level, the eligibility gating matrix is adjusted. The eligibility gating matrix includes multiple eligibility identifiers. Each eligibility identifier represents the eligibility status of a combination of data transferred from the source domain to the target domain for participating in model training and inference within a task. This allows for the timely disabling of inapplicable data, preventing its impact on model transfer and thus ensuring model accuracy. Therefore, a method for accurately transferring agricultural models is implemented, thereby guaranteeing the predictive accuracy of the transferred model. Attached Figure Description
[0071] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0072] Figure 1 A flowchart illustrating a migration method for an agricultural model provided in this application embodiment;
[0073] Figure 2 A flowchart illustrating a method for calculating the similarity between a source domain and a target domain, provided in an embodiment of this application;
[0074] Figure 3 A flowchart illustrating a method for training a target model to be transferred, provided in an embodiment of this application;
[0075] Figure 4 A schematic diagram of the architecture of a migration system for an agricultural model provided in this application embodiment;
[0076] Figure 5 This is a schematic diagram of the architecture of an electronic device provided in an embodiment of this application. Detailed Implementation
[0077] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0078] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0079] This application provides a method for transferring agricultural models, such as... Figure 1 As shown, it includes the following steps:
[0080] S101. Obtain training data for the target domain and source domain.
[0081] In this embodiment, a domain refers to a combination of geographical, climatic, temporal, and team-related factors related to data collection, and is the object of cross-domain migration. Therefore, domains can be categorized by greenhouse, plot, season, year, team, crop batch, etc. A source domain refers to a historical domain with sufficient existing data that can be used for training or migration. Therefore, there can be multiple source domains, allowing for the acquisition of training data from multiple source domains and processing for each domain separately. A target domain refers to a new domain to be migrated, adapted, or evaluated.
[0082] To analyze the similarity between the target domain and the source domain and to perform model transfer, training data for both the target domain and the source domain are acquired separately. Optionally, the training data includes multiple sample data, each of which specifically contains the original observation data, actions, and target labels for each domain.
[0083] It should be noted that, due to limited data, the target domain receives relatively little training data, primarily used to analyze similarity to the source domain and verify the effectiveness of transfer learning. The source domain, on the other hand, is used for transfer learning training of the model.
[0084] S102. Calculate the similarity between the source domain and the target domain using the meta-features extracted from the training data of the source domain and the target domain.
[0085] To avoid bias towards domains with more samples and instead favor source domains similar to the target domain, thus improving model accuracy, it is necessary to extract meta-features from the training data of both the source and target domains. Based on these meta-features, the similarity between the source and target domains can be calculated. These meta-features can be domain-level summary features obtained by statistically analyzing, encoding, or evaluating the training data set.
[0086] Optionally, in another embodiment of this application, one specific implementation of step S102 is as follows: Figure 2 As shown, it includes:
[0087] S201. Extract the meta-features of the source domain and the target domain from the training data of the source domain and the target domain, respectively.
[0088] Specifically, the meta-features that can be extracted from the training data of each domain may include, but are not limited to, climate zone classification (e.g., temperate / subtropical / tropical); geographical latitude; annual average radiation / light intensity distribution statistics; temperature distribution (mean, seasonal peaks and valleys); facility type (glass greenhouse / plastic greenhouse / open-air); and team / collector identification.
[0089] S202. Vectorize the meta-features of the source domain and the target domain to obtain the meta-feature vectors of the source domain and the target domain.
[0090] Specifically, the meta-features of the source domain and the target domain are concatenated and vectorized to obtain the meta-feature vectors of the source domain and the target domain.
[0091] S203. Based on the meta-feature vectors of the source domain and the target domain, calculate the distance between the source domain and the target domain, and convert the distance into the similarity between the source domain and the target domain through a kernel function.
[0092] Specifically, based on the meta-feature vectors of the source domain d_s and the target domain d_t, the Euclidean distance between the source domain d_s and the target domain d_t can be calculated, and this Euclidean distance can be converted into a similarity sim(d_s,d_t) between the source and target domains using a kernel function. Therefore, sim(d_s,d_t)=exp(-‖m_{d_s}-m_{d_t}‖² / σ²), where σ is the standard deviation of each meta-feature vector.
[0093] S103. Determine the domain weight of the source domain based on the similarity between the source domain and the target domain.
[0094] In order to give more attention to the source domain that is similar to the target domain, the domain weights of the source domains are determined, so that when the training samples come from different source domains, the loss is calculated by weighting according to the domain weights.
[0095] Optionally, the similarity between the source and target domains can be directly used as the domain weight of the source domain. Alternatively, the normalized similarity between the source and target domains can be used as the domain weight of the source domain, or other strategies can be employed to determine the domain weight of the source domain. However, it is necessary to ensure that the greater the similarity between the source and target domains, the greater the domain weight of the source domain.
[0096] S104. Based on the training data of the source domain and its domain weights, train the target model to be transferred.
[0097] The loss value during training is calculated by weighting the domain weights corresponding to the source domain.
[0098] Specifically, the target model to be transferred can be trained using individual training samples from the training data of each source domain. During training, the loss of each training sample is calculated according to the domain weights of its respective source domain, and the losses of all training samples are summed. In other words, the total training loss is calculated by weighting the data using the domain weights corresponding to each source domain.
[0099] The target model can be an agricultural world model or a transfer-adaptation model. The agricultural world model is a generative agriculture model that learns environmental dynamics and supports rollout. It primarily takes historical observations and candidate future actions as input and outputs future states, yields, or task responses.
[0100] In other words, during the zero-shot transfer phase, the target domain data is only used for meta-feature extraction and validation / testing, and does not participate in source domain weighted training. However, in the subsequent adaptation phase, a small amount of target domain sample data can be introduced for fine-tuning, domain weight recalculation, or adapter training.
[0101] Optionally, in another embodiment of this application, one specific implementation of step S104 is as follows: Figure 3 As shown, it includes:
[0102] S301. Input each training sample data from the source domain training data into the target model to be transferred for prediction, and obtain the prediction results of each training sample data.
[0103] S302. Weight the loss of the prediction results of each training sample data according to the domain weight of the source domain to obtain the current loss value.
[0104] Specifically, the initial loss of each training sample can be calculated based on the deviation between the prediction result and the actual result of each training sample data. Then, the initial loss of each training sample is weighted according to the domain weight of the source domain to which each training sample belongs, so as to obtain the current loss value.
[0105] S303. Update the parameters of the target model using the current loss value to obtain the trained target model.
[0106] S105. Perform leave-one-out cross-validation on each common segmentation dimension of the target domain and the source domain to obtain the current evaluation index.
[0107] To evaluate the transfer performance of the currently trained target model, a leave-one-out cross-validation method is used. This means that in each training round, one queue of data is set aside as test data for evaluating the target model, while the remaining data is used normally for training, until all queues are used as test data. The set-out data can include not only data from the source domain but also data from the target domain, allowing for cross-validation using data from both domains.
[0108] To fully consider the characteristics of the agricultural field and accurately evaluate the target model, leave-one-out cross-validation is performed on the transfer performance of the currently trained target model across all common splitting dimensions of the target and source domains to obtain the current evaluation metric. Specifically, the training data in the target and / or source domains is split according to the splitting dimensions that the target and source domains can jointly support, resulting in multiple queues of data. For example, if the target and source domains can be split according to the greenhouse dimension, the sample data can be split according to the greenhouse dimension. Then, in each round of training, one queue of data is reserved as test data to evaluate the transfer performance of the currently trained target model, obtaining the current evaluation metric.
[0109] It should be noted that for the remaining segmentation dimensions besides the common segmentation dimension, those segments that are present only in the source domain and not in the target domain will not be used as the main evaluation axis in this round, and no migration conclusions will be output for that dimension. The system should mark such segmentation dimensions as unevaluable or lacking in metadata in the report.
[0110] Optionally, the segmentation dimension may include, but is not limited to, cross-greenhouse segmentation dimension, cross-plot segmentation dimension, cross-seasonal segmentation dimension, and cross-team segmentation dimension.
[0111] Optionally, in another embodiment of this application, one specific implementation of step S105 includes:
[0112] Test sample data will be reserved on the common split dimension and input into the target model for prediction to obtain test results. Based on the test results, each current evaluation index will be calculated.
[0113] The reserved test sample data includes the reserved queue samples of the source domain on the common split dimension and / or the reserved queue samples of the target domain on the common split dimension.
[0114] Optionally, the current evaluation metrics include at least the root mean square error of state prediction, the counterfactual directional consistency rate, and the cross-scenario consistency index. The root mean square error of state prediction is the root mean square of the error between the predicted result and the actual result. The counterfactual directional consistency rate is the proportion of consistency between the direction of change of the predicted result and the theoretically expected direction when the intervention variable was used. The cross-scenario consistency index is an indicator characterizing the model's ability to maintain the consistency of core features under different environments, times, or modalities. Of course, other evaluation metrics can also be calculated as needed.
[0115] S106. Calculate the migration attenuation rate corresponding to the source domain based on the current evaluation index.
[0116] To quantify the rate of memory degradation in cross-domain training, enabling timely transfer control operations on the training data to prevent rapid performance decay and ensure the accuracy of the transfer model, a transfer decay rate is defined as the percentage decrease in the target model's performance in the source domain compared to its performance in the target domain. Since the current evaluation metric reflects the target model's performance in the source domain, by obtaining a quantitative metric for the target model's performance in the target domain based on the current evaluation metric, the transfer decay rate corresponding to the source domain can be calculated.
[0117] Optionally, in another embodiment of this application, one specific implementation of step S106 includes:
[0118] Based on the current evaluation metrics, determine the performance metrics of the target model in the source domain and obtain the performance metrics of the target model in the target domain. Divide the difference between the performance metrics of the target model in the source domain and the performance metrics in the target domain by the performance metrics in the source domain to obtain the migration decay rate corresponding to the source domain.
[0119] Optionally, the sum or weighted result of the current evaluation metrics can be used as the performance metric, or other strategies can be adopted to determine the performance metric of the target model in the source domain.
[0120] Specifically, the training data of the target domain can be input into the target model to output prediction results. Then, based on the prediction results, a metric of the same dimension as the current evaluation metric is calculated. Finally, based on the calculated metric, the performance index of the target model in the target domain is determined. Then, the migration decay rate corresponding to the source domain is calculated using the following formula:
[0121] .
[0122] in, For the target model in the source domain The performance metrics during internal verification, i.e., the performance metrics on the source domain. To use the source domain The target model, after training or weighted training, in the target domain The migration performance on the target domain refers to the performance metrics on the source domain. Migrate to target domain The subsequent performance degradation rate, i.e., the source domain The corresponding migration decay rate.
[0123] S107. Perform migration control operations corresponding to the warning level based on the migration attenuation rate.
[0124] Specifically, a migration attenuation rate can trigger an attenuation warning to execute corresponding control operations. Since different attenuation conditions require different solutions, multiple attenuation rate levels can be defined, allowing for the setting of corresponding warning levels and migration control operations for each warning level. Therefore, migration control operations can be executed based on the warning level at which the current migration attenuation rate falls.
[0125] To control cross-domain eligibility for data from different domains, a (source domain d_s, target domain d_t, task) eligibility gating matrix E is maintained. This matrix includes multiple eligibility identifiers, each representing the eligibility status of a combination of data transferred from the source domain to the target domain for model training and inference within a task. For example, E[d_s,d_t,task]∈{1,0} indicates whether the combination is allowed to transfer training / inference. A value of 1 indicates that the data combination is eligible for training and inference, while a value of 0 indicates that the data combination is not eligible for training and inference; that is, this mechanism is used for model training and inference.
[0126] When the migration decay in the source domain is severe, it indicates that the source domain is no longer suitable for the current task of migrating to the target domain. Therefore, when the warning level is a specified warning level, usually the highest warning level, the eligibility gating matrix is adjusted to adjust the eligibility of the data combination corresponding to the source domain.
[0127] Optionally, in another embodiment of this application, one specific implementation of step S107 includes:
[0128] If the migration decay rate is in a mild range, such as 10%-20%, the suggestion is to add data from the target domain to fine-tune the model. In other words, when the migration decay rate is low, only the target domain data needs to be added to fine-tune the target model.
[0129] If the migration decay rate is in the moderate range, such as 20%-40%, then the feedback should be to recalculate the source domain weights and retrain the model, as well as add data from the target domain for model fine-tuning. Since the problem is more serious at this point, indicating that the current target model is overly biased towards the source domain, it is necessary to recalculate the source domain weights and retrain the model to reduce this bias. Simultaneously, adding data from the target domain for model fine-tuning will optimize its performance.
[0130] If the migration decay rate is in the severe range, such as >40%, then the combination of data to be migrated from the source domain to the target domain will be marked as prohibited in the eligibility gating matrix. Since the problem is very serious at this point, it indicates that the data from the source domain is not suitable for migration to the target domain, so its eligibility flag needs to be adjusted to disable the data combination from the source domain for model training and inference.
[0131] Accordingly, in order to leverage the qualification gating matrix, in another embodiment of this application, the following can be further implemented:
[0132] Query the eligibility gating matrix when training the target model or using the target model for inference.
[0133] If the eligibility flag of the target combination in the eligibility gating matrix is marked as prohibited, then the source domain data corresponding to the target combination is prohibited from participating in training or inference. Here, the target combination is the combination currently used for training or inference that has been migrated from the source domain to the target domain. In other words, if it is marked as prohibited, for example, E=0, then no further steps will be performed on the source domain data of the target combination.
[0134] This application provides a transfer learning method for an agricultural model, which involves acquiring training data for both the target and source domains. Then, using meta-features extracted from the training data, the similarity between the source and target domains is calculated, and the domain weights of the source domain are determined based on this similarity. Next, the target model to be transferred is trained based on the training data and its domain weights. The loss value during training is calculated using the corresponding domain weights of the source domain, thus fully considering the differences between domains and biasing the model towards the source domain, which is similar to the target domain, thereby effectively improving the accuracy of the transferred model. Then, leave-one-out cross-validation is performed on the transfer performance of the currently trained target model along each common segmentation dimension between the target and source domains to obtain the current evaluation index. Considering the characteristics of agriculture, data is segmented according to the agricultural characteristic dimensions that can be used to divide the target domain, and the transfer model is evaluated. Finally, the transfer decay rate corresponding to the source domain is calculated based on the current evaluation index. Transfer control operations with corresponding warning levels are executed based on the transfer decay rate, allowing for timely adjustments to the data based on the defined model transfer decay rate, thereby adjusting the model's performance accordingly. Specifically, when the warning level reaches a specified level, the eligibility gating matrix is adjusted. The eligibility gating matrix includes multiple eligibility identifiers. Each eligibility identifier represents the eligibility status of a combination of data transferred from the source domain to the target domain for participating in model training and inference within a task. This allows for the timely disabling of inapplicable data, preventing its impact on model transfer and thus ensuring model accuracy. Therefore, a method for accurately transferring agricultural models is implemented, thereby guaranteeing the predictive accuracy of the transferred model.
[0135] Another embodiment of this application provides a migration system for agricultural models, such as... Figure 4 As shown, it includes:
[0136] The data acquisition unit 401 is used to acquire training data for the target domain and the source domain.
[0137] The similarity calculation unit 402 is used to calculate the similarity between the source domain and the target domain using meta-features extracted from the training data of the source domain and the target domain.
[0138] The weight determination unit 403 is used to determine the domain weight of the source domain based on the similarity between the source domain and the target domain.
[0139] Training unit 404 is used to train the target model to be transferred based on the training data of the source domain and its domain weights. Specifically, the loss value during training is calculated using weighted averages of the domain weights corresponding to the source domain.
[0140] The performance evaluation unit 405 is used to perform leave-one-out cross-validation on the transfer performance of the currently trained target model on each common segmentation dimension of the target domain and the source domain to obtain the current evaluation index.
[0141] The attenuation calculation unit 406 is used to calculate the migration attenuation rate corresponding to the source domain based on the current evaluation index.
[0142] The early warning operation unit 407 is used to perform migration control operations corresponding to the early warning level based on the migration decay rate. Specifically, when the early warning level is a specified level, the eligibility gating matrix is adjusted. The eligibility gating matrix includes multiple eligibility identifiers. Each eligibility identifier represents the eligibility status of a combination of elements migrating from the source domain to the target domain in a task for participating in model training and inference.
[0143] Optionally, in another embodiment of the agricultural model migration system provided in this application, the similarity calculation unit includes:
[0144] The feature extraction unit is used to extract meta-features of the source domain and the target domain from the training data of the source domain and the target domain, respectively.
[0145] The vectorization unit is used to vectorize the meta-features of the source and target domains to obtain the meta-feature vectors of the source and target domains.
[0146] The distance calculation unit is used to calculate the distance between the source domain and the target domain based on the meta-feature vectors of the source domain and the target domain, and convert the distance into the similarity between the source domain and the target domain through a kernel function.
[0147] Optionally, in another embodiment of the agricultural model transfer system provided in this application, the training unit includes:
[0148] The input unit is used to input each training sample data from the source domain training data into the target model to be transferred for prediction, and obtain the prediction results of each training sample data.
[0149] The loss calculation unit is used to weight the loss of the prediction results of each training sample data according to the domain weight of the source domain to obtain the current loss value.
[0150] The parameter update unit is used to update the parameters of the target model using the current loss value, so as to obtain the trained target model.
[0151] Optionally, in another embodiment of the agricultural model migration system provided in this application, the effect evaluation unit includes:
[0152] The prediction unit is used to input the leave-out test sample data on the common split dimension into the target model for prediction to obtain the test results. The leave-out test sample data includes the leave-out queue samples of the source domain on the common split dimension and / or the leave-out queue samples of the target domain on the common split dimension.
[0153] The metric calculation unit is used to calculate various current evaluation metrics based on the test results. These current evaluation metrics include at least the root mean square error of state prediction, the counterfactual directional consistency rate, and the cross-scenario consistency index.
[0154] Optionally, in another embodiment of the agricultural model migration system provided in this application, the attenuation calculation unit includes:
[0155] The performance determination unit is used to determine the performance metrics of the target model in the source domain based on the current evaluation metrics, and to obtain the performance metrics of the target model in the target domain.
[0156] The attenuation rate calculation unit is used to divide the difference between the performance index of the target model in the source domain and the performance index in the target domain by the performance index in the source domain to obtain the migration attenuation rate corresponding to the source domain.
[0157] Optionally, in another embodiment of the agricultural model migration system provided in this application, the early warning operation unit includes:
[0158] The first operating unit is used to provide suggestions for fine-tuning the model by adding data from the target domain when the migration decay rate is in the mild decay rate range.
[0159] The second operation unit is used to provide feedback suggestions on recalculating the domain weights of the source domain and retraining, as well as adding data from the target domain to fine-tune the model when the migration decay rate is in the moderate decay rate range.
[0160] The third operation unit is used to mark the combination of migrating from the source domain to the target domain as prohibited in the qualification gating matrix when the migration decay rate is in the range of severe decay rate.
[0161] Optionally, in another embodiment of the agricultural model migration system provided in this application, the system further includes:
[0162] The query unit is used to query the eligibility gating matrix when training the target model or using the target model for inference.
[0163] The disable unit is used to prevent source domain data corresponding to the target combination from participating in training or inference when the qualification identifier of the target combination in the qualification gating matrix is marked as disabled. The target combination is the combination currently used for training or inference that has been migrated from the source domain to the target domain.
[0164] Another embodiment of this application provides an electronic device, such as... Figure 5 As shown, it includes:
[0165] Memory 501 and processor 502.
[0166] The memory 501 is used to store the program.
[0167] The processor 502 is used to execute the program stored in the memory 501, which, when executed, is specifically used to implement the migration method of the agricultural model as provided in any of the above embodiments.
[0168] Another embodiment of this application provides a computer storage medium for storing a computer program, which, when executed by a processor, is used to implement the agricultural model migration method provided in any of the above embodiments.
[0169] Computer storage media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0170] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0171] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for transferring agricultural models, characterized in that, include: Obtain training data for the target and source domains; The similarity between the source domain and the target domain is calculated using meta-features extracted from the training data of the source domain and the target domain. The domain weight of the source domain is determined based on the similarity between the source domain and the target domain. Based on the training data of the source domain and its domain weights, the target model to be transferred is trained; wherein, the loss value during training is calculated by weighting the domain weights corresponding to the source domain. Leave-one-out cross-validation is performed on the transfer performance of the currently trained target model on each common segmentation dimension of the target domain and the source domain to obtain the current evaluation index. Calculate the migration attenuation rate corresponding to the source domain based on the current evaluation index; The migration control operation corresponding to the warning level is executed according to the migration decay rate; wherein, when the warning level is a specified warning level, the eligibility gating matrix is adjusted; the eligibility gating matrix includes multiple eligibility identifiers; each eligibility identifier represents the eligibility status of a combination of migrations from the source domain to the target domain in a task to participate in model training and inference.
2. The method according to claim 1, characterized in that, The step of calculating the similarity between the source domain and the target domain using meta-features extracted from the training data of the source domain and the target domain includes: Meta-features of the source domain and the target domain are extracted from the training data of the source domain and the target domain, respectively. The meta-features of the source domain and the target domain are vectorized to obtain the meta-feature vectors of the source domain and the target domain; Based on the meta-feature vectors of the source domain and the target domain, the distance between the source domain and the target domain is calculated, and the distance is converted into the similarity between the source domain and the target domain through a kernel function.
3. The method according to claim 1, characterized in that, The training of the target model to be transferred based on the training data of the source domain and its domain weights includes: Each training sample data from the training data in the source domain is input into the target model to be transferred for prediction, and the prediction results of each training sample data are obtained. The loss of the prediction results of each training sample data is weighted according to the domain weight of the source domain to obtain the current loss value; The parameters of the target model are updated using the current loss value to obtain the trained target model.
4. The method according to claim 1, characterized in that, The transfer performance of the currently trained target model is evaluated using leave-one-out cross-validation on each common segmentation dimension between the target domain and the source domain to obtain the current evaluation metric, including: The test sample data left out on the common segmentation dimension is input into the target model for prediction to obtain the test results; wherein, the test sample data left out includes the left-out queue samples of the source domain on the common segmentation dimension and / or the left-out queue samples of the target domain on the common segmentation dimension; Based on the test results, each current evaluation metric is calculated; wherein, the current evaluation metric includes at least the root mean square error of state prediction, the counterfactual direction consistency rate, and the cross-scenario consistency index.
5. The method according to claim 1, characterized in that, The step of calculating the migration attenuation rate corresponding to the source domain based on the current evaluation metric includes: Based on the current evaluation metrics, determine the performance metrics of the target model in the source domain, and obtain the performance metrics of the target model in the target domain; The difference between the performance index of the target model in the source domain and the performance index in the target domain is divided by the performance index in the source domain to obtain the migration decay rate corresponding to the source domain.
6. The method according to claim 1, characterized in that, The step of performing migration control operations corresponding to the warning level based on the migration attenuation rate includes: If the migration decay rate is within the mild decay rate range, a suggestion is made to increase the data in the target domain for model fine-tuning. If the migration decay rate is in the moderate decay rate range, then a suggestion is given to recalculate the domain weights of the source domain and retrain, and to add data from the target domain to fine-tune the model. If the migration decay rate is within the range of severe decay rates, then the combination of migrating from the source domain to the target domain is marked as prohibited in the eligibility gating matrix.
7. The method according to claim 6, characterized in that, Also includes: The eligibility gating matrix is queried when training the target model or when using the target model for inference. If the eligibility identifier of the target combination in the eligibility gating matrix is marked as prohibited, then the source domain data corresponding to the target combination is prohibited from participating in training or inference; wherein, the target combination is the combination currently used for training or inference that has been migrated from the source domain to the target domain.
8. A transfer system for an agricultural model, characterized in that, include: The data acquisition unit is used to acquire training data from the target domain and the source domain. A similarity calculation unit is used to calculate the similarity between the source domain and the target domain using meta-features extracted from the training data of the source domain and the target domain. The weight determination unit is used to determine the domain weight of the source domain based on the similarity between the source domain and the target domain. The training unit is used to train the target model to be transferred based on the training data of the source domain and its domain weights; wherein, the loss value during training is calculated by weighting the domain weights corresponding to the source domain. The performance evaluation unit is used to perform leave-one-out cross-validation on the transfer performance of the currently trained target model on each common segmentation dimension of the target domain and the source domain, respectively, to obtain the current evaluation index. The attenuation calculation unit is used to calculate the migration attenuation rate corresponding to the source domain based on the current evaluation index. The early warning operation unit is used to perform migration control operations corresponding to the early warning level according to the migration decay rate; wherein, when the early warning level is a specified early warning level, the qualification gating matrix is adjusted; the qualification gating matrix includes multiple qualification identifiers; each qualification identifier represents the qualification status of a combination of migrations from the source domain to the target domain in a task to participate in model training and inference.
9. An electronic device, characterized in that, include: Memory and processor; The memory is used to store programs; The processor is used to execute the program, which, when executed, is specifically used to implement the agricultural model migration method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, is used to implement the migration method of the agricultural model as described in any one of claims 1 to 7.