CN114546973A - Method and device for converting model parameters - Google Patents

Method and device for converting model parameters Download PDF

Info

Publication number
CN114546973A
CN114546973A CN202210168582.9A CN202210168582A CN114546973A CN 114546973 A CN114546973 A CN 114546973A CN 202210168582 A CN202210168582 A CN 202210168582A CN 114546973 A CN114546973 A CN 114546973A
Authority
CN
China
Prior art keywords
model
parameter
parameters
constructed
built
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210168582.9A
Other languages
Chinese (zh)
Inventor
贺捷
吴望龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN202210168582.9A priority Critical patent/CN114546973A/en
Publication of CN114546973A publication Critical patent/CN114546973A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • G06F16/1794Details of file format conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Stored Programmes (AREA)

Abstract

The specification discloses a method and a device for converting model parameters, which can obtain model parameters under the parameter types required by a model to be constructed, transmit the model parameters into the model to be constructed, convert the model parameters through a parameter conversion relation pre-deployed in the model to be constructed, convert the format based on the model parameters to obtain first parameters under a standard format, further convert the first parameters under the standard format through a conversion function preset in the model to be constructed to obtain first parameters under the parameter types required by a custom calculation layer, transmit the first parameters into a custom calculation layer of the model to be constructed to construct and obtain the model to be constructed containing the custom calculation layer, and execute target services corresponding to the model to be constructed through the constructed model to be constructed, wherein the custom calculation layer is a network layer additionally configured for the target services, thereby improving the efficiency of model deployment.

Description

