Method and device for optimizing hyper-parameters in learning model algorithm and storage medium
By pre-constructing a hyperparameter database and importance sorting, the hyperparameter range is gradually narrowed, and the hyperparameter combination of the integrated learning model is optimized, which solves the problem of unreasonable initial range setting and improves the computing efficiency and prediction accuracy.
Patent Information
- Application Number
- CN202411050289.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-29
AI Technical Summary
In the prior art, the initial range of hyperparameters is set in the integrated learning model algorithm unreasonable, resulting in too long time to find the best hyperparameter combination, wasted computing time, and the prediction accuracy may not necessarily be improved after multiple iterations of training.
By pre-constructing a hyperparameter database, obtain the initial range of hyperparameters under different task types, find the initial range of models of the same type based on the task type, sort the importance, set the data interval for data expansion and tuning, and gradually narrow the scope to find the best Variable combination.
Reduces calculation time, ensures the accuracy of the final calculation results, and improves the prediction performance of the model.
Smart Images

Figure CN119047603A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of model tuning, and in particular to a method, device and storage medium for optimizing hyperparameters in a learning model algorithm. Background Art
[0002] With the rise of machine learning algorithms, ensemble learning model algorithms have been widely used in various fields. Compared with algorithms based on single model learning, ensemble learning model algorithms combine multiple basic models to improve the final prediction accuracy. Each basic model has its own advantages and disadvantages. If unrelated basic models are fused, the advantages of one basic model may make up for the disadvantages of another basic model. The interaction between different basic models will produce a model with better performance.
[0003] The application scenarios of integrated learning model algorithms are relatively rich, and common ones are image classification tasks, probability prediction tasks, time series value prediction tasks, etc. Therefore, for different data sets and different tasks, the hyperparameter setting and optimization of the model algorithm become crucial. If the input data set is relatively large, the computational cost of each model training should not be underestimated.
[0004] There are many methods for optimizing hyperparameters in ensemble learning model algorithms, such as manual retrieval, grid retrieval, random grid retrieval, Bayesian optimization, etc. However, before using these methods, it is necessary to set the initial ranges of different hyperparameters and then find the best hyperparameter combination suitable for the data set. When setting the initial range of hyperparameters for the first time, algorithm developers usually use default values or existing values, try training first, and then adjust the range by checking the results. However, for different task requirements, the initial ranges of hyperparameters set by the corresponding basic model algorithms vary greatly. If the initial range of hyperparameters of the model algorithm for the input data set is not set reasonably, but repeated training is used to adjust the reasonable range of hyperparameters to find the best hyperparameter combination, it will greatly waste computing time, and the final prediction accuracy may not necessarily improve after multiple iterative training. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a method, device and storage medium for optimizing hyperparameters in a learning model algorithm, so as to solve the problem in the prior art that the initial range of hyperparameters adopts default values or existing values, the initial range of hyperparameters is too large, resulting in a long time to find the best hyperparameter combination, wasting computing time, and the final prediction accuracy may not necessarily improve after multiple iterative training.
[0006] According to a first aspect of an embodiment of the present invention, a method for optimizing hyperparameters in a learning model algorithm is provided, the method comprising:
[0007] Obtain an algorithm model to be optimized, and search a pre-built hyperparameter database for initial ranges of various hyperparameters of the algorithm model under the same task type based on the task type of the algorithm model to be optimized;
[0008] Running the algorithm model to be optimized based on the initial range of each hyperparameter, obtaining the comprehensive training score of each hyperparameter in the algorithm model to be optimized based on the running result, and ranking the importance of each hyperparameter based on the comprehensive training score of each hyperparameter;
[0009] Select the top N hyperparameters as key hyperparameters based on their importance, and record the importance ranking and initial range of each key hyperparameter.
[0010] Setting the data interval of the initial range of each key hyperparameter to a first preset interval, and performing data expansion on each key hyperparameter within the initial range according to the first preset interval to obtain a first data interval corresponding to each key hyperparameter;
[0011] According to the order of the importance of key hyperparameters, each key hyperparameter is tuned in the corresponding first data interval to obtain the training score of the key hyperparameter in the corresponding first data interval. During each key hyperparameter tuning process, the remaining hyperparameters remain default, and the optimal result obtained in the previous key hyperparameter tuning process is used as the input of the next key hyperparameter tuning process;
[0012] Sort the key hyperparameters by their importance, traverse all the key hyperparameters, and obtain the training score of each key hyperparameter in the corresponding first data interval;
[0013] Obtain a first segmentation threshold according to a training score of each key hyperparameter in a corresponding first data interval, and obtain a second data interval of each key hyperparameter according to the first segmentation threshold;
[0014] Divide the second data interval into multiple variable intervals according to a preset data scale, obtain the average training score of each variable interval, and take the variable interval with the highest average training score as the third data interval;
[0015] The third data interval corresponding to each key hyperparameter is used as input for the next step of searching for the optimal variable combination of the algorithm model to be optimized, so as to obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
[0016] Preferably,
[0017] The pre-built hyperparameter database includes:
[0018] Obtain the minimum and maximum values of each hyperparameter in the training iteration process of different algorithm models in different historical task types, and obtain the initial range of each hyperparameter under different task types;
[0019] A hyperparameter database is established based on the initial range of each hyperparameter under different task types.
[0020] Preferably,
[0021] The method of sorting the key hyperparameters according to their importance, tuning each key hyperparameter in the corresponding first data interval, obtaining the training score of the key hyperparameter in the corresponding first data interval, keeping the other hyperparameters as default in each key hyperparameter tuning process, and using the optimal result obtained in the previous key hyperparameter tuning process as the input of the next key hyperparameter tuning process according to the control variable method includes:
[0022] According to the order of importance of key hyperparameters, keep the remaining hyperparameters except the key hyperparameter ranked first in importance as default, obtain the training score of the algorithm model to be optimized when the key hyperparameter ranked first in importance takes a value in the corresponding first data interval, obtain the optimal value of the key hyperparameter ranked first in importance in the corresponding first data interval according to the training score, and complete the tuning of the key hyperparameter ranked first in importance;
[0023] The value of the key hyperparameter ranked first in importance is fixed as the optimal value of the corresponding first data interval and remains unchanged, and the remaining hyperparameters except the key hyperparameter ranked second in importance are kept as default, and the training score of the algorithm model to be optimized is obtained when the key hyperparameter ranked second in importance takes the value in the corresponding first data interval, and the optimal value of the key hyperparameter ranked second in importance in the corresponding first data interval is obtained according to the training score, and the tuning of the key hyperparameter ranked second in importance is completed;
[0024] The value of the key hyperparameter ranked second in importance is fixed as the optimal value of the corresponding first data interval and remains unchanged, and the remaining hyperparameters except the key hyperparameter ranked third in importance are kept as default, and the training score of the algorithm model to be optimized is obtained when the key hyperparameter ranked third in importance takes the value of the corresponding first data interval, and the optimal value of the key hyperparameter ranked third in importance in the corresponding first data interval is obtained according to the training score, and the tuning of the key hyperparameter ranked third in importance is completed;
[0025] Repeat the tuning process of each key hyperparameter until all key hyperparameters are traversed in order of importance, and obtain the training score of each key hyperparameter in the corresponding first data interval.
[0026] Preferably,
[0027] The first segmentation threshold comprises:
[0028] The first segmentation threshold indicates that when the key hyperparameter takes a value greater than the first segmentation threshold in the corresponding first data interval, the training score of the algorithm model to be optimized no longer changes.
[0029] Preferably, it also includes:
[0030] The training score of each key hyperparameter in the corresponding first data interval is visualized in the form of a box plot.
[0031] Preferably, it also includes:
[0032] Setting the data interval of the third data interval of each key hyperparameter to a second preset interval, where the second preset interval is smaller than the first preset interval, and performing data distribution encryption on the third data interval by using the second preset interval to obtain a fourth data interval;
[0033] The fourth data interval corresponding to each key hyperparameter is used as input for the next step of searching for the optimal variable combination of the algorithm model to be optimized, so as to obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
[0034] According to a second aspect of an embodiment of the present invention, a device for optimizing hyperparameters in a learning model algorithm is provided, the device comprising:
[0035] Initial range search module: used to obtain the algorithm model to be optimized, and search the initial range of each hyperparameter of the algorithm model under the same task type in the pre-built hyperparameter database based on the task type of the algorithm model to be optimized;
[0036] Importance acquisition module: used for running the algorithm model to be optimized based on the initial range of each hyperparameter, obtaining the comprehensive training score of each hyperparameter in the algorithm model to be optimized based on the running result, and ranking the importance of each hyperparameter based on the comprehensive training score of each hyperparameter;
[0037] Key hyperparameter acquisition module: used to select the top N hyperparameters as key hyperparameters according to the hyperparameter importance ranking, and record the importance ranking and initial range of each key hyperparameter;
[0038] A first data interval acquisition module: used to set the data interval of the initial range of each key hyperparameter to a first preset interval, and perform data expansion on each key hyperparameter within the initial range according to the first preset interval to obtain a first data interval corresponding to each key hyperparameter;
[0039] Iterative tuning module: used to sort key hyperparameters according to their importance, tune each key hyperparameter in the corresponding first data interval, obtain the training score of the key hyperparameter in the corresponding first data interval, and in each key hyperparameter tuning process, keep the other hyperparameters as default, and use the optimal result obtained in the previous key hyperparameter tuning process as the input of the next key hyperparameter tuning process;
[0040] Training score acquisition module: used to sort the key hyperparameters according to their importance, traverse all the key hyperparameters, and obtain the training score of each key hyperparameter in the corresponding first data interval;
[0041] A second data interval acquisition module: acquiring a first segmentation threshold according to a training score of each key hyperparameter in the corresponding first data interval, and acquiring a second data interval of each key hyperparameter according to the first segmentation threshold;
[0042] A third data interval acquisition module: used to divide the second data interval into multiple variable intervals according to a preset data scale, and obtain the average training score of each variable interval respectively, and take the variable interval with the highest average training score as the third data interval;
[0043] Optimal variable combination search module: used to use the third data interval corresponding to each key hyperparameter as the input for the next optimal variable combination search of the algorithm model to be optimized, and obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
[0044] According to a third aspect of an embodiment of the present invention, there is provided a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a main controller, each step in the above method is implemented.
[0045] The technical solution provided by the embodiments of the present invention may have the following beneficial effects:
[0046] Based on the existing default initial range of hyperparameters or the existing initial range, the present application does not directly use the initial range for searching the optimal variable combination of the hyperparameters, but determines the key hyperparameters under the same task type according to the initial range, and then expands the data of the initial range according to the first preset interval to obtain a first data interval, iteratively tunes according to the importance of the key hyperparameter, obtains the training score of the key hyperparameter in the first data interval, obtains the first segmentation threshold according to the training score, narrows the first data interval for the first time by the first segmentation threshold to obtain the second data interval, and then compares the average training scores of the second data interval to obtain the third data interval, thereby achieving a second narrowing of the range; the search for the optimal variable combination of the hyperparameters is achieved through the range after the second narrowing, and since the training score is always used as the basis for narrowing during the narrowing process, the present application can not only reduce the calculation time, but also ensure the accuracy of the final calculation result.
[0047] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0049] Figure 1 is a flowchart of a method for optimizing hyperparameters in a learning model algorithm according to an exemplary embodiment;
[0050] Figure 2 is a box plot of training scores of key hyperparameters in corresponding first data intervals according to another exemplary embodiment;
[0051] Figure 3 is a system schematic diagram of a device for optimizing hyperparameters in a learning model algorithm according to another exemplary embodiment;
[0052] In the accompanying drawings: 1-initial range search module, 2-importance acquisition module, 3-key hyperparameter acquisition module, 4-first data interval acquisition module, 5-iterative tuning module, 6-training score acquisition module, 7-second data interval acquisition module, 8-third data interval acquisition module, 9-optimal variable combination search module. DETAILED DESCRIPTION
[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0054] Embodiment 1
[0055] Figure 1 is a flow chart of a method for optimizing hyperparameters in a learning model algorithm according to an exemplary embodiment. Figure 1 As shown, the method includes:
[0056] S1, obtaining an algorithm model to be optimized, and searching a pre-built hyperparameter database for initial ranges of various hyperparameters of the algorithm model under the same task type based on the task type of the algorithm model to be optimized;
[0057] S2, running the algorithm model to be optimized based on the initial range of each hyperparameter, obtaining the comprehensive training score of each hyperparameter in the algorithm model to be optimized based on the running result, and ranking the importance of each hyperparameter based on the comprehensive training score of each hyperparameter;
[0058] S3, select the top N hyperparameters as key hyperparameters according to the ranking of hyperparameter importance, and record the importance ranking and initial range of each key hyperparameter;
[0059] S4, setting the data interval of the initial range of each key hyperparameter to a first preset interval, and performing data expansion on each key hyperparameter within the initial range according to the first preset interval to obtain a first data interval corresponding to each key hyperparameter;
[0060] S5, sorting the key hyperparameters according to their importance, tuning each key hyperparameter in the corresponding first data interval, obtaining the training score of the key hyperparameter in the corresponding first data interval, in each key hyperparameter tuning process, keeping the other hyperparameters as default, and using the optimal result obtained in the previous key hyperparameter tuning process as the input of the next key hyperparameter tuning process;
[0061] S6, sorting the key hyperparameters according to their importance, traversing all the key hyperparameters, and obtaining a training score for each key hyperparameter in the corresponding first data interval;
[0062] S7, obtaining a first segmentation threshold according to a training score of each key hyperparameter in a corresponding first data interval, and obtaining a second data interval of each key hyperparameter according to the first segmentation threshold;
[0063] S8, dividing the second data interval into multiple variable intervals according to a preset data scale, and obtaining an average training score for each variable interval respectively, and taking a variable interval with the highest average training score as the third data interval;
[0064] S9, using the third data interval corresponding to each key hyperparameter as input for searching for the next optimal variable combination of the algorithm model to be optimized, and obtaining the optimal variable combination of the key hyperparameters of the algorithm model to be optimized;
[0065] It is understandable that the present application first needs to establish a hyperparameter database, that is, the default initial range of each hyperparameter. It is worth emphasizing that since the initial range of the hyperparameter is different when each algorithm model is used for different task types, when establishing the hyperparameter database, the default initial range of the hyperparameter of the same algorithm model under different task types should be obtained for different task types respectively, and the default initial range is determined by the numerical changes of the hyperparameters of the same historical task type and the same algorithm model during the iteration process. In short, for the algorithm model, under all the same task types in history, in countless iterations, the minimum value that appears is X and the maximum value is Y, then the default initial range of the hyperparameter is (X, Y), and the algorithm model and task type corresponding to the hyperparameter are stored together in the hyperparameter database, so as to establish the hyperparameter database;
[0066] After the hyperparameter database is built, for the algorithm model to be optimized, its task type is determined, and the default initial ranges of all hyperparameters corresponding to the algorithm model under the same task type are queried in the hyperparameter database;
[0067] The algorithm model to be optimized is run for the first time based on the default initial range of all hyperparameters. The criticality of all hyperparameters is ranked by the comprehensive training score calculation formula. The calculation formula for the comprehensive training score is as follows:
[0068]
[0069] Among them, Performance Score is the training score result of different hyperparameters using cross-validation method on the algorithm model, cv * is the best training score result in the cross-validation process, and ov is the best training score result in the algorithm model evaluation process. is the average of all training score results in the cross-validation process. The subscript m represents different algorithm models, the subscript i represents different hyperparameters, and the subscript t represents different task types.
[0070] The initial training score of each hyperparameter is sorted to obtain the hyperparameter importance ranking, and the top N hyperparameters are selected as key hyperparameters. The value of N varies according to different task types and algorithm models, and this embodiment does not impose any restrictions on this.
[0071] In this embodiment, it is assumed that there are three key hyperparameters, which are hyperparameter A, hyperparameter B, and hyperparameter C in order of importance. It is assumed that the default initial range of hyperparameter A is (1, 10) queried from the hyperparameter database. In order to ensure that the distribution range of hyperparameter values is wide and sparse, it is necessary to expand the default initial range by the first preset interval to obtain the first data interval. Assuming that the first preset interval is 3, the first data interval is (1, 4, 7, 10);
[0072] In the process of tuning the key hyperparameter A, except for hyperparameter A, the rest of the hyperparameters in the model are temporarily kept at the default values. Only the training score changes in the model algorithm when hyperparameter A is in the set first data interval are checked, and the results are visualized in the form of a box plot. According to the training results of hyperparameter A, the optimal value A_best of hyperparameter A can be obtained, assuming it is 4. Then, hyperparameter B is tuned, and the value of the first hyperparameter A is updated from the default value to A_best, that is, 4, and used as the input of the tuning step of hyperparameter B. The rest of the hyperparameters are kept at the default values again. At this time, the hyperparameter combination list should be {hyperparameter B: corresponding first data interval; hyperparameter A: A _best; other hyperparameters: keep default}, check the training results of hyperparameter B, and get the optimal value B_best of hyperparameter B; finally, tune hyperparameter C, update the value of hyperparameter B, and keep the default values of other hyperparameters. The hyperparameter list at this time should be {variable C: corresponding first data interval; hyperparameter A: A_best; hyperparameter B: B_best; other hyperparameters: keep default}, and so on. Each time a single key hyperparameter is tuned, the optimal result obtained in the previous key hyperparameter tuning process needs to be used as the input of the next key hyperparameter tuning process, and the control variable method is combined with iterative update to achieve iterative tuning of key hyperparameters.
[0073] Through the above steps, the training results of three hyperparameters A, B and C are obtained respectively, and are displayed in the form of box plots, as shown in the attached figure. Figure 2 As shown in the figure, the horizontal axis is the value of the hyperparameter A, and the vertical axis is the evaluation index selected as the accuracy of the output result of the evaluation model; taking the hyperparameter A as an example, from the attached Figure 2It can be clearly seen that the hyperparameter A in the model algorithm is within the interval (a, b), and it increases step by step with a spacing of c (i.e., the first preset interval). Regarding the change in the training score of the corresponding algorithm model, after it is greater than a certain value d (i.e., the first segmentation threshold), the training score no longer changes, indicating that after being greater than the value d, the increase in the value of the hyperparameter A has no impact on the model accuracy. Then, the interval greater than the value d (d < b) can be discarded, and the variable interval range can be further shortened from (a, b) to (a, d), which is the second data interval mentioned above. Based on this, the second data interval (a, d) is divided into multiple data intervals according to the preset data scale, and the average value of the training scores of each data interval is calculated respectively. It can be further seen that the average training result of the hyperparameter A in the data interval (e, f) is relatively good, where (e, f) is a subset of (a, d). Once again, the interval range is narrowed, which is the third data interval. Finally, the effective preliminary preset interval of the hyperparameter A is determined as (e, f);
[0074] Similarly, the third data interval of each key hyperparameter is obtained;
[0075] Since the third data interval (e, f) is obtained after two contractions of the first data interval (a, b), but the interval is not changed during the two contraction processes, that is, the above-mentioned interval c. However, since the interval c will be set to be larger when setting it, the purpose is to reduce the running time of the algorithm model to more quickly determine the rough upper and lower limits of the effective interval (the third data interval). After determining the third data interval (e, f), the interval c needs to be reduced to i (i < c) (the interval i is the second preset interval mentioned above), and the data distribution within the third data interval (e, f) is encrypted. Suppose that before the distribution encryption of (e, f), that is, when distributed with an interval of c, the value of the interval c is 2, then the third data interval is (1, 3, 5, 7). Then, after reducing the interval c to the interval i, the value of the interval i is 1, and the fourth data interval is (1, 2, 3, 4, 5, 6, 7);
[0076] The fourth data interval of each key hyperparameter is used as the input for the next search for the optimal variable combination, which is convenient for more quickly and better finding the optimal variable combination to improve the accuracy of the model output result;
[0077] Based on the existing default initial range of hyperparameters or the existing initial range, the present application does not directly use the initial range for searching the optimal variable combination of the hyperparameters, but determines the key hyperparameters under the same task type according to the initial range, and then expands the data of the initial range according to the first preset interval to obtain a first data interval, iteratively tunes according to the importance of the key hyperparameter, obtains the training score of the key hyperparameter in the first data interval, obtains the first segmentation threshold according to the training score, narrows the first data interval for the first time by the first segmentation threshold to obtain the second data interval, and then compares the average training scores of the second data interval to obtain the third data interval, thereby achieving a second narrowing of the range; the search for the optimal variable combination of the hyperparameters is achieved through the range after the second narrowing, and since the training score is always used as the basis for narrowing during the narrowing process, the present application can not only reduce the calculation time, but also ensure the accuracy of the final calculation result.
[0078] Embodiment 2:
[0079] Figure 3 is a system schematic diagram of a device for optimizing hyperparameters in a learning model algorithm according to another exemplary embodiment, the device comprising:
[0080] Initial range search module 1: used to obtain the algorithm model to be optimized, and search the initial range of each hyperparameter of the algorithm model under the same task type in the pre-built hyperparameter database based on the task type of the algorithm model to be optimized;
[0081] Importance acquisition module 2: used to run the algorithm model to be optimized based on the initial range of each hyperparameter, obtain the comprehensive training score of each hyperparameter in the algorithm model to be optimized based on the running result, and sort the importance of each hyperparameter based on the comprehensive training score of each hyperparameter;
[0082] Key hyperparameter acquisition module 3: used to select the top N hyperparameters as key hyperparameters according to the hyperparameter importance ranking, and record the importance ranking and initial range of each key hyperparameter;
[0083] The first data interval acquisition module 4 is used to set the data interval of the initial range of each key hyperparameter to a first preset interval, and perform data expansion on each key hyperparameter within the initial range according to the first preset interval to obtain a first data interval corresponding to each key hyperparameter;
[0084] Iterative tuning module 5: used to sort the key hyperparameters according to their importance, tune each key hyperparameter in the corresponding first data interval, obtain the training score of the key hyperparameter in the corresponding first data interval, in each key hyperparameter tuning process, the other hyperparameters remain default, and the optimal result obtained in the previous key hyperparameter tuning process is used as the input of the next key hyperparameter tuning process;
[0085] Training score acquisition module 6: used to sort the key hyperparameters according to their importance, traverse all the key hyperparameters, and obtain the training score of each key hyperparameter in the corresponding first data interval;
[0086] Second data interval acquisition module 7: acquiring a first segmentation threshold according to the training score of each key hyperparameter in the corresponding first data interval, and acquiring a second data interval of each key hyperparameter according to the first segmentation threshold;
[0087] The third data interval acquisition module 8 is used to divide the second data interval into multiple variable intervals according to a preset data scale, and obtain the average training score of each variable interval respectively, and take the variable interval with the highest average training score as the third data interval;
[0088] Optimal variable combination search module 9: used to use the third data interval corresponding to each key hyperparameter as input for the next optimal variable combination search of the algorithm model to be optimized, and obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
[0089] Embodiment three:
[0090] This embodiment provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a main controller, each step in the above method is implemented;
[0091] It is understandable that the storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0092] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0093] It should be noted that, in the description of the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0094] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0095] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0096] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0097] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0098] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0099] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0100] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for optimizing hyperparameters in a learning model algorithm, characterized in that: The method comprises: Obtain an algorithm model to be optimized, and search a pre-built hyperparameter database for initial ranges of various hyperparameters of the algorithm model under the same task type based on the task type of the algorithm model to be optimized; Running the algorithm model to be optimized based on the initial range of each hyperparameter, obtaining the comprehensive training score of each hyperparameter in the algorithm model to be optimized based on the running result, and ranking the importance of each hyperparameter based on the comprehensive training score of each hyperparameter; Select the top N hyperparameters as key hyperparameters based on their importance, and record the importance ranking and initial range of each key hyperparameter. Setting the data interval of the initial range of each key hyperparameter to a first preset interval, and performing data expansion on each key hyperparameter within the initial range according to the first preset interval to obtain a first data interval corresponding to each key hyperparameter; According to the order of the importance of key hyperparameters, each key hyperparameter is tuned in the corresponding first data interval to obtain the training score of the key hyperparameter in the corresponding first data interval. During each key hyperparameter tuning process, the remaining hyperparameters remain default, and the optimal result obtained in the previous key hyperparameter tuning process is used as the input of the next key hyperparameter tuning process; Sort the key hyperparameters by their importance, traverse all the key hyperparameters, and obtain the training score of each key hyperparameter in the corresponding first data interval; Obtain a first segmentation threshold according to a training score of each key hyperparameter in a corresponding first data interval, and obtain a second data interval of each key hyperparameter according to the first segmentation threshold; Divide the second data interval into multiple variable intervals according to a preset data scale, obtain the average training score of each variable interval, and take the variable interval with the highest average training score as the third data interval; The third data interval corresponding to each key hyperparameter is used as input for the next step of searching for the optimal variable combination of the algorithm model to be optimized, so as to obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
2. The method according to claim 1, characterized in that The pre-built hyperparameter database includes: Obtain the minimum and maximum values of each hyperparameter in the training iteration process of different algorithm models in different historical task types, and obtain the initial range of each hyperparameter under different task types; A hyperparameter database is established based on the initial range of each hyperparameter under different task types.
3. The method according to claim 2, characterized in that The method of sorting the key hyperparameters according to their importance, tuning each key hyperparameter in the corresponding first data interval, obtaining the training score of the key hyperparameter in the corresponding first data interval, keeping the other hyperparameters as default in each key hyperparameter tuning process, and using the optimal result obtained in the previous key hyperparameter tuning process as the input of the next key hyperparameter tuning process according to the control variable method includes: According to the order of importance of key hyperparameters, keep the remaining hyperparameters except the key hyperparameter ranked first in importance as default, obtain the training score of the algorithm model to be optimized when the key hyperparameter ranked first in importance takes a value in the corresponding first data interval, obtain the optimal value of the key hyperparameter ranked first in importance in the corresponding first data interval according to the training score, and complete the tuning of the key hyperparameter ranked first in importance; The value of the key hyperparameter ranked first in importance is fixed as the optimal value of the corresponding first data interval and remains unchanged, and the remaining hyperparameters except the key hyperparameter ranked second in importance are kept as default, and the training score of the algorithm model to be optimized is obtained when the key hyperparameter ranked second in importance takes the value in the corresponding first data interval, and the optimal value of the key hyperparameter ranked second in importance in the corresponding first data interval is obtained according to the training score, and the tuning of the key hyperparameter ranked second in importance is completed; The value of the key hyperparameter ranked second in importance is fixed as the optimal value of the corresponding first data interval and remains unchanged, and the remaining hyperparameters except the key hyperparameter ranked third in importance are kept as default, and the training score of the algorithm model to be optimized is obtained when the key hyperparameter ranked third in importance takes the value of the corresponding first data interval, and the optimal value of the key hyperparameter ranked third in importance in the corresponding first data interval is obtained according to the training score, and the tuning of the key hyperparameter ranked third in importance is completed; Repeat the tuning process of each key hyperparameter until all key hyperparameters are traversed in order of importance, and obtain the training score of each key hyperparameter in the corresponding first data interval.
4. The method according to claim 3, characterized in that The first segmentation threshold comprises: The first segmentation threshold indicates that when the key hyperparameter takes a value greater than the first segmentation threshold in the corresponding first data interval, the training score of the algorithm model to be optimized no longer changes.
5. The method according to claim 4, characterized in that Also includes: The training score of each key hyperparameter in the corresponding first data interval is visualized in the form of a box plot.
6. The method according to claim 5, characterized in that Also includes: Setting the data interval of the third data interval of each key hyperparameter to a second preset interval, where the second preset interval is smaller than the first preset interval, and performing data distribution encryption on the third data interval by using the second preset interval to obtain a fourth data interval; The fourth data interval corresponding to each key hyperparameter is used as input for the next step of searching for the optimal variable combination of the algorithm model to be optimized, so as to obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
7. A device for optimizing hyperparameters in a learning model algorithm, characterized in that: The device comprises: Initial range search module: used to obtain the algorithm model to be optimized, and search the initial range of each hyperparameter of the algorithm model under the same task type in the pre-built hyperparameter database based on the task type of the algorithm model to be optimized; Importance acquisition module: used for running the algorithm model to be optimized based on the initial range of each hyperparameter, obtaining the comprehensive training score of each hyperparameter in the algorithm model to be optimized based on the running result, and ranking the importance of each hyperparameter based on the comprehensive training score of each hyperparameter; Key hyperparameter acquisition module: used to select the top N hyperparameters as key hyperparameters according to the hyperparameter importance ranking, and record the importance ranking and initial range of each key hyperparameter; A first data interval acquisition module: used to set the data interval of the initial range of each key hyperparameter to a first preset interval, and perform data expansion on each key hyperparameter within the initial range according to the first preset interval to obtain a first data interval corresponding to each key hyperparameter; Iterative tuning module: used to sort key hyperparameters according to their importance, tune each key hyperparameter in the corresponding first data interval, obtain the training score of the key hyperparameter in the corresponding first data interval, and in each key hyperparameter tuning process, keep the other hyperparameters as default, and use the optimal result obtained in the previous key hyperparameter tuning process as the input of the next key hyperparameter tuning process; Training score acquisition module: used to sort the key hyperparameters according to their importance, traverse all the key hyperparameters, and obtain the training score of each key hyperparameter in the corresponding first data interval; A second data interval acquisition module: acquiring a first segmentation threshold according to a training score of each key hyperparameter in the corresponding first data interval, and acquiring a second data interval of each key hyperparameter according to the first segmentation threshold; A third data interval acquisition module: used to divide the second data interval into multiple variable intervals according to a preset data scale, and obtain the average training score of each variable interval respectively, and take the variable interval with the highest average training score as the third data interval; Optimal variable combination search module: used to use the third data interval corresponding to each key hyperparameter as the input for the next optimal variable combination search of the algorithm model to be optimized, and obtain the optimal variable combination of the key hyperparameters of the algorithm model to be optimized.
8. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the main controller, it implements each step in the method for optimizing hyperparameters in a learning model algorithm as described in any one of claims 1-6.
Citation Information
Cited By
Traditional Chinese medicine planting soil quality monitoring method and system based on big data analysis
CN120707324A
Traditional Chinese medicine planting soil quality monitoring method and system based on big data analysis
CN120707324B
