A model training method and device, and a model training tool generation method
By generating a base function library tool, the problem of large coding workload in CPU and GPU model training is solved, and efficient cross-platform model training is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DATACANVAS LTD
- Filing Date
- 2023-01-18
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, model training methods for CPUs and GPUs require separate code writing, resulting in a large workload and high labor costs.
Cross-platform model training is achieved by obtaining parameter information from function libraries of CPU and GPU, generating parameter sets, and adjusting functions to generate base function library tools.
It reduces the amount of repetitive code writing, improves the efficiency and flexibility of model training, and avoids inconvenience in conversion.
Smart Images

Figure CN116756555B_ABST
Abstract
Description
A method for generating training model tools, a model training method, and an apparatus. Technical Field
[0001] This application belongs to the field of computer technology, and specifically relates to a method for generating training model tools, a model training method, and an apparatus. Background Technology
[0002] With social development, the amount of data is growing exponentially every year, making the need to accelerate the training of machine learning models increasingly important.
[0003] In related technologies, the training terminal typically uses its Central Processing Unit (CPU) and Graphics Processing Unit (GPU) to process the corresponding training data. The GPU has a faster data processing speed, thus accelerating the training process. However, the software toolkits required for CPU and GPU operation can only handle their respective training data types. Therefore, in existing technologies, implementing the same functional module requires writing separate module code for the CPU or GPU to handle the training data, resulting in a large workload and high labor costs. Summary of the Invention
[0004] The purpose of this application is to provide a method for generating training model tools, a model training method, and an apparatus, which can solve the problems of large coding workload and high labor costs in existing model training methods.
[0005] In a first aspect, embodiments of this application provide a method for generating a training model tool, the method comprising:
[0006] A first function is obtained from a first function library, and a second function with the same functionality as the first function is obtained from a second function library, wherein the first function is a function that runs on the CPU, and the second function is a function that runs on the GPU;
[0007] Obtain the first parameter information of the first function and the second parameter information of the second function;
[0008] Generate a parameter set based on the first parameter information and the second parameter information;
[0009] Adjust the first function and / or the second function according to the parameter set;
[0010] Generate basis functions based on the adjusted first function and the adjusted second function;
[0011] Based on the aforementioned basis functions, a basis function library tool is obtained.
[0012] Optionally, generating the parameter set based on the first parameter information and the second parameter information includes:
[0013] Compare the first parameter information and the second parameter information to obtain the comparison result;
[0014] A parameter set is generated based on the comparison result, the first parameter information, and the second parameter information.
[0015] Optionally, the first parameter information and / or the second parameter information may include at least one of the following: function name, number of parameters, and parameter type.
[0016] Optionally, generating the parameter set based on the comparison result, the first parameter information, and the second parameter information includes:
[0017] If the comparison results are the same, the first parameter information or the second parameter information shall be used as the parameter set;
[0018] If the comparison results are different, the one with a larger number of parameters is selected from the first parameter information and the second parameter information as the benchmark parameter information.
[0019] The parameter set is obtained based on the reference parameter information.
[0020] Optionally, adjusting the first function and the second function according to the parameter set includes:
[0021] Based on the parameter set, the function parameter enhancement adjustment is performed on the first function and the second function that contain a smaller number of parameters.
[0022] Optionally, the method further includes:
[0023] If the first function library does not include a first function corresponding to the second function, then the first function corresponding to the second function is generated by compiling based on the second parameter information of the second function; or,
[0024] If the second function library does not include a second function corresponding to the first function, the second function corresponding to the first function is compiled and generated based on the first parameter information of the first function.
[0025] Secondly, embodiments of this application provide a model training method, the method comprising:
[0026] In response to model training tasks, obtain training data and configuration information for the model training workflow;
[0027] The base function associated with the model training workflow is invoked according to the configuration information, wherein the base function is configured as the base function described in the first aspect;
[0028] The model is iteratively trained using the basis functions and the training data.
[0029] Optionally, the iterative training of the model using the basis functions and the training data includes:
[0030] Based on the data type of the training data, the target runtime resource to be invoked is determined, wherein the target runtime resource includes CPU resources or GPU resources;
[0031] Based on the base function, the target runtime resource is invoked to iteratively train the model.
[0032] Thirdly, embodiments of this application provide a tool generation apparatus for training a model, the apparatus comprising:
[0033] The first acquisition module is configured to acquire a first function from a first function library and acquire a second function from a second function library that has the same function as the first function, wherein the first function is a function that runs on the CPU and the second function is a function that runs on the GPU;
[0034] The second acquisition module is used to acquire the first parameter information of the first function and the second parameter information of the second function;
[0035] The first generation module is used to generate a parameter set based on the first parameter information and the second parameter information;
[0036] An adjustment module is used to adjust the first function and / or the second function according to the parameter set;
[0037] The second generation module is used to generate basis functions based on the adjusted first function and the adjusted second function;
[0038] The third generation module is used to obtain a base function library tool based on the base functions.
[0039] Fourthly, embodiments of this application provide a model training apparatus, the apparatus comprising:
[0040] The acquisition module is used to acquire training data and configuration information for the model training workflow in response to model training tasks.
[0041] The calling module is used to call the basis function associated with the model training workflow according to the configuration information, wherein the basis function is configured as the basis function described in the first aspect;
[0042] The training module is used to iteratively train the model using the basis functions and the training data.
[0043] Fifthly, embodiments of this application provide an electronic device, which includes a processor and a memory. The memory stores programs or instructions that can run on the processor. When the programs or instructions are executed by the processor, they implement the steps of the method for generating a training model tool as described in the first aspect or the method for training a model as described in the second aspect.
[0044] In a sixth aspect, embodiments of this application provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the method for generating a training model tool as described in the first aspect or the method for training a model as described in the second aspect.
[0045] In this embodiment, by obtaining the first parameter information of a first function running on the CPU and the second parameter information of a second function running on the GPU, a parameter set is generated using the first and second parameter information. This parameter set is then used to adjust the first and second functions to obtain base functions. This invention abstracts a base function library tool by adjusting the functions running on the CPU and GPU. Then, when performing automated model training using the CPU or GPU, the first or second function is called using the base functions in the base function library. This eliminates the need to write separate module code for model training for the CPU and GPU, reducing repetitive workload and cost, avoiding inconvenient conversion issues, and improving efficiency. Attached Figure Description
[0046] Figure 1 is a flowchart illustrating the tool generation method for training models provided in an embodiment of this application;
[0047] Figure 2 is a flowchart illustrating the model training method provided in an embodiment of this application;
[0048] Figure 3 is a schematic diagram of the application of a training model tool;
[0049] Figure 4 is a schematic diagram of the tool generation device for training models provided in an embodiment of this application.
[0050] Figure 5 is a schematic diagram of the model training device provided in an embodiment of this application;
[0051] Figure 6 is a schematic diagram of the structure of the electronic device provided in an embodiment of this application. Detailed Implementation
[0052] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0053] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0054] The tool generation method for training models provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0055] As shown in Figure 1, the model training method provided in this embodiment includes the following steps:
[0056] Step S11: Obtain a first function from a first function library, and obtain a second function with the same functionality as the first function from a second function library, wherein the first function is a function that runs on the CPU, and the second function is a function that runs on the GPU.
[0057] During model training, automated machine learning frameworks can be built on CPUs or GPUs to automate a series of training processes, including data cleaning, feature engineering, hyperparameter optimization, model selection, model evaluation, and model fusion. The tool libraries and functions used for model training on CPUs differ from those used on GPUs. CPU tool libraries primarily include Pandas, NumPy, and Scikit-learn. GPU tool libraries mainly include cuDF (data processing library), cuPY (matrix mathematics library), and cuML (machine learning library). GPU tool libraries have application programming interfaces (APIs) similar to those of CPU tool libraries.
[0058] Select the first function to be called during model training from the CPU tool library; this first function is included in the first function library. Select the second function to be called during model training from the GPU tool library; this second function is included in the second function library. The first and second functions with the same functionality are corresponding.
[0059] Step S12: Obtain the first parameter information of the first function and the second parameter information of the second function.
[0060] The first parameter information includes the function interface and function functionality of the first function; similarly, the second parameter information includes the function interface and function functionality of the second function.
[0061] Step S13: Generate a parameter set based on the first parameter information and the second parameter information.
[0062] The parameter set contains the first parameter information corresponding to all the first functions in the first function library, that is, the function interface and function functionality corresponding to the first function. Similarly, the parameter set also contains the second function information corresponding to all the second functions in the second function library.
[0063] For a pair of first and second functions with the same functionality, compare their corresponding first and second parameter information. If the first and second parameter information are the same, no modification is needed. If the first and second parameter information are different, adjust either the first or second parameter information to make them the same.
[0064] Step S14: Adjust the first function and / or the second function according to the parameter set.
[0065] Understandably, when the target first parameter information or target second parameter information in the parameter set is adjusted, the target first function or target second function in the first function library needs to be adjusted accordingly, so that the first parameter information of the adjusted target first function is consistent with the target first parameter information or the second parameter information of the target second function is consistent with the target second parameter information.
[0066] Step S15: Generate basis functions based on the adjusted first function and the adjusted second function.
[0067] After the adjustment, the first and second parameter information of each pair of functions with the same function are also the same, that is, the function interface is also the same. The first and second functions with the same function and the same function interface are abstracted to form the corresponding base function. The base function is used to call the corresponding first or second function.
[0068] Step S16: Obtain the basis function library tool based on the basis functions.
[0069] The base function library tool includes multiple base functions, which are used to call the corresponding first function or the corresponding second function. Therefore, the base function library tool can be used to call the first function in the first function library or the second function in the second function library.
[0070] The following example illustrates the process of generating basis functions. To implement the addition function, both the CPU tool Pandas and the GPU library cuDF use the add() function. The first function is pandas.DataFrame.add(other, axis='columns', level=None, fill_value=None).
[0071] The corresponding second function is cudf.DataFrame.add(other, axis='columns', level=None, fill_value=None).
[0072] By abstracting the code of the first and second functions that implement addition, we obtain a base function with a unified interface:
[0073] basetoolbox.DataFrame.add(other, axis='columns', level=None, fill_value=None).
[0074] It should be noted that each basis function includes a corresponding functionality.
[0075] Through the above steps, the first parameter information of the first function running on the CPU and the second parameter information of the second function running on the GPU are obtained. Using the first and second parameter information, a parameter set is generated, which is then used to adjust the first and second functions to obtain the base functions. This invention abstracts a base function library tool by adjusting the functions running on the CPU and GPU. Then, when using the CPU or GPU for automated model training, the first or second function is called through the base functions in the base function library tool. This eliminates the need to write separate module code for model training for CPU and GPU, reducing repetitive workload and cost, avoiding inconvenient conversion issues, and improving efficiency.
[0076] Optionally, generating a parameter set based on the first parameter information and the second parameter information includes:
[0077] Compare the first parameter information and the second parameter information to obtain the comparison result;
[0078] A parameter set is generated based on the comparison result, the first parameter information, and the second parameter information.
[0079] The first and second parameter information of a pair of first and second functions with the same function are compared to obtain the comparison result. Based on the comparison result, it is determined whether the first or second parameter information needs to be modified so that the first and second parameter information of each pair of first and second functions with the same function are consistent. This ensures that the base function library tool can accurately call the first and second functions with the same function in the first and second function libraries through the base functions.
[0080] Optionally, the first parameter information and / or the second parameter information may include at least one of the following: function name, number of parameters, and parameter type.
[0081] The function name corresponds to the function's functionality, facilitating base function calls. The number of parameters indicates the number of parameters the function can handle, and the parameter type indicates the data type of the parameters the function can handle. By comprehensively considering the function name, number of parameters, and parameter types, and comparing the first and second parameter information, the first and / or second parameter information is adjusted based on the comparison result. This allows for adjustments to the first and / or second functions in subsequent processes, further ensuring that the base function library tools can accurately call functionally identical first and second functions from the first and second function libraries using base functions.
[0082] Optionally, generating the parameter set based on the comparison result, the first parameter information, and the second parameter information includes:
[0083] If the comparison results are the same, either the first parameter information or the second parameter information will be used as the parameter set.
[0084] If the comparison results are the same, that is, when a pair of first and second functions with the same functionality also have the same function interface (i.e., the number of parameters that the function can handle, the data type of the parameters that can be handled, and the name of the function are all the same), then there is no need to adjust the first and second parameter information, nor is there any need to adjust the first function corresponding to the first parameter information and the second function corresponding to the second parameter information. The corresponding base function can be directly generated. In the subsequent model training process, data processing can be completed simply by calling the corresponding first function in the first function library or the corresponding second function in the second function library through the base function library tool. There is no need to rewrite the training module code for CPU and GPU.
[0085] If the comparison results are different, the parameter information with a larger number of parameters is selected from the first parameter information and the second parameter information as the benchmark parameter information, and the parameter set is obtained based on the benchmark parameter information.
[0086] For a pair of functions, first and second, with identical functionality, if the comparison results differ (i.e., the first and second parameter information are different, meaning their function interfaces are different), the first or second parameter information is adjusted to generate a parameter set. Specifically, different function interfaces can be due to differences in the number of parameters processed, the data type of the function, or the name of the function. If the function interface parameters in the first parameter information are fewer than those in the second parameter information, the second parameter information serves as the baseline, and the function interface information in the first parameter information is added based on this baseline. Conversely, if the function interface parameters in the second parameter information are fewer than those in the first parameter information, the first parameter information serves as the baseline, and the second parameter information is added based on this baseline. Supplementing the function with fewer parameters based on the baseline parameter information facilitates subsequent adjustments to the function corresponding to the function with fewer parameters.
[0087] Optionally, adjusting the first function and the second function according to the parameter set includes:
[0088] Based on the parameter set, the function parameter enhancement adjustment is performed on the first function and the second function that contain a smaller number of parameters.
[0089] For example, the first function is a function in Scikit-learn. Based on its first parameter information, it supports data types such as integers, floating-point numbers, and text. The second function, however, is a function in cuML. Based on its second parameter information, it only supports integers and floating-point numbers. In this case, the first parameter information of the first function serves as the baseline parameter information. Based on this baseline, the function interface parameters in the second parameter information of the second function need to be enhanced by label encoding. When text features appear, the text is categorized and then labeled, with numerical labels replacing the text. The enhanced first and second parameter information maintain the same function functionality and interface, facilitating abstraction of the first and second functions to obtain corresponding base functions for generating a base function library tool.
[0090] Optionally, the tool generation method for training models provided in this application embodiment further includes:
[0091] If the first function library does not include a first function corresponding to the second function, then the first function corresponding to the second function is generated by compiling based on the second parameter information of the second function; or,
[0092] If the second function library does not include a second function corresponding to the first function, the second function corresponding to the first function is compiled and generated based on the first parameter information of the first function.
[0093] It should be noted that, since the software ecosystem supporting CPU operation is more mature than that supporting GPU operation, the first function in the first function library can generally perform more functions than the second function in the second function library. Therefore, in most cases, each second function in the second function library can be found in the first function library, but the first function may not be found in the second function library. Therefore, it is necessary to compile and generate the corresponding second function based on the first parameter information of the first function.
[0094] The following example illustrates the compilation process. Some functions in cuML only support processing ndarray data and do not support DataFrame, the mainstream data format for machine learning algorithms. When the first target function is used to process a specific function of DataFrame format data, cuML does not have a second function corresponding to the first target function because it only supports processing ndarray data. Therefore, it can only refer to the algorithm logic corresponding to the first parameter information of the first target function and reimplement it in the GPU tool library in the form of DataFrame to generate the second target function to correspond with the first target function. Then, the target base function is generated based on the first target function and the second target function, ensuring that each step in the model training process can be implemented by calling the base function.
[0095] This application embodiment also provides a model training method, as shown in Figure 2, the model training method includes:
[0096] Step S21: In response to the model training task, obtain training data and configuration information for the model training workflow.
[0097] The execution entity of the model training method can be a model training application, which can be installed on devices such as mobile phones and computers. Based on the model training task, the execution entity of the model training method responds and obtains training data and configuration information for the model training workflow. General requirements for training data are: the data sample should be as large as possible, the data should be diverse, and the data sample quality should be high. Configuration information includes operator modules and the operational relationships between operator models. Operator models include: data cleaning, missing value handling, normalization, feature engineering, hyperparameter optimization, model selection, model evaluation, and model fusion. The training data and configuration information are then input into the model training application for fully automated machine learning.
[0098] Step S22: Invoke the basis functions associated with the model training workflow according to the configuration information, wherein the basis functions are configured as the basis functions described in the above-mentioned model training tool production method.
[0099] The base functions associated with the model training workflow are determined based on the configuration information. If data cleaning of the training data is required, the base function with data cleaning function is called. Then, the corresponding first and second functions in the first and second function libraries are called through the base function.
[0100] Step S23: Iteratively train the model using the basis functions and the training data.
[0101] Based on the correspondence between base functions and corresponding first and second functions, the corresponding first function can be called from the first function library or the corresponding second function from the second function library to process the training data for model training. Therefore, when processing training data, either a CPU or a GPU can be chosen. CPUs have a small number of powerful computing units, suitable for a small number of computationally complex calculations. GPUs have hundreds or thousands of cores, enabling massive parallel computing at speeds far exceeding those of CPUs, but they can handle lower levels of computational logic complexity. When processing training data, the appropriate choice is made based on the algorithmic logic and data volume required for each training step: calling the first function on the CPU or the second function on the GPU. Through the calls to the base functions and their corresponding first or second functions, both CPUs and GPUs can complete the entire automated machine learning training task. Furthermore, due to the characteristics of GPUs, their speed performance is generally superior to that of CPUs, and the larger the amount of training data, the more pronounced the speedup advantage of GPUs becomes.
[0102] Optionally, the iterative training of the model using the basis functions and the training data includes:
[0103] Based on the data type of the training data, the target runtime resource to be invoked is determined, wherein the target runtime resource includes CPU resources or GPU resources;
[0104] Based on the base function, the target runtime resource is invoked to iteratively train the model.
[0105] Understandably, when the data type of the training data is more suitable for CPU processing, the first function is called through the base function to perform training on the CPU; when the data type of the training data is more suitable for GPU processing, the second function is called through the base function to perform training on the GPU.
[0106] Figure 3 illustrates the application of a model training tool. By inputting the training dataset (train data), the automatic machine learning model can be trained. This model training application includes a base function library jointly determined by a modified first function and a modified second function, i.e., the abstraction layer shown in Figure 3. This abstraction layer is also called the base function library tool (BaseToolbox), which can identify the data type of the training data. The application also includes toolkits: the CPU function library cpuToolbox (the first function library) and the GPU function library gpuToolbox (the second function library). The base function library tool determines the corresponding base function based on the training data and the model training workflow configuration information. Then, based on the identified data type of the training data, it selects to call either the first function in the CPU function library or the second function in the GPU function library. For example, when the training data format is cuDFDaraFrame supported by the GPU, the second function is called in the GPU function library, and the automatic machine learning model training process is executed on the GPU.
[0107] It can use either CPU or GPU for model training, making it more flexible. The choice between CPU or GPU is determined by the type of training data, further ensuring the stability of the model training process.
[0108] The training model tool generation method provided in this application embodiment can be executed by a training model tool generation device.
[0109] In this embodiment, the method for generating a training model tool is performed using a training model tool generation device as an example, and the training model tool generation device 400 provided in this application is described in conjunction with Figure 4. The training model tool generation device 400 includes:
[0110] The first acquisition module 401 is used to acquire a first function from a first function library and to acquire a second function with the same function as the first function from a second function library, wherein the first function is a function that runs on the CPU and the second function is a function that runs on the GPU;
[0111] The second acquisition module 402 is used to acquire the first parameter information of the first function and the second parameter information of the second function;
[0112] The first generation module 403 is used to generate a parameter set based on the first parameter information and the second parameter information;
[0113] Adjustment module 404 is used to adjust the first function and / or the second function according to the parameter set;
[0114] The second generation module 405 is used to generate a base function based on the adjusted first function and the adjusted second function;
[0115] The third generation module 406 is used to obtain a base function library tool based on the base functions.
[0116] Optionally, the first generation module 403 is further configured to:
[0117] Compare the first parameter information and the second parameter information to obtain the comparison result;
[0118] A parameter set is generated based on the comparison result, the first parameter information, and the second parameter information.
[0119] Optionally, the first parameter information and / or the second parameter information may include at least one of the following: function name, number of parameters, and parameter type.
[0120] Optionally, the first generation module 403 is further configured to:
[0121] If the comparison results are the same, the first parameter information or the second parameter information shall be used as the parameter set;
[0122] If the comparison results are different, the one with a larger number of parameters is selected from the first parameter information and the second parameter information as the benchmark parameter information.
[0123] The parameter set is obtained based on the reference parameter information.
[0124] Optionally, the adjustment module 404 is also used for:
[0125] Based on the parameter set, the function parameter enhancement adjustment is performed on the first function and the second function that contain a smaller number of parameters.
[0126] Optionally, the tool generation device 400 for training the model also includes a compilation module, which is used for:
[0127] If the first function library does not include a first function corresponding to the second function, then the first function corresponding to the second function is generated by compiling based on the second parameter information of the second function; or,
[0128] If the second function library does not include a second function corresponding to the first function, the second function corresponding to the first function is compiled and generated based on the first parameter information of the first function.
[0129] The aforementioned tool generation device for training models can generate corresponding base function library tools based on the first function in the first function library and the second function in the second function library, and then call the corresponding first or second function through the base functions in the base function library tools.
[0130] It should be noted that the tool generation apparatus for training models provided in this application embodiment can implement all the technical processes of the above-described tool generation method for training models and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0131] The model training method provided in this application can be executed by a model training device. This application example uses a model training device to execute the model training method, and the model training device 500 provided in this application is described with reference to Figure 5. The model training device includes:
[0132] The acquisition module 501 is used to acquire training data and configuration information of the model training workflow in response to the model training task.
[0133] The calling module 502 is used to call the basis function associated with the model training workflow according to the configuration information, wherein the basis function is configured as the basis function in the generation method of the above-mentioned training model tool;
[0134] The training module 503 is used to iteratively train the model using the basis functions and the training data.
[0135] Optionally, the training module 503 is also used for:
[0136] Based on the data type of the training data, the target runtime resource to be invoked is determined, wherein the target runtime resource includes CPU resources or GPU resources;
[0137] Based on the base function, the target runtime resource is invoked to iteratively train the model.
[0138] The aforementioned model training device 500 can perform fully automated machine learning training by calling the corresponding first or second function on the CPU or GPU based on the basis functions and training data.
[0139] It should be noted that the model training apparatus provided in this application embodiment can implement all the technical processes of the above-mentioned model training method and achieve the same technical effect. To avoid repetition, it will not be described again here.
[0140] The device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. Non-mobile electronic devices can also be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not specifically limit the scope of the device.
[0141] Optionally, as shown in FIG5, this application embodiment also provides an electronic device 600, including a processor 601 and a memory 602. The memory 602 stores a program or instructions that can run on the processor 601. When the program or instructions are executed by the processor 601, they implement the various steps of the above-mentioned training model tool generation method or model training method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0142] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0143] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described training model tool generation method or model training method embodiment and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0144] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0145] It should be noted that, in this document, 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 limitations, 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 that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0146] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0147] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for generating a training model tool, characterized in that, include: The process involves: obtaining a first function from a first function library; obtaining a second function from a second function library that has the same functionality as the first function, wherein the first function is a function that runs on the CPU, and the second function is a function that runs on the GPU; obtaining first parameter information of the first function and second parameter information of the second function; generating a parameter set based on the first parameter information and the second parameter information; adjusting the first function and / or the second function based on the parameter set; generating base functions based on the adjusted first function and the adjusted second function; and obtaining a base function library tool based on the base functions, wherein the base function library tool includes base functions used to call the corresponding first function or the corresponding second function. The second function; the step of generating a parameter set based on the first parameter information and the second parameter information includes: comparing the first parameter information and the second parameter information to obtain a comparison result; generating a parameter set based on the comparison result, the first parameter information, and the second parameter information; the step of adjusting the first function and the second function based on the parameter set includes: based on the parameter set, performing function parameter enhancement adjustments on the function with the smaller number of parameters in the first function and the second function; the step of generating base functions based on the adjusted first function and the adjusted second function includes: abstracting each pair of first functions and second functions with the same function function and the same function interface to form corresponding base functions.
2. The method according to claim 1, characterized in that, The first parameter information and / or the second parameter information include at least one of the following: function name, number of parameters, and parameter type.
3. The method according to claim 2, characterized in that, The step of generating a parameter set based on the comparison result, the first parameter information, and the second parameter information includes: if the comparison results are the same, using either the first parameter information or the second parameter information as the parameter set; if the comparison results are different, selecting the parameter information with the larger number of parameters from the first parameter information and the second parameter information as the benchmark parameter information; and obtaining the parameter set based on the benchmark parameter information.
4. The method according to claim 1, characterized in that, The method further includes: if the first function library does not include a first function corresponding to the second function, compiling and generating a first function corresponding to the second function based on the second parameter information of the second function; or, if the second function library does not include a second function corresponding to the first function, compiling and generating a second function corresponding to the first function based on the first parameter information of the first function.
5. A model training method, characterized in that, include: In response to model training tasks, obtain training data and configuration information for the model training workflow; The base function associated with the model training workflow is invoked according to the configuration information, wherein the base function is configured as any one of claims 1 to 4; the model is iteratively trained using the base function and the training data.
6. The method according to claim 5, characterized in that, The iterative training of the model using the base function and the training data includes: determining the target runtime resource to be invoked based on the data type of the training data, wherein the target runtime resource includes CPU resources or GPU resources; and invoking the target runtime resource based on the base function to perform iterative training of the model.
7. A device for generating training model tools, characterized in that, The apparatus includes: a first acquisition module, configured to acquire a first function from a first function library, and to acquire a second function with the same function as the first function from a second function library, wherein the first function is a function that runs on a CPU, and the second function is a function that runs on a GPU; a second acquisition module, configured to acquire first parameter information of the first function and second parameter information of the second function; a first generation module, configured to generate a parameter set based on the first parameter information and the second parameter information; an adjustment module, configured to adjust the first function and / or the second function based on the parameter set; a second generation module, configured to generate a base function based on the adjusted first function and the adjusted second function; and a third generation module; The first generation module is used to generate a base function library tool based on the base functions. The base function library tool includes base functions, which are used to call the corresponding first function or the corresponding second function. The first generation module is also used to: compare the first parameter information and the second parameter information to obtain a comparison result; generate a parameter set based on the comparison result, the first parameter information, and the second parameter information. The adjustment module is also used to: perform function parameter enhancement adjustments on the first function and the second function with the smaller number of parameters based on the parameter set. The second generation module is also used to: abstract each pair of first functions and second functions with the same function function and the same function interface to form corresponding base functions.
8. A model training device, characterized in that, The apparatus includes: an acquisition module for acquiring training data and configuration information of the model training workflow in response to a model training task; an invocation module for invoking a basis function associated with the model training workflow according to the configuration information, wherein the basis function is configured as the basis function according to any one of claims 1 to 4; and a training module for iteratively training the model using the basis function and the training data.
Citation Information
Patent Citations
Kernel function generation method, target code generation method and combination processing device
CN110825380A