Method and device for converting model parameters
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for model parameter transformation.
Background
Currently, with the continuous development of computer technology, machine learning models can be widely applied to various industries gradually, and the technical problems of numerous industries are solved.
In practical application, when a developer develops and trains a machine learning model, a Torch framework can be used as a basis, that is, a Torch model is used in the development and training stages, and in order to improve the calculation efficiency of the model in use, the Torch model can be converted into a TensorRT model for deployment.
In the machine learning model, a developer can also write a custom calculation layer which needs to be added into the machine learning model under a CUDA kernel framework to realize special business requirements, and because model parameters (such as convolution kernel parameters, network weights and the like) need to be transmitted into the custom calculation layer in models under a Torch framework and a TensorRT framework respectively, the developer usually needs to write two sets of codes respectively to transmit the parameters into the custom calculation layer in each framework under the Torch framework and the TensorRT framework, and each time the developer builds a model, the developer often needs to transmit the parameters into the custom calculation layer in such a way, so that the efficiency of deploying the machine learning model is reduced.
Therefore, how to improve the efficiency of deploying the machine learning model is an urgent problem to be solved.
Disclosure of Invention
The present specification provides a method and an apparatus for model parameter transformation, which partially solve the above problems in the prior art.
The technical scheme adopted by the specification is as follows:
the present specification provides a method of model parameter transformation, comprising:
obtaining model parameters under the parameter types required by the model to be constructed;
transmitting the model parameters into the model to be constructed so as to perform format conversion based on the model parameters through a parameter conversion relation deployed in the model to be constructed in advance, and obtaining first parameters in a standard format;
converting the first parameter in the standard format through a preset conversion function in the model to be built to obtain a first parameter in a parameter type required by a user-defined calculation layer, transmitting the first parameter to the user-defined calculation layer of the model to be built to build the model to be built containing the user-defined calculation layer, and executing a target service corresponding to the model to be built through the built model to be built, wherein the user-defined calculation layer is a network layer additionally configured for the target service.
Optionally, the transmitting the model parameters into the model to be constructed to obtain, inside the model to be constructed, first parameters in a standard format based on the model parameters, specifically including:
transmitting the model parameters into the model to be built, so as to perform format conversion on first parameters, except for second parameters, contained in the model parameters inside the model to be built, to obtain the first parameters in the standard format, wherein the first parameters comprise parameters required by model calculation inside the custom calculation layer, and the second parameters comprise parameters required by other network structures except for the custom calculation layer in the model to be built;
constructing to-be-constructed models containing the custom computing layers, and specifically comprising the following steps:
and according to the first parameter based on the standard format, the first parameter under the parameter type required by the user-defined computation layer and the second parameter are obtained through conversion, and the model to be constructed containing the user-defined computation layer is constructed.
Optionally, the method further comprises:
when the model to be constructed is stored in a file format, converting the first parameter in the standard format into a byte format to obtain a first parameter in the byte format, and storing the first parameter in the byte format in a model file corresponding to the model to be constructed;
when the model to be built is loaded through the model file, the first parameters in the byte format are restored to the first parameters in the standard format, so that the model to be built converts the first parameters in the standard format through the conversion function and then transmits the converted first parameters to the custom calculation layer of the second model.
Optionally, the model to be constructed at least includes a first model and a second model, the first model is a model that is constructed in a preset first model frame in a training stage and is directed to the target service, and the second model is a model that is constructed in a preset second model frame through the trained first model and is used for deploying and actually executing the target service.
Optionally, if the model to be constructed is the first model, obtaining the model parameters required by the model to be constructed specifically includes:
obtaining model parameters in a standard format;
converting the model parameters in the standard format into model parameters in a first type corresponding to the first model frame, and transmitting the model parameters in the first type into the first model;
if the model to be constructed is the second model, obtaining model parameters required by the model to be constructed, specifically comprising:
and converting the model parameters under the first type into model parameters under a second type corresponding to the second model frame, and transmitting the model parameters under the second type into the second model.
Optionally, the obtaining of the model parameters in the standard format specifically includes:
acquiring a pre-configured parameter file;
and reading the parameter file, and converting the model parameters stored in the parameter file into the model parameters in the standard format.
Optionally, the first model framework is a Torch framework and the second model framework is a TensorRT framework.
The present specification provides an apparatus for model parameter transformation, comprising:
the acquisition module is used for acquiring model parameters under the parameter types required by the model to be constructed;
the model parameter transmitting module is used for transmitting the model parameters into the model to be constructed so as to perform format conversion based on the model parameters through a parameter conversion relation which is deployed in the model to be constructed in advance, and obtain first parameters in a standard format;
the conversion module is used for converting the first parameters in the standard format through a conversion function preset in the model to be constructed to obtain first parameters in a parameter type required by a custom calculation layer, transmitting the first parameters to the custom calculation layer of the model to be constructed to construct and obtain the model to be constructed containing the custom calculation layer, and executing a target service corresponding to the model to be constructed through the constructed model to be constructed, wherein the custom calculation layer is a network layer additionally configured for the target service.
The present specification provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the above-described method of model parameter transformation.
The present specification provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above method of model parameter transformation when executing the program.
The technical scheme adopted by the specification can achieve the following beneficial effects:
as can be seen from the above method for converting model parameters, the service platform can obtain the model parameters under the parameter types required by the model to be constructed, and transmit the model parameters into the model to be constructed, the first parameter under the standard format is obtained by the parameter conversion relation pre-arranged in the model to be constructed and the format conversion based on the model parameter, further, the first parameter under the standard format is converted through a conversion function preset in the model to be constructed to obtain the first parameter under the parameter type required by the user-defined calculation layer, and is transmitted into a custom calculation layer of the model to be constructed so as to construct and obtain the model to be constructed containing the custom calculation layer, and executing the target service corresponding to the model to be constructed through the constructed model to be constructed, wherein the custom calculation layer is a network layer additionally configured for the target service.
It can be seen from the above contents that, the method for converting model parameters provided in this specification can define a standard format, when model parameters of a to-be-custom calculation layer are required to be customized and transmitted to the to-be-custom calculation layer of the to-be-built model, the interior of the to-be-built model can be converted into first parameters in the standard format, and further converted into parameter types required by the to-be-custom calculation layer through a preset conversion function, so as to be input into the to-be-custom calculation layer of the model, when a new to-be-custom calculation layer needs to be deployed into the to-be-built model, the above manner can be reused, only the conversion function needs to be replaced, and compared with the prior art, the efficiency of model deployment can be improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification and are incorporated in and constitute a part of this specification, illustrate embodiments of the specification and together with the description serve to explain the specification and not to limit the specification in a non-limiting sense. In the drawings:
FIG. 1 is a schematic flow chart of a method for model parameter transformation in the present specification;
fig. 2 is a detailed flowchart illustrating parameter conversion performed on parameters required by a custom computing layer provided in this specification;
FIG. 3 is a schematic diagram of a model parameter transformation apparatus provided herein;
FIG. 4 is a schematic diagram of an electronic device for a method for model parameter transformation provided herein.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the present specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a method for converting model parameters in this specification, which specifically includes the following steps:
s101: and obtaining model parameters under the parameter types required by the model to be constructed.
S102: and transmitting the model parameters into the model to be constructed so as to perform format conversion based on the model parameters through a parameter conversion relation deployed in the model to be constructed in advance, thereby obtaining first parameters in a standard format.
S103: converting the first parameter in the standard format through a preset conversion function in the model to be built to obtain a first parameter in a parameter type required by a custom calculation layer, transmitting the first parameter to the custom calculation layer of the model to be built to build a model to be built containing the custom calculation layer, and executing a target service corresponding to the model to be built through the built model to be built, wherein the custom calculation layer is a network layer additionally configured for the target service.
In practical application, a machine learning model has multiple model frames, a service platform can use a model of one frame in model research and development and training stages, and after the model training is finished, the trained model can be converted into a model under another frame in order to improve the efficiency of the model in use, and a custom calculation layer is usually required to be included in the model.
Of course, the above mentioned is only one application scenario of the present invention, and in practical applications, developers may perform model parameter conversion for any machine learning model including a custom computation layer according to the model parameter conversion method of the present invention.
Based on the method, the service platform can obtain model parameters under the parameter types needed by the model to be constructed, and transmits the model parameters into the model to be constructed, so that format conversion is carried out based on the model parameters through the parameter conversion relation pre-deployed in the model to be constructed, and first parameters under the standard format are obtained.
The model to be constructed comprises a custom calculation layer, the custom calculation layer can be usually written under a CUDA kernel frame, the custom calculation layer needs to be further packaged to be in line with the model frame of the model to be constructed, and therefore the custom calculation layer can be embedded into the model to be constructed.
After a first parameter in a standard format is obtained inside a model to be built, the first parameter in the standard format can be converted through a conversion function preset in the model to be built to obtain a first parameter in a parameter type required by a custom calculation layer, the first parameter is transmitted to the custom calculation layer of the model to be built to build the model to be built containing the custom calculation layer, and a target service corresponding to the model to be built is executed through the built model to be built, wherein the custom calculation layer is a network layer additionally configured for the target service.
That is to say, the above-mentioned method is to introduce the model parameter conforming to the type of the model parameter to be constructed into the model to be constructed, then to perform certain format conversion on the model parameter in the model to be constructed to obtain the first parameter in the standard format, and to perform conversion on the first parameter in the standard format and also in the model to obtain the first parameter in the type of the parameter required by the custom computation layer of the model to be constructed, and input the first parameter into the model.
That is, a developer in the service platform may define the standard format in advance, and for any type of model parameter, the service platform may convert the type of model parameter into a model parameter in the standard format by using a parameter conversion method corresponding to the type, or may convert the model parameter in the standard format into the type of model parameter.
That is, the above-mentioned preset conversion function may be predefined for the custom computing layer, and the conversion function can convert the model parameters in the standard format into the parameter types required inside the custom computing layer.
It should be noted that, in practice, when the model parameters of the custom calculation layer need to be transmitted into the custom calculation layer, parameter conversion can be performed in the above manner, and if a model to be constructed including a new custom calculation layer needs to be constructed, the preset conversion function can be reconfigured according to the parameter types of the model parameters required by the custom calculation layer.
The aforementioned model to be constructed may include at least a first model and a second model, where the first model may be a model constructed in a preset first model frame in a training phase and is for the target service, and the second model may be a model constructed in a preset second model frame through the trained first model and is used for deploying and actually executing the target service.
Based on the situation that the model parameters of the first model under the first model framework and the model parameters of the second model under the second model framework, which comprise the custom calculation layer, need to be transmitted to the respective custom calculation layers, when the model to be constructed is the first model, the service platform can obtain the model parameters in the standard format, and converting the model parameters in the standard format into model parameters in a first type corresponding to the first model frame, inputting the model parameters in the first type into the first model, format conversion is carried out in the first model based on the model parameters under the first type to obtain first parameters under a standard format, and converting the first parameter in the standard format through the conversion function to obtain the first parameter in the parameter type required by the user-defined calculation layer, and inputting the first parameter into the user-defined calculation layer in the first model.
The model frame corresponding to the second model is different from the first model and is another model frame, the required model parameters in the second model need to be the model parameters of the second type under the second model frame, the first type is the parameter type conforming to the standard under the first model frame corresponding to the first model, and the second type is the parameter type conforming to the standard under the model frame corresponding to the second model.
And the model parameters of the custom calculation layer also need to be input into the custom calculation layer of the second model, so that the custom calculation layer performs the calculation inside the model through the model parameters. Therefore, the model parameters under the first type can be converted into the model parameters under the second type corresponding to the second model frame, the model parameters under the second type are transmitted into the second model, and the format of the model parameters under the second type is converted through the parameter conversion relation pre-deployed in the second model to obtain the first parameters under the standard format.
The first model skeleton may be a Torch skeleton, and accordingly, the first type may be a string type, the second model skeleton may be a TensorRT skeleton, and accordingly, the second type may be a parameter set type (PluginFieldselection).
If the second model is a model under a TensorRT framework, the service platform can convert the model parameters under the first type into a parameter set type (PluginFieldConnection) meeting the framework standard corresponding to the second model through the ONNX Parser, and the obtained model parameters under the second type are input into the second model. Of course, if the frame to which the first model needs to be converted is not a TensorRT frame, the method for specifically converting the parameters of the model in the first type may be different, and details are not described herein.
It should be further noted that, when the model to be constructed (e.g., the first model or the second model) is not needed to be used, the service platform may store the model to be constructed in a file format, and when the model to be constructed needs to be used, the service platform may load the model to be constructed by storing the model file of the model to be constructed, and then perform service execution through the model to be constructed.
In order to store the model parameters in the model file, when the service platform needs to store the model to be constructed in the file format, the service platform may convert the first parameter in the standard format into the byte format to obtain the first parameter in the byte format, so as to store the first parameter in the byte format in the model file corresponding to the model to be constructed, and when the model to be constructed is loaded through the model file, the first parameter in the byte format is restored to the first parameter in the standard format, so that the model to be constructed converts the first parameter in the standard format through the conversion function and then transmits the converted first parameter to the custom calculation layer of the model to be constructed.
That is to say, when the first parameter needs to be stored in the model file, the first parameter in the standard format may be converted into a byte format that can be stored in the file, and then stored in the model file, and if the model to be constructed needs to be loaded, the model to be constructed is identified and predicted, or the model to be constructed is trained, and the like, the first parameter in the byte format may be restored into the first parameter in the standard format, and the first parameter in the standard format is converted by the conversion function and then input to the custom calculation layer of the model to be constructed, so that the first parameter in the standard format and the byte format can be efficiently converted into each other when the model to be constructed is stored in the file format and the model to be constructed is loaded by the model file.
It can be seen from the foregoing that, the method for converting model parameters provided in this specification may define a standard format, and when a first parameter of a custom calculation layer is required to be introduced into a custom calculation layer from a model under one frame, or a custom calculation layer from a model under another frame, the first parameter in the standard format may be converted into a parameter type (first type) under a frame that meets a first model through a first parameter in the standard format (the first parameter is a parameter required by the custom calculation layer), and then the parameter type (first type) is introduced into the first model, and the first parameter in the standard format may be restored inside the first model, and then further converted into a model parameter required by the custom calculation layer. And when the first model is converted into a model of another frame, the model parameters in the second model, which conform to the other frame type, can be restored into model parameters in the standard format, and then the model parameters in the standard format are converted into model parameters required by the custom calculation layer and transmitted into the custom calculation layer.
It should be further noted that the model parameters under the parameter types required by the model to be built may only include the first parameters, that is, the model parameters may only include the model parameters required by the custom calculation layer, and of course, the model parameters may also include the second parameters, and after the model parameters are introduced into the model to be built, format conversion may be performed on the first parameters, which are included in the model parameters, except for the second parameters, inside the model to be built to obtain the first parameters in the standard format, where the first parameters include the parameters required by the model calculation inside the custom calculation layer, and the second parameters include the parameters required by other network structures in the model to be built, except for the custom calculation layer.
When the model to be constructed is constructed, the model to be constructed including the custom calculation layer can be constructed according to the first parameter and the second parameter which are obtained by conversion based on the first parameter under the standard format and under the parameter type required by the custom calculation layer.
The complete parameter conversion process is described below with a specific example, as shown in fig. 2.
Fig. 2 is a detailed flowchart illustrating parameter conversion performed on parameters required by a custom computing layer provided in this specification.
Fig. 2 is an example of a model needing to be converted from a first model framework (such as a Torch framework) to a second model framework (such as a TensorRT framework), that is, first parameters required by a custom computation layer need to enter the custom computation layer from a first model under the first model framework and also need to enter the custom computation layer from a second model under the second model framework.
As can be seen from fig. 2, the first parameter in the standard format can be converted into the string type through the string conversion function, and then the string type enters the first model, and then the string type can be restored into the standard format through the restoration function corresponding to the string type, and further the string type can be converted into the parameter type required by the custom calculation layer through the preset conversion function, and then the parameter type enters the custom calculation layer, and when the first parameter needs to be transferred into the custom calculation layer of the second model, the first parameter in the string type can be directly converted into the first parameter in the second type (e.g., Plugin field selection)
When the first parameter enters the second model in the second type, the first parameter in the standard format can be restored through the restoring function corresponding to the second type, when the model file needs to be stored, the first parameter in the standard format can be converted into a byte type (buffer type) through a byte type conversion function and stored, and when the model needs to be loaded, the first parameter can be restored back to the standard format through the restoring function corresponding to the byte type, so that the first parameter is converted into the parameter type required by the custom computing layer.
For convenience of description, the service platform is used as an execution subject to describe, in practical applications, the execution subject may have multiple types, such as an unmanned device, a server included in the service platform, and the like, and the target service to which the model to be constructed is applied is not limited, the target service may be any service that requires a machine learning model, such as recognition, prediction, and the like in the unmanned device may be regarded as a target service, and for example, the target service may also be a recommendation service.
The unmanned equipment mentioned above may refer to equipment capable of realizing automatic driving, such as unmanned vehicles, unmanned aerial vehicles, automatic distribution equipment, and the like. Based on this, the remote control method provided by the specification can determine the number of operators in each geographic area, and when the unmanned device in one geographic area needs to be remotely controlled, the service platform can distribute the operators to the unmanned device to remotely control the unmanned device, and the unmanned device can be particularly applied to the field of delivery through the unmanned device, such as business scenes of delivery such as express delivery, logistics and takeout using the unmanned device.
The above-mentioned custom computing layer can be determined by specific business requirements, that is, there are many custom computing layers, so that if a developer needs to write a custom computing layer in a model, the present invention can be applied, and if the developer needs to convert the model from one frame to another frame, the model parameters required by the custom computing layer can be converted from the custom computing layer in the model of one frame to the custom computing layer in the model of another frame by the model parameter conversion method mentioned in this specification.
It should be noted that all actions of acquiring signals, information or data in the present invention are performed under the premise of complying with the corresponding data protection regulation policy of the country of the location and obtaining the authorization given by the owner of the corresponding device.
It can be seen from the above method that if a new custom layer is needed if the model framework is fixed, only a function for converting the parameter type required by the model and the parameter type in the standard format to each other is deployed at the beginning, and only a conversion function for converting the parameter type in the standard format to the parameter type required by the custom layer needs to be customized, so that the efficiency of deploying the machine learning model by the developer can be improved by the above method.
The above method for converting model parameters provided for one or more embodiments of the present specification is based on the same idea, and the present specification further provides a device for converting model parameters, as shown in fig. 3.
Fig. 3 is a schematic diagram of a device for converting model parameters provided in this specification, which specifically includes:
an obtaining module 301, configured to obtain a model parameter in a parameter type required by a model to be constructed;
an importing module 302, configured to import the model parameters into the model to be built, so as to perform format conversion based on the model parameters through a parameter conversion relationship pre-deployed in the model to be built, so as to obtain first parameters in a standard format;
a conversion module 303, configured to convert the first parameter in the standard format through a conversion function preset in the model to be built, to obtain a first parameter in a parameter type required by a custom calculation layer, and transmit the first parameter to the custom calculation layer of the model to be built, so as to build a model to be built that includes the custom calculation layer, and execute a target service corresponding to the model to be built through the built model to be built, where the custom calculation layer is a network layer additionally configured for the target service.
Optionally, the importing module 302 is specifically configured to import the model parameters into the model to be built, so as to perform format conversion on first parameters, which are included in the model parameters and are except for second parameters, inside the model to be built to obtain the first parameters in the standard format, where the first parameters include parameters required by model calculation inside the custom calculation layer, and the second parameters include parameters required by other network structures, which are included in the model to be built and are except for the custom calculation layer;
the conversion module 303 is specifically configured to, according to the first parameter based on the standard format, convert the obtained first parameter in the parameter type required by the custom computation layer and the obtained second parameter, and construct a model to be constructed including the custom computation layer.
Optionally, the apparatus further comprises:
a storage module 304, configured to convert the first parameter in the standard format into a byte format when the model to be built is stored in a file format, to obtain the first parameter in the byte format, and store the first parameter in the byte format in a model file corresponding to the model to be built; when the model to be built is loaded through the model file, the first parameters in the byte format are restored to the first parameters in the standard format, so that the model to be built converts the first parameters in the standard format through the conversion function and then transmits the converted first parameters to the custom calculation layer of the model to be built.
Optionally, the model to be constructed at least includes a first model and a second model, the first model is a model that is constructed in a preset first model frame in a training stage and is directed to the target service, and the second model is a model that is constructed in a preset second model frame through the trained first model and is used for deploying and actually executing the target service.
Optionally, if the model to be constructed is a first model, the obtaining module 301 is specifically configured to obtain model parameters in a standard format; converting the model parameters in the standard format into model parameters in a first type corresponding to the first model frame, and transmitting the model parameters in the first type into the first model;
if the model to be constructed is a second model, the obtaining module 301 is specifically configured to convert the model parameters in the first type into model parameters in a second type corresponding to the second model frame, and transmit the model parameters in the second type into the second model.
Optionally, the obtaining module 301 is specifically configured to obtain a pre-configured parameter file; and reading the parameter file, and converting the model parameters stored in the parameter file into the model parameters in the standard format.
Optionally, the first model framework is a Torch framework and the second model framework is a TensorRT framework.
The present specification also provides a computer-readable storage medium having stored thereon a computer program, the computer program being operable to perform the method of model parameter transformation described above.
This specification also provides a schematic block diagram of the electronic device shown in fig. 4. As shown in fig. 4, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the nonvolatile memory to the memory and then runs the computer program to realize the method for converting the model parameters. Of course, besides the software implementation, the present specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may be hardware or logic devices.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present specification.

