Object optimization method, device, computer equipment and storage medium
By obtaining the deployment environment data of the target object, determining the optimization target and performing multiple optimizations, the problem of low object optimization efficiency in traditional methods is solved, and efficient matching and optimization between objects and environment is achieved.
Patent Information
- Application Number
- CN202210361815.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-07
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2042-04-07
AI Technical Summary
When traditional object optimization methods are deployed to the target deployment environment, they cannot effectively match environmental requirements, resulting in poor performance and low optimization efficiency.
By obtaining the deployment environment data of the target object, determining the optimization target, and multi-optimizing according to the parameter optimization strategy that is appropriate to the environment, filtering candidate optimization objects that meet the conditions as the final result.
It improves the matching degree between the object optimization results and the deployment environment, improves the optimization efficiency, and enables the object to accurately reflect the real situation in the deployment environment.
Smart Images

Figure CN115115046B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an object optimization method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] Object optimization can make an object more suitable for a specific application scenario, thereby enabling its application in multiple technical fields. Traditionally, object optimization has focused on a specific aspect of performance. For example, optimizing a neural network model often focuses on the model's reasoning performance.
[0003] However, when the optimized object is deployed in the target deployment environment, for example, when the optimized model is deployed on a hardware platform, the optimized object may have poor performance during runtime due to the constraints of the environment's storage space, computing power, and operating framework, and may not be able to meet and reflect the actual situation of the environment. In other words, the optimization efficiency of objects in traditional technologies is not high. Summary of the Invention
[0004] Based on this, it is necessary to provide an object optimization method, device, computer equipment, computer-readable storage medium and computer program product that can improve the optimization efficiency of the object in response to the above technical problems.
[0005] In a first aspect, the present application provides an object optimization method. The method comprises:
[0006] Acquire a target object and determine a target deployment environment for the target object;
[0007] Determining at least one optimization goal for the target object based on the object data of the target object and the environment data of the target deployment environment;
[0008] For each of the optimization objectives, performing multi-path optimization on the target object according to a parameter optimization strategy adapted to the target deployment environment, to obtain a plurality of candidate optimization objects that meet the optimization objective;
[0009] The object parameters corresponding to each of the candidate optimization objects are obtained, and the candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results of the target object.
[0010] In a second aspect, the present application further provides an object optimization device. The device comprises:
[0011] An acquisition module, configured to acquire a target object and determine a target deployment environment for the target object;
[0012] a determination module, configured to determine at least one optimization target for the target object based on the object data of the target object and the environment data of the target deployment environment;
[0013] An optimization module, configured to perform multi-path optimization on the target object according to a parameter optimization strategy adapted to the target deployment environment for each optimization target, to obtain a plurality of candidate optimization objects that meet the optimization target;
[0014] The screening module is used to obtain the object parameters corresponding to each of the candidate optimization objects, and determine the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object.
[0015] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above method when executed by a processor.
[0017] In a fifth aspect, the present application further provides a computer program product, which includes a computer program that implements the steps of the above method when executed by a processor.
[0018] The object optimization method, apparatus, computer device, computer-readable storage medium, and computer program product described above obtain a target object, determine the target deployment environment of the target object, and determine at least one optimization target for the target object based on the object data of the target object and the environment data of the target deployment environment. This method allows the optimization target for the target object to match the target deployment environment. Furthermore, for each optimization target, the target object is multi-path optimized according to a parameter optimization strategy adapted to the target deployment environment to obtain multiple candidate optimization objects that meet the optimization target. Furthermore, by obtaining the object parameters corresponding to each candidate optimization object, the candidate optimization objects whose object parameters meet the object parameter screening criteria are determined as the optimization results for the target object. This method improves the matching degree between the optimization result of the target object and the target deployment environment, achieves customized optimization based on the target deployment environment, and improves the optimization efficiency of the target object. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A diagram illustrating an application environment of an object optimization method according to an embodiment;
[0020] Figure 2A schematic flow chart of an object optimization method according to an embodiment;
[0021] Figure 3 A schematic diagram of performing weight matrix pruning on a target object in one embodiment;
[0022] Figure 4 is a schematic diagram of performing weight matrix pruning on a target object in another embodiment;
[0023] Figure 5 Schematic diagram of optimizing parameters of each level of a multi-level object in a specific embodiment;
[0024] Figure 6 is a schematic diagram of evaluating each candidate optimization object in a specific embodiment;
[0025] Figure 7 is a structural block diagram of an object optimization device in one embodiment;
[0026] Figure 8 is a diagram of the internal structure of a computer device in one embodiment;
[0027] Figure 9 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0029] It should be noted that the data involved in this application, including but not limited to the object data of the target object, the environmental data of the target deployment environment, etc., are all data that have been fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0030] In one embodiment, the object optimization method provided by this application can be applied to Figure 1 In the illustrated application environment, the application environment involves both device 102 and server 104. In some embodiments, the application environment may also involve device 106. Devices 102 and 106 communicate with server 104 via a network. A data storage system can store data that server 104 needs to process. The data storage system can be integrated with server 104, or it can be located in the cloud or on another server.
[0031] Specifically, server 104 obtains a target object and determines a target deployment environment for the target object. For example, server 104 obtains a target object from device 102 and determines that the target deployment environment for the target object is device 106. Alternatively, server 104 obtains a target object from device 106 and determines that the target deployment environment for the target object is device 102. Furthermore, server 104 determines at least one optimization target for the target object based on the object data of the target object and the environment data of the target deployment environment. For each optimization target, server 104 performs multi-path optimization on the target object according to a parameter optimization strategy adapted to the target deployment environment to obtain multiple candidate optimization objects that meet the optimization target. Object parameters corresponding to each candidate optimization object are obtained, and candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results for the target object. Thus, server 104 can send the optimization results of the target object to the device where the target deployment environment is located for deployment.
[0032] In one embodiment, the object optimization method provided by this application may be applied only to device 102 if the computing processing capabilities of device 102 meet the requirements. Specifically, the target deployment environment of the target object is device 102. Device 102 obtains the target object and optimizes the target object. After determining the optimization result of the target object, the optimized result of the target object is deployed on device 102.
[0033] Devices 102 and 106 may be, but are not limited to, various desktop computers, laptops, smartphones, tablet computers, IoT devices, and portable wearable devices. IoT devices may include smart TVs, smart car devices, etc. Portable wearable devices may include smart watches, smart bracelets, etc. Server 104 may be implemented as a standalone server or a server cluster consisting of multiple servers.
[0034] In one embodiment, Figure 2 As shown, an object optimization method is provided, which is applied to Figure 1 Taking the server 104 in FIG. 1 as an example, the method includes the following steps S202 to S208:
[0035] Step S202: Acquire the target object and determine the target deployment environment of the target object.
[0036] In one embodiment, the target object refers to the object to be optimized, including but not limited to various types of data such as neural network models, applications, and applets. Deployment refers to the action of publishing the target object to the target deployment environment. The target deployment environment refers to the series of hardware platforms and software environments required or located during the deployment of the target object, including but not limited to computer processors, memory, hard disks, operating systems and versions, operating permissions, databases and versions, containers, clusters, and dependent images. It may also include mobile devices, edge computing devices, and devices equipped with specific types of chips.
[0037] It should be noted that the target deployment environment will impose constraints or restrictions on the deployment of the target object. Therefore, in order to make the target object more adaptable to the target deployment environment and improve the operating performance when running the target object, before carrying out the deployment of the target object, it is necessary to determine the target deployment environment of the target object and perform reasonable optimization before deploying the target object.
[0038] Specifically, the target object is obtained, and the target deployment environment of the target object is determined. The target object is a complete object that is predetermined and can be run directly. For example, if the target object is a neural network model, when the target object is obtained, a pre-trained neural network model that can be run directly is obtained, without the need to perform the training process of the neural network model, so as to effectively improve the efficiency of optimizing the target object. For another example, if the neural network model needs to be deployed on an edge computing device, such as deploying a pre-trained face recognition model on an AI camera with artificial intelligence (AI) capabilities, where the AI camera is an edge computing device, then the target object is the pre-trained face recognition model, and the target deployment environment is the AI camera. For example, if the pre-trained facial feature extraction model is deployed on a server equipped with a predetermined type of graphics processing unit (GPU), then the target object is the pre-trained facial feature extraction model, and the target deployment environment is a server equipped with a predetermined type of GPU.
[0039] Step S204: determining at least one optimization target for the target object based on the object data of the target object and the environment data of the target deployment environment.
[0040] In one embodiment, object data refers to data related to the performance and attributes of a target object, including but not limited to parameters such as the target object's size, type, accuracy, latency, weight, and training framework. Different target objects may correspond to different types of object data. Environment data refers to data related to the attributes of the target deployment environment, including but not limited to data such as the target deployment environment's version type, storage space, computing speed, and runtime framework.
[0041] In one embodiment, the optimization target refers to the target when optimizing the target object, and the optimization target needs to be determined based on the object data of the target object and the environmental data of the target deployment environment. For a target object and a target deployment environment in which it is deployed, there may be one or more optimization targets for the target object. For example, a pre-trained face recognition model is deployed on an AI camera with artificial intelligence (AI) capabilities, the target object is the pre-trained face recognition model, and the target deployment environment is the AI camera. Based on the size, accuracy, and training framework of the face recognition model, as well as the storage space, computing rate, and running framework of the AI camera, it can be determined that the optimization target of the face recognition model may be one or more of model size optimization, model accuracy optimization, and model inference performance optimization.
[0042] It should be noted that there can be one or more optimization targets for the target object. If there is only one optimization target, the target object can be optimized according to the optimization target. If there are multiple optimization targets for the target object, the target object can be optimized for each optimization target. Specifically, one of the optimization targets can be arbitrarily determined as the first optimization target, and the optimization process can be performed according to the first optimization target to obtain the object after the first optimization process. Then, a second optimization target can be determined. When the optimization process is performed according to the second optimization target, the original target object can be optimized, or the object after the first optimization process obtained last time can be further optimized. The principles of subsequent processing are the same until the optimization process is completed for all optimization targets.
[0043] Step S206 : For each optimization target, perform multi-path optimization on the target object according to a parameter optimization strategy adapted to the target deployment environment to obtain a plurality of candidate optimization objects that meet the optimization target.
[0044] In one embodiment, for each optimization objective, one or more optimization methods may exist. By combining one or more optimization methods, multiple corresponding parameter optimization strategies may exist for each optimization objective, and the parameter optimization strategies are adapted to the target deployment environment. The optimization objective, the optimization methods under the optimization objective, and the parameter optimization strategies may be pre-set based on actual technical needs or configured by a configuration object based on actual conditions. The configuration object may be a user or other developer.
[0045] Specifically, for each optimization target of the target object, the optimization methods existing under the optimization target are determined, and according to the environmental parameters of the target deployment environment, the parameter optimization strategy adapted to the target deployment environment is determined, and the parameter optimization strategy is one or more combinations of the optimization methods. For example, for an optimization target of the target object, the optimization methods existing under the optimization target include the first optimization method, the second optimization method, and the third optimization method. The parameter optimization strategies adapted to the target deployment environment may include the following: executing only the first optimization method, executing only the second optimization method, executing only the third optimization method, executing the first optimization method and the second optimization method, executing the first optimization method and the third optimization method, executing the second optimization method and the third optimization method, executing the first optimization method, the second optimization method, and the third optimization method.
[0046] For each optimization objective, after determining a parameter optimization strategy that matches the target deployment environment, a multi-path optimization is performed on the target object according to each parameter optimization strategy. Each parameter optimization strategy corresponds to an optimization method, also referred to in this embodiment as a single-path optimization of the target object. After optimization, each parameter optimization strategy corresponds to a processed target object, referred to as a candidate optimization object. Specifically, under a single optimization objective, multiple candidate optimization objects that meet that objective can be obtained. Consequently, these multiple candidate optimization objects can then be screened and finally selected as a single optimization object.
[0047] Step S208 : obtaining the object parameters corresponding to each candidate optimization object, and determining the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object.
[0048] In one embodiment, object parameters refer to parameters related to the performance and attributes of a candidate optimization object, including but not limited to the size, type, accuracy, latency, weight, and other parameters of the candidate optimization object. Upon obtaining the candidate optimization objects, the corresponding object parameters for each candidate optimization object are obtained. It should be noted that the object parameters of the candidate optimization objects and the object data of the target object can either correspond to each other or contain different data content, and can be set according to actual technical needs.
[0049] The object parameter screening conditions refer to the conditions set when screening multiple candidate optimization objects. They can be set according to actual technical needs. For example, they can be set according to the object parameters of each candidate optimization object, or they can be set based on the requirements of the configuration object.
[0050] Specifically, the object parameters corresponding to each candidate optimization object are obtained, and the candidate optimization object whose object parameters meet the object parameter screening criteria is determined as the optimization result of the target object. There is only one candidate optimization object that meets the object screening criteria, and this candidate optimization object is determined as the final optimization object for the target object. This candidate optimization object can then be deployed.
[0051] In the above-mentioned object optimization method, a target object is obtained, a target deployment environment of the target object is determined, and at least one optimization target for the target object is determined based on the object data of the target object and the environment data of the target deployment environment. This method can match the optimization target for the target object with the target deployment environment. Furthermore, for each optimization target, the target object is multi-path optimized according to a parameter optimization strategy adapted to the target deployment environment to obtain multiple candidate optimization objects that meet the optimization target. By obtaining the object parameters corresponding to each candidate optimization object, the candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results of the target object. This method can improve the matching degree between the optimization results of the target object and the target deployment environment, improve the optimization efficiency of the target object, and achieve customized optimization based on the target deployment environment. Therefore, when the optimization results of the target object are deployed in the target deployment environment, the operating results of the target object can accurately reflect the actual situation of the target deployment environment.
[0052] In one embodiment, the optimization target, the optimization method under the optimization target, and the parameter optimization strategy can be pre-set according to actual technical needs. Specifically, based on the object data of the target object and the environment data of the target deployment environment, determining at least one optimization target for the target object includes the following steps S302 to S304:
[0053] Step S302: obtaining an association relationship between an object deployed in a target deployment environment and an object optimization target, wherein the association relationship is constructed based on object data of the object and environment data of the target deployment environment.
[0054] In one embodiment, an association between objects deployed in a target deployment environment and object optimization goals is pre-established and stored. The association can be constructed based on object data of the objects and environment data of the target deployment environment. For each object deployed in the target deployment environment, it can correspond to at least one object optimization goal.
[0055] It should be noted that this association also stores the optimization method for each object's optimization objective, as well as the parameter optimization strategy corresponding to each object objective. Furthermore, the content of this association can be dynamically updated based on data such as the target deployment environment and the objects deployed within it. Specifically, the association between the objects deployed within the target deployment environment and the object's optimization objectives is obtained, so that the optimization objective corresponding to the target object can be determined based on this association.
[0056] Step S304 : performing optimization target matching on the target object deployed in the target deployment environment according to the association relationship, and obtaining at least one optimization target that matches the target object.
[0057] In one embodiment, matching can be performed based on the object data of the target object according to the association relationship. First, the object that matches the target object and is deployed in the target deployment environment is determined, and then the object optimization target corresponding to the matched object is determined as the optimization target that matches the target object. The optimization target includes at least one, that is, at least one optimization target that matches the target object is obtained.
[0058] In this embodiment, by pre-establishing an association relationship between the object deployed in the target deployment environment and the object optimization target, matching can be performed directly based on the association relationship according to the object data of the target object to determine the optimization target when the target object is deployed in the target deployment environment, which can effectively improve the efficiency of determining the optimization target of the target object.
[0059] In one embodiment, the optimization target, the optimization method under the optimization target, and the parameter optimization strategy may be configuration operations performed on a configuration object based on actual conditions. Specifically, determining at least one optimization target for the target object based on object data of the target object and environmental data of the target deployment environment includes: obtaining at least one optimization target configured for the target object in response to the optimization target configuration operation, wherein the at least one optimization target matches the object data of the target object and the environmental data of the target deployment environment.
[0060] Among them, the optimization target configuration operation refers to the configuration operation performed by the configuration object for the optimization target of the target object. By responding to the optimization target configuration operation, the optimization target of the target object can be obtained. The configuration object can be a user or other developer, that is, the configuration object directly selects and determines the optimization target. In addition, the configuration object can also specify the optimization method under the optimization target, as well as the parameter optimization strategy corresponding to the optimization target. Specifically, the configuration object can perform the optimization target configuration operation based on the object data of the target object and the environmental data of the target deployment environment, that is, at least one optimization target of the target object finally determined matches the object data of the target object and the environmental data of the target deployment environment.
[0061] In this embodiment, by responding to the optimization target configuration operation of the configuration object, a series of customized settings for optimizing the target object can be directly obtained, which can improve the efficiency of determining the optimization target and improve the configuration experience of the configuration object.
[0062] In one embodiment, the target object includes a multi-level object. A multi-level object refers to a target object having a multi-level structure, where each level of the multi-level structure corresponds to a level. For example, if the target object is a neural network model, the model structure of the neural network model is a multi-level structure, and the neural network model can also be called a multi-level object.
[0063] If the target object is a multi-level object, the parameter optimization strategy can also be a parameter optimization strategy for each level. In this case, the parameter optimization strategy includes: a hierarchical parameter optimization strategy for each level. Among them, a hierarchical parameter optimization strategy is a parameter optimization strategy for a specific level.
[0064] It should be noted that the level parameter optimization strategies corresponding to each level of the multi-level object can be the same or different, that is, each level can execute the same level parameter optimization strategy, and can also execute specific level parameter optimization strategies corresponding to different levels. The specific settings can be made according to actual technical needs and are not limited here.
[0065] In one embodiment, if the target object is a multi-level object, for each optimization target, a multi-path optimization is performed on the target object according to a parameter optimization strategy adapted to the target deployment environment to obtain multiple candidate optimization objects that meet the optimization target, including the following steps S402 to S404:
[0066] Step S402: For each optimization target, determine a hierarchical parameter optimization strategy that is compatible with the target deployment environment.
[0067] If the target object is a multi-level object, the parameter optimization strategy can be a hierarchical parameter optimization strategy for each level of the multi-level object. Specifically, for each optimization objective, a hierarchical parameter optimization strategy is determined that is compatible with the target deployment environment. Optimization methods for multi-level object optimization objectives include, but are not limited to, object quantization, weight matrix pruning, and object type conversion.
[0068] Among them, object quantization processing refers to the processing method of converting floating-point storage and integer storage into each other, which can compress the storage space occupied by the target object and improve the performance parameters of the object to a certain extent. For example, if the target object is a neural network model, the 32-bit floating-point number parameters in the target object can be mapped to 8-bit integers. At the same time, since part of the target object metadata needs to be stored to reduce the precision loss of the target object, after mapping the 32-bit floating-point number parameters in the target object to 8-bit integers, the storage space can be reduced by up to 75%. At the same time, the reasoning speed of the object can be increased by about 2 to 4 times. Alternatively, the parameters of the 32-bit floating-point number can be quantized to 16-bit floating-point numbers, thereby reducing the storage space by 50%. At the same time, the reasoning speed of the object can be improved to a certain extent.
[0069] Specifically, taking the target object as a neural network model as an example, the neural network model can be a face recognition model that needs to be deployed on an AI camera with artificial intelligence (AI) capabilities. The face recognition model can specifically be a convolutional neural network model. The weights between neurons in the neural network model are usually represented using 32-bit floating-point numbers during model training, and their accuracy can fully meet the requirements of the neural network model. When object quantization processing is performed, some of the model's weights can be converted into 16-bit floating-point numbers or 8-bit integer representations, which can save 50% and 75% of the storage space of the weight matrix respectively.
[0070] Among them, the method for converting a 32-bit floating-point number into a 16-bit floating-point number can be to obtain the 16-bit floating-point number closest to the 32-bit floating-point number, thereby directly converting the 32-bit floating-point number into a 16-bit floating-point number. For example, the number 0.123 is represented as approximately 0.1230000034 and 0.12298584 in 32-bit floating-point and 16-bit floating-point numbers, respectively. Under these two representations, the above two data are closest. Therefore, the number 0.123 in the 32-bit floating-point representation of 0.1230000034 can be converted into 0.12298584 in the 16-bit floating-point representation. Because the neural network model itself has a certain degree of fault tolerance, directly converting the 32-bit floating-point number into a 16-bit floating-point number by obtaining the 16-bit floating-point number closest to the 32-bit floating-point number has little impact on the model's performance.
[0071] Among them, 8-bit integers can represent 256 numbers. Generally, it is possible to measure the distribution of all parameters in the weight matrix of a layer, obtain the upper limit of the value required to represent the layer, expressed as T, and set the value that the 8-bit integer of the layer can express, expressed as -T,...,0,T / 127,2T / 127,...,126T / 127, with a precision of T / 127. The way to convert a 32-bit floating-point number to an 8-bit integer is to obtain the value that can be expressed by the closest 8-bit integer to the 32-bit floating-point number. When the 32-bit floating-point number exceeds the expression range, it can be treated as -T or 126T / 127. Among them, values greater than 0 are treated as 126T / 127, and values less than 0 are treated as -T.
[0072] Among them, weight matrix pruning refers to a method of sparsifying part of the weight matrix, which can compress the size of the target object, that is, compress the storage space occupied by the target object, and improve the performance parameters of the target object. Among them, the parameter pruning ratio θ of weight matrix pruning needs to be set according to actual technical needs, and 0<θ<1. For example, for an n×n weight matrix, if only the first predetermined number of elements with the largest absolute value need to be retained, the predetermined number is n, then the matrix parameters after weight matrix pruning become 1 / n of the original.
[0073] Specifically, taking the target object as a neural network model as an example, the neural network model may be a face recognition model that needs to be deployed on an AI camera with artificial intelligence (AI) capabilities, and the face recognition model may specifically be a convolutional neural network model. Figure 3 The figure shows a schematic diagram of weight matrix pruning for a target object in one embodiment. The left figure is a schematic diagram of a weight matrix of a neural network model. The matrix width is C. After the weight matrix is pruned and sparsely processed, as shown in the right figure, the width of the weight matrix after sparse processing is only C / 2, thereby compressing the size of the target object and accelerating reasoning when the target object is running. Figure 4 The figure shows a schematic diagram of another embodiment of pruning the weight matrix of a target object. The left figure is a schematic diagram of the weight matrix of a neural network model, and the right figure is a schematic diagram of the weight matrix after pruning and sparsification. Assuming that the weight matrix of the neural network model is an m×n weight matrix, the parameter pruning ratio θ is used. The first mnθ elements with the largest absolute value in the weight matrix are retained, and the remaining elements are set to 0, thereby achieving a sparsification effect.
[0074] It is generally believed that the smaller the parameter pruning ratio θ of weight matrix pruning, that is, the more parameters are deleted in a single pruning, this may cause the parameter pruning to exceed the fault tolerance of the neural network model, resulting in an excessive decrease in accuracy. Therefore, the weight matrix pruning can be completed through multiple iterations of the neural network model, where one iteration of the model refers to a retraining of the model. Each iteration is used to prune away a portion of the model's weight matrix parameters, and through the retraining of the model, the remaining non-zero elements in the weight matrix are optimized to avoid an excessive decrease in the model's accuracy. Specifically, the smaller the parameter pruning ratio θ of weight matrix pruning, that is, the more parameters need to be pruned and deleted in a single pruning, the more model iterations are required to ensure the accuracy of the model. The corresponding relationship between the parameter pruning ratio θ and the number of model iterations can be set according to actual technical needs. For example, if the parameter pruning ratio θ is set to 20%, the corresponding number of model iterations can be 4.
[0075] When performing weight matrix pruning, each iteration of the model can delete the same number of parameters, or a predetermined proportion of the current parameters. The specific setting can be based on actual technical needs. For example, it can be specified by the configuration user through configuration operations, or preset empirical values based on the type of neural network model. For example, if it is necessary to retain 1 / 8 of the parameters and the corresponding number of iterations is 3, then 7 / 24 of the parameters can be removed in each iteration. Alternatively, 1 / 2 of the parameters can be removed in the first iteration, 1 / 4 of the parameters can be removed in the second iteration, and 1 / 8 of the parameters can be removed in the third iteration.
[0076] It should be noted that the above-mentioned weight matrix pruning can be to retain a predetermined proportion of parameters for the entire weight matrix, or it can be to perform sparse processing according to a specific structure. For example, each column of the weight matrix retains a specific number of elements, each row retains a part of several consecutive elements, retains a block matrix, etc. The specific settings can be made according to actual technical needs.
[0077] Among them, object type conversion refers to converting an object into another format type. For example, if the target object is a neural network model and its type is a PyTorch model, it can be converted into an Open Neural Network Exchange (ONNX) model to remove unnecessary information when the object is inferred, thereby reducing the size of the object and improving the inference speed to a certain extent.
[0078] In one embodiment, if the target object is a multi-level object, the hierarchical parameter optimization strategy adapted to the target deployment environment can be one or more of the three optimization methods described above. The hierarchical parameter optimization strategies corresponding to each level of the multi-level object can be the same or different, and can be set according to actual technical needs. Specifically, the hierarchical parameter optimization strategies may include: only performing object quantization processing, only performing weight matrix pruning, only performing object type conversion, performing object quantization processing and weight matrix pruning, performing object quantization processing and object type conversion, performing weight matrix pruning and object type conversion, performing object quantization processing and weight matrix pruning and object type conversion, and performing object quantization processing and weight matrix pruning and object type conversion.
[0079] It should be noted that, since weight matrix pruning affects the performance parameters of the target object, when weight matrix pruning is included in the parameter optimization strategy, after the weight matrix pruning process is performed, the target object can be trained again using the training data of the target object to fine-tune the parameters of the target object to ensure the accuracy of the target object. Among them, a preset proportion of training data can be randomly extracted and the target object can be retrained to fine-tune the parameters of the target object. The preset proportion can be set according to actual technical needs, for example, it can be set according to a preset experience value, the parameter pruning ratio of the weight matrix pruning, the size of the training data, etc.
[0080] Furthermore, while retraining the target object does take some time, it only accounts for a small portion of the target object's entire inference cycle and has little impact on the target object's overall optimization duration and operational efficiency. For example, if the target object is a neural network model, the time taken to train and optimize the model may be measured in days, while when the model is deployed in the target deployment environment, the time spent on inference may be measured in months or even years.
[0081] It should also be noted that after object quantization, the parameters of the target object can also be fine-tuned to achieve better accuracy, and the fine-tuning method can be the same as the method in the above embodiment. Compared with weight matrix pruning, object quantization has a lower impact on the performance parameters of the target object. Therefore, in order to improve the optimization processing efficiency of the target object, after performing object quantization, while ensuring the accuracy of the target object, for example, while ensuring that the degree of decrease in the accuracy of the target object does not exceed a preset decrease, it is possible to choose not to fine-tune the parameters based on actual technical needs.
[0082] Step S404 , performing multi-path optimization on the parameters of each level of the multi-level object according to the level order of the multi-level object and the level parameter optimization strategy of each level, to obtain a plurality of candidate optimization objects that meet the optimization target.
[0083] The hierarchical order of a multi-level object refers to the order corresponding to each level of the multi-level object. It can be determined based on the levels that the data passes through from input to output when the multi-level object is processing data, or it can be configured and specified through a configuration object. For example, if the target object is a neural network model, assuming that the neural network model includes an input layer, a hidden layer, and an output layer, after the data is input into the neural network model, when the neural network model processes the data, the levels that the data passes through from input to output are the input layer, hidden layer, and output layer, then the input layer, hidden layer, and output layer are correspondingly determined as the first level, the second level, the third level, and so on. When the parameters of each level of the multi-level object are subsequently optimized, the optimization is performed in the order of the first level, the second level, the third level, and so on.
[0084] Specifically, according to the hierarchical order of the multi-level objects and the hierarchical parameter optimization strategy of each level, multi-path optimization can be performed on the parameters of each level of the multi-level objects, that is, multiple optimization methods can be used for optimization. Therefore, after the multi-path optimization is completed, multiple candidate optimization objects that meet the optimization goals can be obtained.
[0085] It should be noted that when optimizing the parameters of each level of a multi-level object, usually, under the condition of sufficient optimization time, especially when the level parameter optimization strategy includes weight matrix pruning or object quantization processing, it is preferred to adjust the optimization method layer by layer in the order of the levels. Taking the target object as a neural network model as an example, the neural network model has a high fault tolerance. When the parameters of a certain layer are pruned by weight matrix or quantized by object, the parameters of this layer and other layers can be optimized through small-scale retraining to reduce the degree of accuracy reduction of the neural network model, thereby improving the accuracy of the neural network model. If multiple layers are adjusted and optimized at the same time, the impact on the accuracy of the neural network model will be greater than adjusting layer by layer. It can be understood that the specific adjustment method can also be set according to actual technical needs.
[0086] In this embodiment, by determining the hierarchical parameter optimization strategy for each level, customized adjustment optimization for different levels can be achieved. By performing multi-path optimization on the parameters of each level according to the hierarchical order of the multi-level objects and the hierarchical parameter optimization strategy corresponding to each level, the degree of accuracy reduction of the multi-level objects can be reduced, that is, the accuracy of the multi-level objects after optimization can be ensured, thereby improving the optimization efficiency.
[0087] In one embodiment, the above-mentioned multi-path optimization is performed on the parameters of each layer of the multi-layer object according to the hierarchical order of the multi-layer object and the hierarchical parameter optimization strategy of each layer to obtain multiple candidate optimization objects that meet the optimization target. Specifically, the following steps S502 to S506 may be included:
[0088] In step S502 , the hierarchical parameters of the target hierarchical level in the multi-level object are optimized using the hierarchical parameter optimization strategy of the target hierarchical level. After the hierarchical parameter optimization is completed, the target hierarchical optimization object is obtained.
[0089] The target object includes a multi-level object. Since the multi-level object is adjusted and optimized layer by layer in the order of the levels, the level that currently needs to be optimized in the multi-level object is called the target level. After the optimization of the target level is completed, the target object is called the target level optimization object. For example, if the target object is a neural network model, assuming that the neural network model includes an input layer, a hidden layer, and an output layer, which correspond to the first level, the second level, and the third level respectively, the first level, the second level, and the third level need to be optimized in sequence. Therefore, the first level that currently needs to be optimized can be called the target level.
[0090] Specifically, the target level in the multi-level object is determined, and the level parameters of the target level in the multi-level object are optimized using the level parameter optimization strategy of the target level. After the level parameter optimization of the target level is completed, the target level optimization object can be obtained.
[0091] Step S504: If the target-level optimization object satisfies the object index corresponding to the target level, the next level of the target object is determined as the target level.
[0092] Object indicators refer to the performance parameter indicators corresponding to the target-level optimization object. When optimizing for different target levels, different object indicators can be associated with the target level. The specific type and corresponding value of the object indicator can be set based on actual technical needs. For example, the object indicator can be accuracy or any other metric that can be used to evaluate performance. The corresponding value can be preset based on the target object and target deployment environment, or it can be configured and determined by the configuration object.
[0093] If the target level optimization object meets the target level's corresponding object indicators, the next level of the target object is determined as the target level. In other words, only after the current target level is optimized and the target level optimization object meets the target level's corresponding object indicators, the subsequent next level optimization is performed. At this time, the next level of the target level is determined as the target level.
[0094] In one embodiment, if the target-level optimization object does not meet the object index corresponding to the target level, the target-level hierarchical parameter optimization strategy can be adjusted based on the current object index corresponding to the target-level optimization object, until the target-level hierarchical parameter optimization strategy is used to optimize the target-level hierarchical parameters, resulting in a target-level optimization object that meets the object index corresponding to the target level. That is, at this point, by optimizing the target level parameters using the adjusted hierarchical parameter optimization strategy, the target-level optimization object can meet the object index corresponding to the target level. Then, the subsequent optimization of the next level is performed, and at this point, the next level of the target level is determined as the target level.
[0095] In one embodiment, if the target level optimization object does not meet the corresponding object indicators of the target level, the parameter optimization strategy of the target level can be abandoned, and the next level of the target object can be determined as the target level. In other words, parameter optimization of the target level is abandoned, and no parameter optimization is performed. The original level parameters are retained, and subsequent parameter optimization is performed directly on the next level.
[0096] It should be noted that if the target level optimization object does not meet the object indicators corresponding to the target level, it can be determined based on actual technical needs whether to adjust the level parameter optimization strategy or give up parameter optimization for the target level, for example, according to the current object indicators of the target level optimization object. Alternatively, the priority of the above two processing methods can be pre-set. Regardless of whether you choose to adjust the level parameter optimization strategy for the target level or choose to give up parameter optimization for the target level, when entering the parameter optimization of the next level, it is still optimized according to the level parameter optimization strategy corresponding to the next level. That is, the adjustment for the previous target level will not affect the next target level.
[0097] Step S506, returning to the step of optimizing the parameters of the target level in the multi-level object using the target level parameter optimization strategy, until the target object has no next level, and obtaining a candidate optimization object that meets the optimization target.
[0098] If the target level optimization object meets the object indicators corresponding to the target level, the next level of the target object is determined as the target level. At this time, return to step S504 and use the same principle to optimize the next target level until there is no next level of the target object, and obtain a candidate optimization object that meets the optimization target.
[0099] For example, the target object is a neural network model, and it is assumed that the neural network model includes the first level, the second level, and the third level. The target level is the first level, and the first-level parameter optimization strategy of the first level is used for parameter optimization. After the first-level parameter optimization is completed, the first-level optimization object corresponding to the neural network model is obtained. If the first-level optimization object meets the object index corresponding to the first level, it is determined that the first-level optimization is completed. If the first-level optimization object does not meet the object index corresponding to the first level, it can be determined based on the current object index of the first-level optimization object whether to adjust the first-level parameter optimization strategy or abandon the parameter optimization of the first level. Then, the second level can be determined as the target level, and the second-level parameter optimization strategy of the second level can be used for parameter optimization. The optimization principle is the same as that of the first level, until all three levels of the neural network model are optimized and the candidate optimization object is obtained.
[0100] In this embodiment, by optimizing layer by layer, and only when the optimized object at the target layer can meet the object indicators corresponding to the target layer, the optimization of the next target layer is performed. This allows the adjustment of parameters at each layer to meet the set object indicators, reduce the impact on the performance parameters of the target object, and improve optimization efficiency.
[0101] In one embodiment, for each optimization target, multiple candidate optimization objects that meet the optimization target can be obtained. Therefore, in order to facilitate the screening of an object that ultimately meets the target deployment environment, for each optimization target, the target object is multi-path optimized according to a parameter optimization strategy that is adapted to the target deployment environment. After obtaining multiple candidate optimization objects that meet the optimization target, it also includes: generating an object optimization report for the target object based on the object parameters corresponding to each candidate optimization object, and the object optimization report is used to store the object parameters corresponding to each candidate optimization object.
[0102] The object optimization report includes the object parameters corresponding to all candidate optimization objects. The object parameters can be attributes and performance parameter indicators, including but not limited to the accuracy, size, average inference time, longest inference time, X-quantile inference time, weight matrix value, etc. of the candidate optimization object.
[0103] In this embodiment, by generating an object optimization report and storing the object parameters corresponding to each candidate optimization object, it is convenient to subsequently screen the candidate optimization objects in combination with the object optimization report, thereby improving the screening efficiency of screening multiple candidate optimization objects.
[0104] In one embodiment, after obtaining multiple candidate optimization objects, it is necessary to screen and determine the final object to be deployed in the target deployment environment. This can be determined by evaluating the candidate optimization objects. Specifically, the object parameters corresponding to each candidate optimization object are obtained, and the candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results of the target object. The following steps S602 to S606 may be included:
[0105] Step S602: evaluate each candidate optimization object through the target deployment environment to obtain parameter evaluation results corresponding to each candidate optimization object.
[0106] Evaluation involves deploying candidate optimization objects in a set environment and performing reasoning on them to obtain inference results. By evaluating candidate optimization objects, we can measure their performance parameters during the inference process and select those that meet the parameter selection criteria.
[0107] In one embodiment, to ensure consistency between the evaluation process of candidate optimization objects and the reasoning process of candidate optimization objects, and to improve the efficiency of evaluating candidate optimization objects, any possible method can be used to build an evaluation environment consistent with the reasoning framework of the target deployment environment through a hardware platform. Evaluation can then be performed using this hardware platform to evaluate each candidate optimization object through the target deployment environment, thereby obtaining parameter evaluation results corresponding to each candidate optimization object. The parameter evaluation results may include various evaluation attributes and performance parameter indicators of the candidate optimization object, and the specific types may correspond to the parameters stored in the object optimization report.
[0108] In one embodiment, in order to improve the efficiency of object optimization and evaluation, the optimization process and the evaluation process can be built through a server cluster. At this time, the evaluation environment built includes an evaluation module and an optimization module. Among them, the optimization module is used to perform object optimization and can be implemented as a part of a microservice or a single service. The optimization module is mainly divided into two parts. One is the management of optimization tasks, which is mainly used to start, stop, query, and delete optimization tasks. The other is the specific execution of optimization tasks. The execution of each optimization task can be completed by starting a container, or by a thread, process, or coroutine. Among them, the container refers to the division of individual resources into isolated groups in order to better balance conflicting resource usage requirements between isolated groups.
[0109] The evaluation module consists of three main parts: evaluation task management, which is responsible for starting, stopping, querying, and deleting evaluation tasks; evaluation task data collection, which is responsible for invoking the specific inference services that the evaluation task relies on, collecting data, and generating reports; and the evaluation inference process, which is responsible for providing inference services and handling calls for evaluation data collection. Each model evaluation task can start a container to collect the data for that model evaluation task, or the evaluation module can complete this task through a thread, process, or coroutine.
[0110] The implementation of evaluation and inference services depends on the specific model inference framework and hardware platform, and also requires ensuring that the input and output formats of the provided interfaces are consistent. For example, hardware platforms include edge computing devices, servers equipped with graphics processing units (GPUs), and terminals equipped with network processing units (NPUs). For face recognition models, there are inference frameworks suitable for each hardware platform. As long as the interface input and output formats are consistent, the collection and management of model evaluation task data can be done without worrying about the specific inference process. Simply call the corresponding interface and pass in a face image in the interface input format to obtain evaluation results that conform to the interface output format.
[0111] Step S604: Based on the parameter evaluation results and the object optimization report, determine the candidate optimization objects whose object parameters meet the object parameter screening conditions.
[0112] Based on the parameter evaluation results of each candidate optimization object and the optimization report, candidate optimization objects whose object parameters meet the object parameter screening criteria are comprehensively determined. The number of candidate optimization objects that meet the object parameter screening criteria is set to one. For example, the object parameter screening criteria can include selecting the smallest objects, selecting the objects with the best inference performance, or selecting objects with a size not exceeding a preset size and with various performance indicators exceeding set values. The specific settings can be determined based on actual technical needs.
[0113] Step S606: Determine the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object.
[0114] After determining a candidate optimization object whose object parameters meet the object parameter screening conditions, the candidate optimization object whose object parameters meet the object parameter screening conditions can be determined as the optimization result of the target object, so that it can be deployed in the target deployment environment.
[0115] In this embodiment, the candidate optimization objects are evaluated through the target deployment environment, and the evaluation results and the object optimization report are combined for comprehensive screening to determine the final optimization result of the target object. Then, it can be deployed in the target deployment environment, which can make the optimization result more compatible with the specific target deployment environment, realize customized optimization of the target object based on the target deployment environment, and improve the optimization effect.
[0116] The present application will be further described in detail below with reference to the accompanying drawings and a specific embodiment. It should be understood that the specific embodiment described herein is only used to explain the present application and is not intended to limit the present application.
[0117] In a specific embodiment, the target object is a neural network model and the target deployment environment is a computer device. The target object is a pre-trained model with a multi-layer structure. Before deploying the target object in the target deployment environment, the target object needs to be optimized. The steps are as follows:
[0118] Get the target object and determine the target deployment environment of the target object.
[0119] In one embodiment, for example, if a pre-trained facial recognition model is deployed on an AI camera with artificial intelligence (AI) capabilities, the target object is the pre-trained facial recognition model, and the target deployment environment is the AI camera. For another example, if a pre-trained facial feature extraction model is deployed on a server equipped with a predetermined type of graphics processing unit (GPU), the target object is the pre-trained facial feature extraction model, and the target deployment environment is the server equipped with the predetermined type of GPU.
[0120] Based on the object data of the target object and the environmental data of the target deployment environment, at least one optimization target for the target object is determined; wherein, at least one optimization target for the target object can be determined according to the version type, storage space, computing rate, running framework of the target deployment environment, and the size, type, accuracy, latency, weight and training framework of the target object. The optimization target can be model size optimization, model accuracy optimization, model inference performance optimization, etc.
[0121] Specifically, an association relationship between an object deployed in a target deployment environment and an optimization target for the object can be obtained, where the association relationship is constructed based on the object data of the object and the environment data of the target deployment environment. Based on the association relationship, optimization target matching is performed on the target object deployed in the target deployment environment to obtain at least one optimization target that matches the target object. Alternatively, in response to an optimization target configuration operation, at least one optimization target configured for the target object is obtained, where the at least one optimization target matches the object data of the target object and the environment data of the target deployment environment.
[0122] In one embodiment, for example, the user's facial recognition model has an accuracy index of 99%, but because the model is too large to be deployed on the AI camera, the optimization goal in this case can be to optimize the model size, and the accuracy index of the optimized model can be set to 95%, and the inference performance requirement is that the average latency does not exceed 50 milliseconds (ms). For another example, the user's facial feature extraction model has an accuracy index of 99%, but because the model's inference performance cannot handle all facial profile requests during peak traffic periods, the optimization goal in this case can be to optimize the model's inference performance, and the accuracy index of the optimized model can be set to 97%.
[0123] For each optimization target, the target object is multi-path optimized according to the parameter optimization strategy adapted to the target deployment environment to obtain multiple candidate optimization objects that meet the optimization target; wherein, for each optimization target, a hierarchical parameter optimization strategy adapted to the target deployment environment is determined; according to the hierarchical order of the multi-level objects and the hierarchical parameter optimization strategy of each level, the parameters of each level of the multi-level objects are multi-path optimized to obtain multiple candidate optimization objects that meet the optimization target.
[0124] In one embodiment, a target level in a multi-level object is first determined. Then, the level parameters of the target level are optimized using the level parameter optimization strategy of the target level. After the level parameter optimization is completed, a target level optimization object is obtained. If the target level optimization object meets the object indicators corresponding to the target level, the next level of the target object is determined as the target level. The step of optimizing the level parameters of the target level in the multi-level object using the level parameter optimization strategy of the target level is returned until the target object no longer has a next level. A candidate optimization object that meets the optimization target is obtained.
[0125] like Figure 5 The figure shows a schematic diagram of optimizing the parameters of each level of a multi-level object in a specific embodiment. For the convenience of description, taking the neural network model including three levels, namely the first level, the second level, and the third level, and the optimization goal being model size optimization as an example, one of the level parameter optimization strategies under this optimization goal is: pruning the weight matrix and quantizing the level parameters of each level in turn, and then performing a model type conversion. There are also multiple other level parameter optimization strategies under this optimization goal, which are one or more combinations of the above three processing methods. Each level parameter optimization strategy can correspond to a candidate optimization model.
[0126] Specifically, the target level is first determined to be the first level. Parameter optimization is performed using the first-level parameter optimization strategy for the first level. The first-level parameter optimization strategy involves sparsifying the first level using weight matrix pruning. After the sparsification process is completed, the first-level optimization object corresponding to the neural network model is obtained. The first-level optimization object is retrained using training data from randomly selected target objects to achieve parameter fine-tuning. The current accuracy of the first-level optimization object is then determined.
[0127] If the current accuracy meets the accuracy index corresponding to the first level, the sparsification processing of the first level is determined to be completed, and the sparsification processing of the second and third levels is performed, that is, the second and third levels are respectively used as the target levels, and the processing method is the same as the sparsification processing method of the first level.
[0128] If the current accuracy does not meet the accuracy index corresponding to the first level, the sparse processing method of the first level can be adjusted according to the current accuracy, or the sparse processing of the first level can be abandoned, and then the sparse processing of the second and third levels can be performed.
[0129] After all levels of sparsification are completed, each level is quantized in the same manner. Quantization can be done by mapping 32-bit floating-point numbers to 8-bit integers or 16-bit floating-point numbers, effectively reducing the storage space occupied by the model and improving the model's inference speed to a certain extent. After all levels of quantization are completed, the model can be losslessly converted to an ONNX model to remove unnecessary information during the model inference process to reduce the model size. If other indicator requirements are set, for example, a latency indicator is set, when the model also meets the latency indicator, the final candidate optimization object that meets the optimization goal is obtained.
[0130] Then, based on the object parameters corresponding to each candidate optimization object, an object optimization report for the target object is generated. The object optimization report is used to store the object parameters corresponding to each candidate optimization object. The object optimization report includes the accuracy, size, average inference time, maximum inference time, X-quantile inference time, and weight matrix values of the candidate optimization object.
[0131] Then, each candidate optimization object is evaluated through the target deployment environment to obtain the parameter evaluation results corresponding to each candidate optimization object.
[0132] In one embodiment, in order to improve the efficiency of evaluating multiple candidate optimization objects, a unified evaluation module can be built to perform unified evaluation. The evaluation module is mainly composed of three parts, including the management of evaluation tasks, which is mainly responsible for starting, stopping, querying, and deleting evaluation tasks; the collection of evaluation task data, which is mainly responsible for calling the specific reasoning service that the evaluation task depends on, and is responsible for data collection and report generation; the evaluation reasoning process, which is mainly responsible for providing reasoning services and taking over the call of the evaluation data collection part. Among them, for each model evaluation task, a container can be started to be responsible for the collection of the model evaluation task data, or it can be completed by the evaluation module through a thread, process or coroutine. The implementation of the evaluation reasoning service depends on the specific model reasoning framework and hardware platform, and it is also necessary to ensure that the input and output formats of the provided interface are the same. For example, the hardware platforms include edge computing devices, servers equipped with graphics processing units (GPUs), and terminals equipped with network processing units (NPUs). For face recognition models, there are inference frameworks suitable for each hardware platform. As long as the interface input and output formats are the same, the collection and management of model evaluation task data can be done without worrying about the specific inference process. Instead, you only need to call the corresponding interface and pass in the face image in the format that conforms to the interface input to obtain the evaluation results that conform to the interface output format.
[0133] Taking the four evaluation tasks A, B, C, and D as an example, all four evaluation tasks are aimed at obtaining the accuracy and inference time of the face recognition model. The four evaluation tasks are described as follows:
[0134]
[0135]
[0136] Among them, NVIDIA Triton is an open source inference framework, ONNX Runtime is an engine for ONNX model inference, TNN Runtime is an engine for TNN model inference, NNIE (Neural Network Inference Engine) is a unit in a predetermined type of chip SoC that is specifically designed to accelerate the processing of neural network models, and WK is a quantized model format supported by NNIE.
[0137] For example, the management of evaluation tasks is an independent service, and the collection and deployment of evaluation task data is an independent container. Figure 6 The following is a schematic diagram of evaluating each candidate optimization object, in which four evaluation tasks are run simultaneously. The evaluation module can be accessed by the user individually to start the evaluation task or view the parameter evaluation results, etc. It can also be used by the user to Figure 6It should be noted that the above model optimization process can also be implemented directly through the model optimization service. The model optimization service is mainly divided into two parts: the first is the management of optimization tasks, which is mainly used to start, stop, query, and delete optimization tasks; the second is the specific execution of optimization tasks. The execution of each optimization task can be completed by starting a container, or by a thread, process, or coroutine.
[0138] Finally, based on the parameter evaluation results and the object optimization report, candidate optimization objects are identified whose object parameters meet the object parameter screening criteria. In one embodiment, candidate optimization objects with the smallest model size or the best inference performance can be screened out. The candidate optimization objects whose object parameters meet the object parameter screening criteria are then determined as the optimization results for the target object. Furthermore, the optimization results for the target object can be deployed in the target deployment environment.
[0139] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0140] Based on the same inventive concept, embodiments of the present application also provide an object optimization device for implementing the object optimization method described above. The implementation solution provided by this device is similar to the implementation solution described in the above method. Therefore, the specific limitations of one or more object optimization device embodiments provided below can be found in the above-mentioned limitations of the object optimization method and will not be repeated here.
[0141] In one embodiment, Figure 7 As shown, an object optimization device 700 is provided, comprising: an acquisition module 710, a determination module 720, an optimization module 730 and a screening module 740, wherein:
[0142] The acquisition module 710 is configured to acquire a target object and determine a target deployment environment of the target object.
[0143] The determination module 720 is configured to determine at least one optimization target for the target object based on the object data of the target object and the environment data of the target deployment environment.
[0144] The optimization module 730 is configured to perform multi-path optimization on the target object for each optimization target according to a parameter optimization strategy adapted to the target deployment environment, and obtain a plurality of candidate optimization objects that meet the optimization target.
[0145] The screening module 740 is configured to obtain the object parameters corresponding to each of the candidate optimization objects, and determine the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object.
[0146] In one embodiment, the determination module 720 is used to obtain the association relationship between the object deployed in the target deployment environment and the object optimization target, where the association relationship is constructed based on the object data of the object and the environment data of the target deployment environment; according to the association relationship, the target object deployed in the target deployment environment is matched with the optimization target to obtain at least one optimization target that matches the target object.
[0147] In one embodiment, the determination module 720 is configured to obtain at least one optimization target configured for the target object in response to an optimization target configuration operation, where the at least one optimization target matches the object data of the target object and the environment data of the target deployment environment.
[0148] In one embodiment, the target object includes: a multi-level object, and the parameter optimization strategy includes: a hierarchical parameter optimization strategy for each level; the optimization module 730 is used to determine, for each optimization target, a hierarchical parameter optimization strategy that is compatible with the target deployment environment; according to the hierarchical order of the multi-level object and the hierarchical parameter optimization strategy for each level, multi-path optimization is performed on the parameters of each level of the multi-level object to obtain multiple candidate optimization objects that meet the optimization target.
[0149] In one embodiment, the optimization module 730 is used to optimize the hierarchical parameters of the target level in the multi-level object using the hierarchical parameter optimization strategy of the target level, and obtain the target level optimization object after the hierarchical parameter optimization is completed; if the target level optimization object meets the object index corresponding to the target level, the next level of the target object is determined as the target level; return to the step of optimizing the hierarchical parameters of the target level in the multi-level object using the hierarchical parameter optimization strategy of the target level, until the target object no longer has a next level, and obtain a candidate optimization object that meets the optimization target.
[0150] In one embodiment, the optimization module 730 is used to adjust the hierarchical parameter optimization strategy of the target level according to the current object indicator corresponding to the target level optimization object if the target level optimization object does not meet the object indicator corresponding to the target level, until the adjusted hierarchical parameter optimization strategy is used to optimize the hierarchical parameters of the target level, and the obtained target level optimization object meets the object indicator corresponding to the target level.
[0151] In one embodiment, the optimization module 730 is used to abandon the use of the target level parameter optimization strategy for parameter optimization if the target level optimization object does not meet the object index corresponding to the target level, and determine the next level of the target object as the target level.
[0152] In one embodiment, the device also includes: a generation module; the generation module is used to generate an object optimization report of the target object based on the object parameters corresponding to each of the candidate optimization objects, and the object optimization report is used to store the object parameters corresponding to each of the candidate optimization objects.
[0153] In one embodiment, the screening module 740 is used to evaluate each of the candidate optimization objects through the target deployment environment to obtain parameter evaluation results corresponding to each of the candidate optimization objects; based on each of the parameter evaluation results and the object optimization report, determine the candidate optimization objects whose object parameters meet the object parameter screening conditions; and determine the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object.
[0154] Each module in the object optimization device described above may be implemented in whole or in part through software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0155] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store object optimization data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an object optimization method is implemented.
[0156] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an object optimization method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0157] Those skilled in the art will understand that Figure 8 and Figure 9The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0158] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0159] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0160] In one embodiment, a computer program product is provided, comprising a computer program, which implements the steps of the above method when executed by a processor.
[0161] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0162] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0163] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. An object optimization method, characterized in that: The method comprises: Acquire a target object and determine a target deployment environment for the target object; Determining at least one optimization goal for the target object based on the object data of the target object and the environment data of the target deployment environment; For each of the optimization targets, a hierarchical parameter optimization strategy adapted to the target deployment environment is determined; the target object includes a multi-level object having a multi-level structure, and the parameter optimization strategy includes a hierarchical parameter optimization strategy for each level; According to the hierarchical order of the multi-level objects and the hierarchical parameter optimization strategy of each level, multi-path optimization is performed on the hierarchical parameters of the multi-level objects to obtain a plurality of candidate optimization objects that meet the optimization goal; the hierarchical parameter optimization strategy includes weight matrix pruning, which means that in the process of iterating the neural network model multiple times according to the number of model iterations corresponding to the parameter pruning ratio, a portion of the weight matrix parameters of the neural network model is pruned at each iteration according to the parameter pruning ratio, so as to complete a weight matrix pruning through multiple iterations of the neural network model; The object parameters corresponding to each of the candidate optimization objects are obtained, and the candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results of the target object.
2. The method according to claim 1, characterized in that The determining, based on the object data of the target object and the environment data of the target deployment environment, at least one optimization goal for the target object includes: Acquire an association relationship between an object deployed in a target deployment environment and an object optimization target, wherein the association relationship is constructed based on object data of the object and environment data of the target deployment environment; According to the association relationship, optimization target matching is performed on the target object deployed in the target deployment environment to obtain at least one optimization target that matches the target object.
3. The method according to claim 1, characterized in that The determining, based on the object data of the target object and the environment data of the target deployment environment, at least one optimization goal for the target object includes: In response to the optimization target configuration operation, at least one optimization target configured for the target object is obtained, and the at least one optimization target matches the object data of the target object and the environment data of the target deployment environment.
4. The method according to claim 1, wherein According to the hierarchical order of the multi-level objects and the hierarchical parameter optimization strategy of each level, multi-path optimization is performed on the hierarchical parameters of the multi-level objects to obtain multiple candidate optimization objects that meet the optimization goal, including: Optimizing the hierarchical parameters of the target hierarchical level in the multi-level object using the hierarchical parameter optimization strategy of the target hierarchical level, and obtaining the target hierarchical optimization object after the hierarchical parameter optimization is completed; If the target level optimization object satisfies the object index corresponding to the target level, the next level of the target object is determined as the target level; Returning the hierarchical parameters of the target level in the multi-level object, and performing parameter optimization using the hierarchical parameter optimization strategy of the target level, until the target object does not have a next level, obtaining a candidate optimization object that meets the optimization target.
5. The method according to claim 4, characterized in that The method further comprises: If the target level optimization object does not meet the object indicators corresponding to the target level, the level parameter optimization strategy of the target level is adjusted according to the current object indicators corresponding to the target level optimization object, until the level parameters of the target level are optimized using the adjusted level parameter optimization strategy, and the obtained target level optimization object meets the object indicators corresponding to the target level.
6. The method according to claim 4, characterized in that The method further comprises: If the target level optimization object does not meet the object index corresponding to the target level, the parameter optimization using the level parameter optimization strategy of the target level is abandoned, and the next level of the target object is determined as the target level.
7. The method according to claim 1, characterized in that After performing multi-path optimization on the target object according to the parameter optimization strategy adapted to the target deployment environment for each optimization target to obtain multiple candidate optimization objects that meet the optimization target, the method further includes: An object optimization report for the target object is generated according to the object parameters corresponding to each of the candidate optimization objects. The object optimization report is used to store the object parameters corresponding to each of the candidate optimization objects.
8. The method according to claim 7, characterized in that The obtaining of the object parameters corresponding to each of the candidate optimization objects and determining the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object includes: Evaluate each of the candidate optimization objects through the target deployment environment to obtain parameter evaluation results corresponding to each of the candidate optimization objects; Determining, based on the parameter evaluation results and the object optimization report, candidate optimization objects whose object parameters meet the object parameter screening conditions; The candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results of the target object.
9. An object optimization device, characterized in that: The device comprises: An acquisition module, configured to acquire a target object and determine a target deployment environment for the target object; a determination module, configured to determine at least one optimization target for the target object based on the object data of the target object and the environment data of the target deployment environment; An optimization module is used to determine, for each of the optimization targets, a hierarchical parameter optimization strategy that is compatible with the target deployment environment; the target object includes a multi-level object having a multi-level structure, and the parameter optimization strategy includes a hierarchical parameter optimization strategy for each level; according to the hierarchical order of the multi-level object and the hierarchical parameter optimization strategy for each level, multi-path optimization is performed on the parameters of each level of the multi-level object to obtain a plurality of candidate optimization objects that meet the optimization target; the hierarchical parameter optimization strategy includes weight matrix pruning, which means that in the process of iterating the neural network model multiple times according to the number of model iterations corresponding to the parameter pruning ratio, a part of the weight matrix parameters of the neural network model are pruned at each iteration according to the parameter pruning ratio, so as to complete a weight matrix pruning through multiple iterations of the neural network model; The screening module is used to obtain the object parameters corresponding to each of the candidate optimization objects, and determine the candidate optimization objects whose object parameters meet the object parameter screening conditions as the optimization results of the target object.
10. The device according to claim 9, characterized in that The determining module is further configured to: Obtain an association relationship between an object deployed in a target deployment environment and an object optimization target, where the association relationship is constructed based on object data of the object and environment data of the target deployment environment; perform optimization target matching on the target object deployed in the target deployment environment according to the association relationship, and obtain at least one optimization target that matches the target object.
11. The device according to claim 9, characterized in that The determining module is further configured to: In response to the optimization target configuration operation, at least one optimization target configured for the target object is obtained, and the at least one optimization target matches the object data of the target object and the environment data of the target deployment environment.
12. The device according to claim 9, characterized in that The optimization module is further used to: Optimizing the parameters of the target layer in the multi-layer object using the target layer parameter optimization strategy, and obtaining the target layer optimization object after the layer parameter optimization is completed; If the target level optimization object satisfies the object index corresponding to the target level, the next level of the target object is determined as the target level; Returning the hierarchical parameters of the target level in the multi-level object, and performing parameter optimization using the hierarchical parameter optimization strategy of the target level, until the target object does not have a next level, obtaining a candidate optimization object that meets the optimization target.
13. The device according to claim 12, characterized in that The optimization module is further used to: If the target level optimization object does not meet the object indicators corresponding to the target level, the level parameter optimization strategy of the target level is adjusted according to the current object indicators corresponding to the target level optimization object, until the level parameters of the target level are optimized using the adjusted level parameter optimization strategy, and the obtained target level optimization object meets the object indicators corresponding to the target level.
14. The device according to claim 13, characterized in that The optimization module is further used to: If the target level optimization object does not meet the object index corresponding to the target level, the parameter optimization using the level parameter optimization strategy of the target level is abandoned, and the next level of the target object is determined as the target level.
15. The device according to claim 9, characterized in that The device further includes a generating module, configured to: An object optimization report for the target object is generated according to the object parameters corresponding to each of the candidate optimization objects. The object optimization report is used to store the object parameters corresponding to each of the candidate optimization objects.
16. The device according to claim 15, characterized in that The screening module is further used for: Evaluate each of the candidate optimization objects through the target deployment environment to obtain parameter evaluation results corresponding to each of the candidate optimization objects; determine the candidate optimization objects whose object parameters meet the object parameter screening conditions based on the parameter evaluation results and the object optimization report; The candidate optimization objects whose object parameters meet the object parameter screening conditions are determined as the optimization results of the target object.
17. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Neural network pruning method and device, electronic equipment and storage medium
CN112288087A
Artificial intelligence AI model evaluation method, system and device
CN112508044A
Neural network model automatic adaptation method and device
CN113128682A