Claims (10)

1. A method of model parameter transformation, comprising:
obtaining model parameters under the parameter types required by the model to be constructed;
transmitting the model parameters into the model to be constructed so as to perform format conversion based on the model parameters through a parameter conversion relation deployed in the model to be constructed in advance, and obtaining first parameters in a standard format;
converting the first parameter in the standard format through a preset conversion function in the model to be built to obtain a first parameter in a parameter type required by a user-defined calculation layer, transmitting the first parameter to the user-defined calculation layer of the model to be built to build the model to be built containing the user-defined calculation layer, and executing a target service corresponding to the model to be built through the built model to be built, wherein the user-defined calculation layer is a network layer additionally configured for the target service.
2. The method of claim 1, wherein the transmitting the model parameters into the model to be constructed to perform format conversion based on the model parameters through a parameter conversion relationship pre-deployed in the model to be constructed to obtain first parameters in a standard format, specifically comprises:
transmitting the model parameters into the model to be built, so as to perform format conversion on first parameters, except for second parameters, contained in the model parameters inside the model to be built, to obtain the first parameters in the standard format, wherein the first parameters comprise parameters required by model calculation inside the custom calculation layer, and the second parameters comprise parameters required by other network structures except for the custom calculation layer in the model to be built;
constructing to-be-constructed models containing the custom computing layers, and specifically comprising the following steps:
and according to the first parameter based on the standard format, the first parameter under the parameter type required by the user-defined computation layer and the second parameter are obtained through conversion, and the model to be constructed containing the user-defined computation layer is constructed.
3. The method of claim 1, wherein the method further comprises:
when the model to be constructed is stored in a file format, converting the first parameter in the standard format into a byte format to obtain a first parameter in the byte format, and storing the first parameter in the byte format in a model file corresponding to the model to be constructed;
when the model to be built is loaded through the model file, the first parameters in the byte format are restored to the first parameters in the standard format, so that the model to be built converts the first parameters in the standard format through the conversion function and then transmits the converted first parameters to the custom calculation layer of the model to be built.
4. The method according to any one of claims 1 to 3, wherein the model to be constructed at least comprises a first model and a second model, the first model is a model constructed in a preset first model frame in a training stage and is aimed at the target business, and the second model is a model constructed in a preset second model frame through the trained first model and is used for deploying and actually executing the target business.
5. The method according to claim 4, wherein if the model to be constructed is the first model, obtaining model parameters required by the model to be constructed specifically comprises:
obtaining model parameters in a standard format;
converting the model parameters in the standard format into model parameters in a first type corresponding to the first model frame, and transmitting the model parameters in the first type into the first model;
if the model to be constructed is the second model, obtaining model parameters required by the model to be constructed, specifically comprising:
and converting the model parameters under the first type into model parameters under a second type corresponding to the second model frame, and transmitting the model parameters under the second type into the second model.
6. The method of claim 5, wherein obtaining model parameters in a standard format specifically comprises:
acquiring a pre-configured parameter file;
and reading the parameter file, and converting the model parameters stored in the parameter file into the model parameters in the standard format.
7. The method of claim 4, wherein the first model framework is a Torch framework and the second model framework is a TensorRT framework.
8. An apparatus for model parameter transformation, comprising:
the acquisition module is used for acquiring model parameters under the parameter types required by the model to be constructed;
the model parameter transmitting module is used for transmitting the model parameter into the model to be constructed so as to perform format conversion based on the model parameter through a parameter conversion relation deployed in the model to be constructed in advance to obtain a first parameter in a standard format;
the conversion module is used for converting the first parameter in the standard format through a conversion function preset in the model to be built to obtain a first parameter in a parameter type required by a custom calculation layer, transmitting the first parameter to the custom calculation layer of the model to be built to build the model to be built containing the custom calculation layer, and executing a target service corresponding to the model to be built through the built model to be built, wherein the custom calculation layer is a network layer additionally configured for the target service.
9. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1 to 7 when executing the program.
CN202210168582.9A 2022-02-23 2022-02-23 Method and device for converting model parameters Pending CN114546973A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210168582.9A CN114546973A (en) 2022-02-23 2022-02-23 Method and device for converting model parameters

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210168582.9A CN114546973A (en) 2022-02-23 2022-02-23 Method and device for converting model parameters

Publications (1)

Publication Number Publication Date
CN114546973A true CN114546973A (en) 2022-05-27

Family

ID=81677475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210168582.9A Pending CN114546973A (en) 2022-02-23 2022-02-23 Method and device for converting model parameters

Country Status (1)

Country Link
CN (1) CN114546973A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116167431A (en) * 2023-04-25 2023-05-26 之江实验室 Service processing method and device based on hybrid precision model acceleration
CN117724865A (en) * 2023-12-13 2024-03-19 行吟信息科技(武汉)有限公司 Service execution method, device, equipment and medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116167431A (en) * 2023-04-25 2023-05-26 之江实验室 Service processing method and device based on hybrid precision model acceleration
CN116167431B (en) * 2023-04-25 2023-08-04 之江实验室 Service processing method and device based on hybrid precision model acceleration
CN117724865A (en) * 2023-12-13 2024-03-19 行吟信息科技(武汉)有限公司 Service execution method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN114546973A (en) Method and device for converting model parameters
CN113011483B (en) Method and device for model training and business processing
CN111652351A (en) Deployment method, device and medium of neural network model
CN110569428A (en) recommendation model construction method, device and equipment
CN107038058B (en) Code processing method and device
CN112597013A (en) Online development and debugging method and device
CN115203394A (en) Model training method, service execution method and device
CN107391529B (en) Method and device for realizing Object Relation Mapping (ORM)
CN110852503A (en) Method and device for selecting payment channel and payment channel route
CN115981870A (en) Data processing method and device, storage medium and electronic equipment
CN115146601A (en) Method and device for executing language processing task, readable storage medium and equipment
CN117828360A (en) Model training method, model training device, model code generating device, storage medium and storage medium
CN108345536A (en) A kind of dispositions method, device and the equipment of continuous integrating environment
CN114861665B (en) Method and device for training reinforcement learning model and determining data relation
CN109597695B (en) Data processing method, device and equipment
CN115034367A (en) Model deployment method and device
CN115758141A (en) Method and device for model training and business wind control
CN115543945A (en) Model compression method and device, storage medium and electronic equipment
CN110704742B (en) Feature extraction method and device
CN114996570A (en) Information recommendation method and device
CN114594944A (en) Application construction system and device
CN115017905A (en) Model training and information recommendation method and device
CN111984247A (en) Service processing method and device and electronic equipment
CN111596946A (en) Recommendation method, device and medium for intelligent contracts of block chains
CN117519733B (en) Project deployment method and device, storage medium and electronic equipment

Legal Events

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