A model sensitivity determination method, apparatus and electronic device
By calculating the reconstruction error for specified parameters of the target network layer, the problem of time-consuming model sensitivity determination is solved, and efficient and hardware resource-saving model sensitivity determination is achieved.
Patent Information
- Application Number
- CN202111604614.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2041-12-24
AI Technical Summary
Existing methods for determining model sensitivity are time-consuming and inefficient, making it difficult to efficiently determine the stability of a model.
By calculating the reconstruction error for specified parameters of the target network layer, the sensitivity index of each specified parameter is determined, thereby deriving the sensitivity of the target network layer and reducing the inference process for the entire model.
It improves the efficiency of model sensitivity determination, reduces hardware resource consumption, and supports batch determination of model sensitivity.
Smart Images

Figure CN114358245B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine learning technology, and in particular to a method, apparatus, and electronic device for determining model sensitivity. Background Technology
[0002] Currently, with the continuous development of artificial intelligence technology, various models are being applied to various fields, such as image recognition, voice interaction, and security monitoring.
[0003] In the process of using various models, the stability of the model output plays an important role in the accuracy of the model output. Therefore, for a trained model, users usually want to be able to determine the sensitivity of the model.
[0004] The sensitivity of a model refers to the stability of its output for a given sample. It can be understood as the robustness of the model in acquiring sample features given known samples. Higher model sensitivity results in lower stability of the model's output, and vice versa.
[0005] In related technologies, the method for determining model sensitivity involves pruning different substructures of a trained model, fine-tuning the structure of the pruned model, and then determining the accuracy of the output of the fine-tuned model. Furthermore, it involves determining how this determined accuracy compares to the accuracy of the output of the unpruned model, and then determining the model's sensitivity based on this change. Specifically, a significant decrease in accuracy indicates higher model sensitivity, and vice versa. However, in these related technologies, model sensitivity is determined by the accuracy of the model's output. Each time this accuracy is determined, the entire model needs to be reasoned, resulting in a time-consuming and inefficient process for determining model sensitivity. Summary of the Invention
[0006] The purpose of this invention is to provide a model sensitivity determination method, apparatus, and electronic device to reduce the time consumed in the model sensitivity determination process and improve the efficiency of model sensitivity determination. The specific technical solution is as follows:
[0007] In a first aspect, embodiments of the present invention provide a method for determining model sensitivity, the method comprising:
[0008] For each target network layer in the target model whose sensitivity needs to be determined, perform the following steps:
[0009] For each specified parameter in the target network layer, determine the output result of the target network layer after removing the specified parameter, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter;
[0010] Determine the expected output of the post-network layer, and based on the expected output and the output corresponding to each specified parameter, determine the reconstruction error corresponding to the specified parameter;
[0011] Based on the reconstruction error corresponding to each specified parameter, determine the sensitivity index corresponding to that specified parameter;
[0012] The sensitivity of the target network layer is determined based on the sensitivity index corresponding to each specified parameter.
[0013] Optionally, in one specific implementation, determining the expected output result of the subsequent network layer includes:
[0014] Based on the first output result of the target network layer, the second output result of the subsequent network layer is determined, and based on the second output result, the expected output result of the subsequent network layer is determined.
[0015] or,
[0016] Based on the functionality of the target model, construct the desired output result of the subsequent network layer.
[0017] Optionally, in one specific implementation, determining the desired output result of the subsequent network layer based on the second output result includes:
[0018] The second output result is determined as the expected output result of the subsequent network layer;
[0019] or,
[0020] The second output result is corrected using a preset algorithm to obtain the corrected output result of the post-network layer, and the corrected output result is determined as the expected output result of the post-network layer.
[0021] Optionally, in one specific implementation, determining the reconstruction error corresponding to the specified parameter based on the expected output result and the output result corresponding to each specified parameter includes:
[0022] The difference between the expected output and the output corresponding to each specified parameter is calculated as the reconstruction error corresponding to that specified parameter.
[0023] or,
[0024] Calculate the similarity between the expected output and the output corresponding to each specified parameter, and use it as the reconstruction error corresponding to that specified parameter.
[0025] Optionally, in one specific implementation, before determining the sensitivity index corresponding to each specified parameter based on the reconstruction error corresponding to each specified parameter, the method further includes:
[0026] Based on the function of the target model, the reconstruction error corresponding to each specified parameter is weighted and corrected to obtain the correction error corresponding to each specified parameter.
[0027] The process of determining the sensitivity index corresponding to each specified parameter based on the reconstruction error includes:
[0028] Based on the correction error corresponding to each specified parameter, determine the sensitivity index corresponding to that specified parameter.
[0029] Optionally, in one specific implementation, determining the sensitivity of the target network layer based on the sensitivity index corresponding to each specified parameter includes:
[0030] The ratio of the number of specified parameters whose corresponding sensitivity index is less than a preset threshold to the total number of specified parameters is used as the sensitivity of the target network layer.
[0031] Optionally, in one specific implementation, the subsequent network layer of each target network layer is the next network layer after the target network layer.
[0032] Secondly, embodiments of the present invention provide a model sensitivity determination apparatus, the apparatus comprising:
[0033] The result determination module is used to determine the output result of the target network layer after removing the specified parameter for each specified parameter in each target network layer in the target model whose sensitivity is to be determined, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter;
[0034] The error determination module is used to determine the expected output result of the subsequent network layer of each target network layer, and to determine the reconstruction error corresponding to each specified parameter based on the expected output result and the output result corresponding to each specified parameter in the target network layer.
[0035] The index determination module is used to determine the sensitivity index corresponding to each specified parameter for each target network layer based on the reconstruction error corresponding to each specified parameter in the target network layer.
[0036] The sensitivity determination module is used to determine the sensitivity of each target network layer by specifying the sensitivity index corresponding to the parameters.
[0037] Optionally, in one specific implementation, the error determination module includes:
[0038] The first determining submodule is used to determine the second output result of the subsequent network layer based on the first output result of the target network layer, and to determine the expected output result of the subsequent network layer based on the second output result; or, the second determining submodule is used to construct the expected output result of the subsequent network layer based on the function of the target model.
[0039] Optionally, in one specific implementation, the first determining submodule is specifically used to: determine the second output result as the expected output result of the post-network layer; or, use a preset algorithm to correct the second output result to obtain the corrected output result of the post-network layer, and determine the corrected output result as the expected output result of the post-network layer.
[0040] Optionally, in one specific implementation, the error determination module is specifically used to: calculate the difference between the expected output result and the output result corresponding to each specified parameter, as the reconstruction error corresponding to the specified parameter; or, calculate the similarity between the expected output result and the output result corresponding to each specified parameter, as the reconstruction error corresponding to the specified parameter.
[0041] Optionally, in one specific implementation, the device further includes: an error correction module, used to perform weighted correction on the reconstruction error corresponding to each specified parameter based on the function of the target model before determining the sensitivity index corresponding to each specified parameter based on the reconstruction error corresponding to each specified parameter, so as to obtain the correction error corresponding to each specified parameter; the sensitivity determination module is specifically used to: determine the sensitivity index corresponding to each specified parameter based on the correction error corresponding to each specified parameter.
[0042] Optionally, in one specific implementation, the sensitivity determination module is specifically used to: for each target network layer, calculate the ratio of the number of specified parameters whose corresponding sensitivity index is less than a preset threshold in the target network layer to all specified parameters in the target network layer, and use this ratio as the sensitivity of the target network layer;
[0043] Optionally, in one specific implementation, the subsequent network layer of each target network layer is the next network layer after the target network layer.
[0044] Thirdly, embodiments of the present invention provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0045] Memory, used to store computer programs;
[0046] When a processor executes a program stored in memory, it implements the steps of any of the model sensitivity determination methods provided in the first aspect above.
[0047] Fourthly, embodiments of the present invention provide a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the model sensitivity determination methods provided in the first aspect above.
[0048] Fifthly, embodiments of the present invention provide a computer program product containing instructions that, when run on a computer, cause the computer to perform the steps of any of the model sensitivity determination methods provided in the first aspect.
[0049] Beneficial effects of the embodiments of the present invention:
[0050] As can be seen from the above, when determining model sensitivity using the solution provided in the embodiments of the present invention, the target network layers whose sensitivity needs to be determined in the target model can be identified first. Then, for each target network layer, specific parameters can be determined. For each specific parameter, the output result of the target network layer after removing that parameter is determined, and based on that output result, the output result of the subsequent network layer of the target network layer is determined as the output result corresponding to that specific parameter. Next, the expected output result of the subsequent network layer of the target network layer can be determined, and based on the expected output result and the output results corresponding to the aforementioned specific parameters, the reconstruction error corresponding to each specific parameter is determined. Then, based on the reconstruction error corresponding to each specific parameter, the sensitivity index corresponding to that specific parameter can be determined; furthermore, based on the sensitivity index corresponding to each specific parameter, the sensitivity of the target network layer is determined. Thus, after determining the sensitivity of each target network layer in the target model whose sensitivity needs to be determined, the obtained sensitivities can be used as the model sensitivity of the target model.
[0051] Based on this, the solution provided by the embodiments of the present invention determines the sensitivity of the target model based on the expected output results of the post-layers of each target network layer. In other words, it is only necessary to infer the post-layers of each network layer, and it is not possible to infer the entire model. Therefore, the time consumption of the model sensitivity determination process can be reduced and the efficiency of model sensitivity determination can be improved.
[0052] Furthermore, since it is not necessary to infer the entire model, the determination of model sensitivity can reduce the consumption of hardware resources such as CPU (Central Processing Unit) and GPU (Graphics Processing Unit), thus saving hardware resources. Moreover, because the determination of model sensitivity is less time-consuming, it is also easier to determine model sensitivity in batches.
[0053] Of course, implementing any product or method of the present invention does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings.
[0055] Figure 1 A flowchart illustrating a model sensitivity determination method provided in an embodiment of the present invention;
[0056] Figure 2 This is a graph showing the change in the reconstruction error of feature points when the preset algorithm is the sigmoid algorithm in a specific implementation.
[0057] Figure 3 A flowchart illustrating another model sensitivity determination method provided in an embodiment of the present invention;
[0058] Figure 4 This is a schematic diagram of a model sensitivity determination device provided in an embodiment of the present invention;
[0059] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0060] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of the present invention.
[0061] In related technologies, the method for determining model sensitivity involves pruning different substructures of a trained model, fine-tuning the structure of the pruned model, and then determining the accuracy of the output of the fine-tuned model. Furthermore, it involves determining how this determined accuracy compares to the accuracy of the output of the unpruned model, and then determining the model's sensitivity based on this change. Specifically, a significant decrease in accuracy indicates higher model sensitivity, and vice versa. However, in these related technologies, model sensitivity is determined by the accuracy of the model's output. Each time this accuracy is determined, the entire model needs to be reasoned, resulting in a time-consuming and inefficient process for determining model sensitivity.
[0062] To address the aforementioned technical problems, embodiments of the present invention provide a method for determining model sensitivity.
[0063] This method is applicable to any application scenario requiring sensitivity determination of a trained model, such as image recognition, voice interaction, and intelligent security. Furthermore, it can be applied to various electronic devices, including laptops, desktop computers, and servers (hereinafter referred to as electronic devices). The electronic device executing this method can be a standalone device or at least one device within a system or device cluster. Therefore, this embodiment of the invention does not specify the application scenarios or the executing entity of the method.
[0064] This invention provides a method for determining model sensitivity, which may include:
[0065] For each target network layer in the target model whose sensitivity needs to be determined, perform the following steps:
[0066] For each specified parameter in the target network layer, determine the output result of the target network layer after removing the parameter, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter;
[0067] Determine the expected output of the post-network layer, and based on the expected output and the output corresponding to each specified parameter, determine the reconstruction error corresponding to the specified parameter;
[0068] Based on the reconstruction error corresponding to each specified parameter, determine the sensitivity index corresponding to that specified parameter;
[0069] The sensitivity of the target network layer is determined based on the sensitivity index corresponding to each specified parameter.
[0070] As can be seen from the above, when determining model sensitivity using the solution provided in the embodiments of the present invention, the target network layers whose sensitivity needs to be determined in the target model can be identified first. Then, for each target network layer, specific parameters can be determined. For each specific parameter, the output result of the target network layer after removing that parameter is determined, and based on that output result, the output result of the subsequent network layer of the target network layer is determined as the output result corresponding to that specific parameter. Next, the expected output result of the subsequent network layer of the target network layer can be determined, and based on the expected output result and the output results corresponding to the aforementioned specific parameters, the reconstruction error corresponding to each specific parameter is determined. Then, based on the reconstruction error corresponding to each specific parameter, the sensitivity index corresponding to that specific parameter can be determined; furthermore, based on the sensitivity index corresponding to each specific parameter, the sensitivity of the target network layer is determined. Thus, after determining the sensitivity of each target network layer in the target model whose sensitivity needs to be determined, the obtained sensitivities can be used as the model sensitivity of the target model.
[0071] Based on this, the solution provided by the embodiments of the present invention determines the sensitivity of the target model based on the expected output results of the post-layers of each target network layer. In other words, it is only necessary to infer the post-layers of each network layer, and it is not possible to infer the entire model. Therefore, the time consumption of the model sensitivity determination process can be reduced and the efficiency of model sensitivity determination can be improved.
[0072] Furthermore, since the entire model does not need to be inferred, the determination of model sensitivity reduces the use of hardware resources such as CPU (Central Processing Unit) and GPU (Graphics Processing Unit), thus saving hardware resources. Moreover, because the determination of model sensitivity is less time-consuming, it also makes it easier to determine model sensitivity in batches.
[0073] The following, with reference to the accompanying drawings, provides a detailed description of a model sensitivity determination method provided by an embodiment of the present invention.
[0074] In this embodiment of the invention, determining the model sensitivity of the target model essentially involves determining the sensitivity of each target network layer in the target model whose sensitivity is to be determined. Based on this, the model sensitivity determination method provided in this embodiment of the invention can be described based on each target network layer.
[0075] Optionally, each target network layer in the target model can be a convolutional layer and / or a fully connected layer in the target model.
[0076] Figure 1This is a flowchart illustrating a model sensitivity determination method provided in an embodiment of the present invention; wherein, as... Figure 1 As shown, the following steps can be performed for each target network layer:
[0077] S101: For each specified parameter in the target network layer, determine the output result of the target network layer after removing the parameter, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter;
[0078] For each network layer of the model, the parameters of the network layer can be divided from different perspectives according to different granularities, thereby obtaining various parameters that match the granularity.
[0079] Optionally, the target model mentioned above can be a convolutional network model.
[0080] Optionally, the target network layer mentioned above can be a convolutional layer and / or a fully connected layer.
[0081] Optionally, the specified parameters may include model parameters such as weights, convolution kernels, channels, and convolutional layers.
[0082] Based on this, for each target network layer, the parameters of the target network layer can also be divided according to a preset specified granularity, thereby obtaining each specified parameter that matches the specified granularity.
[0083] For the target model, the output of each network layer except the last network layer is the input data of the next network layer. Therefore, the output of the next network layer can be determined based on the output of the current network layer.
[0084] In this way, for each network layer in the target model except the last one, the output of that network layer can be used to determine the output of each network layer that follows it. The network layers that follow the current network layer can be called its successor layers.
[0085] In other words, for each target network layer in the target model, the output of the target network layer can be used to determine the output of the subsequent network layers. Furthermore, since the output of the subsequent network layers is needed to determine the sensitivity of each target network layer, none of the target network layers in the target model are the last network layer of the target model.
[0086] For each target network layer, when the target network layer receives input data, the target network layer can output a direct output result about the input data, and the direct output result is determined based on all the specified parameters in the target network layer.
[0087] Accordingly, for each target network layer, if the target network layer still obtains the above input data when a specified parameter is removed, the target network layer can output an indirect output result about the input data. The indirect output result is determined based on the remaining specified parameters in the target network layer.
[0088] For example, if the target network layer is a convolutional layer with N (N>1) kernels, and the specified parameter is the convolutional kernel, then when image data is input to the target network layer, N feature maps about the image data learned by the target network layer can be obtained, and the direct output result of the target network layer determined by the above N feature maps can be obtained. This direct output result is the input data of the next network layer of the target network layer.
[0089] Correspondingly, when one convolutional kernel in the target network layer is removed, and image data is input into the target network layer after removing the convolutional kernel, N-1 feature maps about the image data learned by the target network layer after removing the convolutional kernel can be obtained, and the indirect output result determined by the above N-1 feature maps can be obtained from the target network layer after removing the convolutional kernel. The indirect output result can still be used as the input data of the next network layer of the target network layer.
[0090] Based on this, for each specified parameter in each target network layer, the output result of the target network layer after removing the parameter can be determined, and based on the determined output result, the output result of the subsequent network layer of the target network layer can be determined as the output result corresponding to the specified parameter.
[0091] Optionally, the subsequent network layer for each target network layer can be the next network layer after that target network layer.
[0092] S102: Determine the expected output of the subsequent network layer, and based on the expected output and the output corresponding to each specified parameter, determine the reconstruction error corresponding to that specified parameter;
[0093] For each model, for each network layer in the model, based on the task performed by the model and the expected task performance, each network layer can have the result that the user expects the network layer to output. When the output of the network layer is the result that the user expects, the model can achieve the task performance that meets the user's expectations.
[0094] For example, when the model performs an object detection task, the expected output result for the box region in the output result is 1, and the expected output result for the region outside the box region is 0; when the model performs a segmentation task, the expected output result for the mask region containing the object in the output result is 1, and the expected output result for the other regions is 0.
[0095] Based on this, for each target network layer, the expected output of the subsequent network layer can be determined.
[0096] Optionally, in one specific implementation, determining the expected output result of the post-network layer in step S102 above may include the following step 11:
[0097] Step 11: Based on the first output result of the target network layer, determine the second output result of the subsequent network layer, and based on the second output result, determine the expected output result of the subsequent network layer.
[0098] In this specific implementation, for each target network layer, the first output result of that target network layer can be obtained first. This first output result then serves as the input data for the next network layer of that target network layer. Therefore, the output result of the next network layer of that target network layer can be determined using this first output result. Furthermore, the output result of the next network layer of that target network layer serves as the input data for the next network layer of that next network layer, and is used to determine the output result of the next network layer of that next network layer.
[0099] By analogy, the second output of the subsequent network layer can be determined based on the first output of the target network layer. Furthermore, the desired output of the subsequent network layer can be determined using this second output.
[0100] Optionally, for each target network layer, the second output result of the subsequent network layer of the target network layer can be directly determined as the expected output result of the subsequent network layer of the target network layer.
[0101] Optionally, for each target network layer, a preset algorithm can be used to correct the second output result of the subsequent network layer of the target network layer, so as to obtain the corrected output result of the subsequent network layer of the target network layer, and the corrected output result is determined as the expected output result of the subsequent network layer of the target network layer.
[0102] The aforementioned preset algorithms can be sigmoid, softmax, tanh, or other algorithms that can be used to balance the reconstruction error of each feature point in the output of the model's network layers. In other words, when the difference between the actual value and the expected value of a feature point is large, the aforementioned preset algorithms can be used to increase the reconstruction error of the feature point; when the difference between the actual value and the expected value of a feature point is small, the aforementioned preset algorithms can be used to reduce the reconstruction error of the feature point.
[0103] For example, such as Figure 2 The diagram shows the variation of the feature point reconstruction error when the preset algorithm is the sigmoid algorithm. Near the origin of the coordinate axis, the difference between the actual and expected values of the feature points is amplified, while on both sides of the horizontal axis, the difference is reduced.
[0104] Optionally, in one specific implementation, determining the desired output result of the post-network layer in step S102 above may include the following step 12:
[0105] Step 12: Based on the functionality of the target model, construct the expected output of the subsequent network layer.
[0106] In this specific implementation, for each target network layer, when determining the expected output of the subsequent network layer of the target network layer, the expected output of the subsequent network layer of the target network layer can be constructed based on the function of the target model.
[0107] For each model, for each network layer in the model, based on the task performed by the model and the expected performance of the task, each network layer may have the output result that the user expects from that network layer.
[0108] For example, when the model performs an object detection task, the expected output result for the box region in the output result is 1, and the expected output result for the region outside the box region is 0; when the model performs a segmentation task, the expected output result for the mask region containing the object in the output result is 1, and the expected output result for the other regions is 0.
[0109] Based on this, for each target network layer, the task performed by the target model can be determined based on the function of the target model. Then, according to the expected task performance, the expected output result of the subsequent network layer of the target network layer can be constructed.
[0110] Furthermore, since the so-called reconstruction error is the difference between the expected output of the model and the actual output, for each target network layer, the difference between the output corresponding to each specified parameter determined above and the expected output of the subsequent network layer of the target network layer is the reconstruction error of the subsequent network layer of the target network layer when the target network layer is pruned.
[0111] In this way, based on the expected output and the output for each specified parameter, the reconstruction error can be determined. Furthermore, the magnitude of the reconstruction error for each specified parameter depends on the impact of removing that specified parameter on the output of the target network layer.
[0112] Specifically, when the specified parameter has a significant impact on the output of the target network layer, the reconstruction error corresponding to the specified parameter is larger; when the specified parameter has a minor impact on the output of the target network layer, the reconstruction error corresponding to the specified parameter is smaller.
[0113] Optionally, in one specific implementation, step S102 above, determining the reconstruction error corresponding to the specified parameter based on the expected output result and the output result corresponding to each specified parameter, may include the following step 21:
[0114] Step 21: Calculate the difference between the expected output and the output corresponding to each specified parameter, and use it as the reconstruction error corresponding to that specified parameter.
[0115] In this specific implementation, for each target network layer, after determining the reconstruction error corresponding to each specified parameter in the target network layer and the expected output result of the subsequent network layer of the target network layer, the difference between the expected output result and the output result corresponding to each specified parameter can be calculated. Thus, the obtained difference is the reconstruction error corresponding to the specified parameter.
[0116] Optionally, in one specific implementation, step S102 above, determining the reconstruction error corresponding to the specified parameter based on the expected output result and the output result corresponding to each specified parameter, may include the following step 22:
[0117] Step 22: Calculate the similarity between the expected output and the output corresponding to each specified parameter, and use it as the reconstruction error corresponding to that specified parameter.
[0118] In this specific implementation, for each target network layer, after determining the reconstruction error corresponding to each specified parameter in the target network layer and the expected output result of the subsequent network layer of the target network layer, the similarity between the expected output result and the output result corresponding to each specified parameter can be calculated. Thus, the obtained similarity is the reconstruction error corresponding to the specified parameter.
[0119] S103: Based on the reconstruction error corresponding to each specified parameter, determine the sensitivity index corresponding to that specified parameter;
[0120] For each target network layer, after determining the reconstruction error corresponding to each specified parameter in the target network layer, the sensitivity index corresponding to the specified parameter can be determined based on the reconstruction error corresponding to each specified parameter.
[0121] For different target models, when users have different desired task performance, different reconstruction errors can be set for each specified parameter of the same target network layer. Therefore, the reconstruction error corresponding to each specified parameter can be adjusted through weighted calculation.
[0122] Based on this, one possible specific implementation method is as follows: Figure 3 As shown, in the model sensitivity determination method provided by this embodiment of the invention, for each target network layer, the following step S105 can also be performed:
[0123] S105: Based on the function of the target model, the reconstruction error corresponding to each specified parameter is weighted and corrected to obtain the correction error corresponding to each specified parameter.
[0124] Accordingly, in this specific implementation, step S103 above may include the following step S1031:
[0125] S1031: Based on the correction error corresponding to each specified parameter, determine the sensitivity index corresponding to that specified parameter.
[0126] In this specific implementation, after the reconstruction error corresponding to each specified parameter, the task performed by the target model can be determined based on the function of the target model. Then, according to the expected task execution effect, the reconstruction error corresponding to each specified parameter is weighted to obtain the correction error corresponding to each specified parameter. Based on the correction error corresponding to each specified parameter, the sensitivity index corresponding to the specified parameter is determined.
[0127] For example, when the target model performs an object detection task, if more attention is paid to the detection rate and a higher detection rate is desired, the reconstruction error of the box region in the output result can be increased by weighting. If more attention is paid to false alarms in the background and a higher accuracy is desired, the reconstruction error of the non-box region in the output result can be increased by weighting.
[0128] The aforementioned sensitivity indicators can be L1 norm, L2 norm, MSE (mean squared error), etc., and the embodiments of the present invention do not specifically limit them.
[0129] S104: Determine the sensitivity of the target network layer based on the sensitivity index corresponding to each specified parameter.
[0130] For each target network layer, after determining the sensitivity index corresponding to each specified parameter, the sensitivity of the target network layer can be determined based on the sensitivity index corresponding to each specified parameter.
[0131] In this embodiment of the invention, the specific implementation of step S104 is not limited. For example, the average value of the sensitivity index corresponding to each specified parameter is calculated, and this average value is used as the sensitivity of the target network layer.
[0132] Optionally, in one specific implementation, step S104 above may include the following step 31:
[0133] Step 31: Calculate the ratio of the number of specified parameters whose corresponding sensitivity index is less than the preset threshold to the total number of specified parameters, and use this ratio as the sensitivity of the target network layer.
[0134] In this specific implementation, for each target network layer, after determining the sensitivity index corresponding to each specified parameter, the number of specified parameters whose corresponding sensitivity index is less than a preset threshold can be determined, and the ratio of the above number to all specified parameters can be further calculated. This ratio is the sensitivity of the target network layer.
[0135] Optionally, for each target network layer in the target model, after determining the sensitivity index corresponding to each specified parameter in each target network layer, the sensitivity indexes can be sorted in ascending order to determine each target sensitivity index that is less than the preset threshold.
[0136] Furthermore, the target network layer to which the specified parameters corresponding to each of the above target sensitivity indices belong is determined, and based on the determination result, the number of specified parameters corresponding to the above target sensitivity indices included in each target network layer is further obtained. Thus, for each target network layer, the ratio of the above number to all specified parameters included in the target network layer can be calculated to obtain the sensitivity of the target network layer.
[0137] Alternatively, for each target network layer in the target model, after performing the above steps S101-S104 for one target network layer, the above steps S101-S104 can be performed for another target network layer.
[0138] Optionally, for each target network layer in the target model, the above steps S101-S104 can be performed simultaneously for each target network layer.
[0139] As can be seen from the above, when applying the solution provided by the embodiments of the present invention, the sensitivity of the target model is determined based on the expected output results of the post-layer of each target network layer. That is, it is only necessary to infer the post-layer of each network layer, and it is not possible to infer the entire model. Therefore, the time consumption of the model sensitivity determination process can be reduced and the efficiency of model sensitivity determination can be improved.
[0140] Furthermore, since the entire model does not need to be inferred, the determination of model sensitivity reduces the use of hardware resources such as CPU (Central Processing Unit) and GPU (Graphics Processing Unit), thus saving hardware resources. Moreover, because the determination of model sensitivity is less time-consuming, it also makes it easier to determine model sensitivity in batches.
[0141] Corresponding to the model sensitivity determination method provided in the embodiments of the present invention, the embodiments of the present invention also provide a model sensitivity determination device.
[0142] Figure 4 This is a schematic diagram of a model sensitivity determination device provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the device includes:
[0143] The result determination module 410 is used to determine the output result of the target network layer after removing the specified parameter for each specified parameter in each target network layer in the target model whose sensitivity is to be determined, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter.
[0144] The error determination module 420 is used to determine the expected output result of the subsequent network layer of each target network layer, and to determine the reconstruction error corresponding to the specified parameter based on the expected output result and the output result corresponding to each specified parameter in the target network layer.
[0145] The index determination module 430 is used to determine the sensitivity index corresponding to each specified parameter for each target network layer based on the reconstruction error corresponding to each specified parameter in the target network layer.
[0146] The sensitivity determination module 440 is used to determine the sensitivity of each target network layer by specifying the sensitivity index corresponding to the parameters.
[0147] As can be seen from the above, when applying the solution provided by the embodiments of the present invention, the sensitivity of the target model is determined based on the expected output results of the post-layer of each target network layer. That is, it is only necessary to infer the post-layer of each network layer, and it is not possible to infer the entire model. Therefore, the time consumption of the model sensitivity determination process can be reduced and the efficiency of model sensitivity determination can be improved.
[0148] Furthermore, since the entire model does not need to be inferred, the determination of model sensitivity reduces the use of hardware resources such as CPU (Central Processing Unit) and GPU (Graphics Processing Unit), thus saving hardware resources. Moreover, because the determination of model sensitivity is less time-consuming, it also makes it easier to determine model sensitivity in batches.
[0149] Optionally, in one specific implementation, the error determination module 420 includes:
[0150] The first determining submodule is used to determine the second output result of the subsequent network layer based on the first output result of the target network layer, and to determine the expected output result of the subsequent network layer based on the second output result;
[0151] or,
[0152] The second determining submodule is used to construct the expected output result of the post-network layer based on the function of the target model.
[0153] Optionally, in one specific implementation, the first determining submodule is specifically used for:
[0154] The second output result is determined as the expected output result of the subsequent network layer;
[0155] or,
[0156] The second output result is corrected using a preset algorithm to obtain the corrected output result of the post-network layer, and the corrected output result is determined as the expected output result of the post-network layer.
[0157] Optionally, in one specific implementation, the error determination module 420 is specifically used for:
[0158] The difference between the expected output and the output corresponding to each specified parameter is calculated as the reconstruction error corresponding to that specified parameter.
[0159] or,
[0160] Calculate the similarity between the expected output and the output corresponding to each specified parameter, and use it as the reconstruction error corresponding to that specified parameter.
[0161] Optionally, in one specific implementation, the apparatus further includes:
[0162] The error correction module is used to perform weighted correction on the reconstruction error corresponding to each specified parameter based on the function of the target model before determining the sensitivity index corresponding to each specified parameter based on the reconstruction error corresponding to each specified parameter, so as to obtain the correction error corresponding to each specified parameter.
[0163] The sensitivity determination module 440 is specifically used to: determine the sensitivity index corresponding to the specified parameter based on the correction error corresponding to each specified parameter.
[0164] Optionally, in one specific implementation, the sensitivity determination module 440 is specifically used for:
[0165] For each target network layer, the ratio of the number of specified parameters whose sensitivity index is less than a preset threshold in that target network layer to all specified parameters in that target network layer is calculated, and this ratio is used as the sensitivity of that target network layer.
[0166] Optionally, in one specific implementation, the subsequent network layer of each target network layer is the next network layer after the target network layer.
[0167] Corresponding to the model sensitivity determination method provided in the embodiments of the present invention, the embodiments of the present invention also provide an electronic device, such as... Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0168] Memory 503 is used to store computer programs;
[0169] When the processor 501 executes the program stored in the memory 503, it implements the steps of any of the model sensitivity determination methods provided in the above embodiments of the present invention.
[0170] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0171] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0172] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0173] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0174] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the model sensitivity determination methods provided in the embodiments of the present invention.
[0175] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the steps of any of the model sensitivity determination methods provided in the embodiments of the present invention.
[0176] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0177] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0178] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device embodiments, electronic device embodiments, computer-readable storage medium embodiments, and computer program product embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0179] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for determining model sensitivity, characterized in that, Applied to image recognition, voice interaction, or intelligent security scenarios, the method includes: For each target network layer in the target model whose sensitivity needs to be determined, perform the following steps: For each specified parameter in the target network layer, determine the output result of the target network layer after removing the specified parameter, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter; Determine the expected output result of the post-network layer, and based on the expected output result and the output result corresponding to each specified parameter, determine the reconstruction error corresponding to the specified parameter, wherein the expected output result is the output result of the post-network layer that enables the target model to achieve the expected task execution effect; Based on the function of the target model, the reconstruction error corresponding to each specified parameter is weighted and corrected to obtain the correction error corresponding to each specified parameter. Based on the correction error corresponding to each specified parameter, determine the sensitivity index corresponding to that specified parameter; The sensitivity of the target network layer is determined based on the sensitivity index corresponding to each specified parameter. Determining the expected output of the post-network layer includes: Based on the first output result of the target network layer, the second output result of the subsequent network layer is determined, and the second output result is corrected using a preset algorithm to obtain the corrected output result of the subsequent network layer. The corrected output result is then determined as the expected output result of the subsequent network layer. The preset algorithm is an algorithm capable of balancing the reconstruction errors of each feature point in the output result of the model network layer. Specifically, the preset algorithm is used to increase or decrease the reconstruction error of a feature point based on the difference between its actual value and its expected value. or, Based on the function of the target model, determine the task performed by the target model, and construct the expected output result of the post-network layer of the target network layer according to the expected task execution effect; Wherein, when the task performed by the target model is an object detection task, the step of weighted correction of the reconstruction error corresponding to each specified parameter based on the function of the target model includes: If the function of the target model is to improve the target detection rate, then the weight coefficient of the reconstruction error corresponding to the target bounding box region is increased; if the function of the target model is to reduce the background false alarm rate, then the weight coefficient of the reconstruction error corresponding to the non-target bounding box region is increased.
2. The method according to claim 1, characterized in that, The step of determining the reconstruction error corresponding to a specified parameter based on the expected output result and the output result corresponding to each specified parameter includes: The difference between the expected output and the output corresponding to each specified parameter is calculated as the reconstruction error corresponding to that specified parameter. or, Calculate the similarity between the expected output and the output corresponding to each specified parameter, and use it as the reconstruction error corresponding to that specified parameter.
3. The method according to claim 1, characterized in that, The process of determining the sensitivity of the target network layer based on the sensitivity index corresponding to each specified parameter includes: The ratio of the number of specified parameters whose corresponding sensitivity index is less than a preset threshold to the total number of specified parameters is used as the sensitivity of the target network layer.
4. The method according to any one of claims 1-3, characterized in that, The next network layer following each target network layer is the next network layer after that target network layer.
5. A model sensitivity determination device, characterized in that, The device, applicable to image recognition, voice interaction, or intelligent security scenarios, includes: The result determination module is used to determine the output result of the target network layer after removing the specified parameter for each specified parameter in each target network layer in the target model whose sensitivity is to be determined, and based on the determined output result, determine the output result of the subsequent network layer of the target network layer as the output result corresponding to the specified parameter; The error determination module is used to determine the expected output result of the subsequent network layer for each target network layer, and to determine the reconstruction error corresponding to the specified parameter based on the expected output result and the output result corresponding to each specified parameter in the target network layer. The expected output result is the output result of the subsequent network layer that enables the target model to achieve the expected task execution effect. The error correction module is used to perform weighted correction on the reconstruction error corresponding to each specified parameter based on the function of the target model, so as to obtain the correction error corresponding to each specified parameter. The index determination module is used to determine the sensitivity index corresponding to each specified parameter for each target network layer based on the correction error corresponding to each specified parameter in the target network layer. The sensitivity determination module is used to determine the sensitivity of each target network layer by specifying the sensitivity index corresponding to the parameters. The error determination module includes: The first determining submodule is used to determine the second output result of the subsequent network layer based on the first output result of the target network layer, and to correct the second output result using a preset algorithm to obtain the corrected output result of the subsequent network layer, and to determine the corrected output result as the expected output result of the subsequent network layer; wherein, the preset algorithm is an algorithm that can balance the reconstruction error of each feature point of the model network layer output result, and the preset algorithm is specifically used to increase or decrease the reconstruction error of the feature point according to the difference between the actual value and the expected value of the feature point; or, The second determining submodule is used to determine the task performed by the target model based on the function of the target model, and construct the expected output result of the post-network layer of the target network layer according to the expected task execution effect; Wherein, when the task performed by the target model is a target detection task, the error correction module is specifically used for: If the function of the target model is to improve the target detection rate, then the weight coefficient of the reconstruction error corresponding to the target bounding box region is increased; if the function of the target model is to reduce the background false alarm rate, then the weight coefficient of the reconstruction error corresponding to the non-target bounding box region is increased.
6. The apparatus according to claim 5, characterized in that, The error determination module is specifically used to: calculate the difference between the expected output result and the output result corresponding to each specified parameter, as the reconstruction error corresponding to the specified parameter; or, calculate the similarity between the expected output result and the output result corresponding to each specified parameter, as the reconstruction error corresponding to the specified parameter. And / or, The sensitivity determination module is specifically used to: for each target network layer, calculate the ratio of the number of specified parameters whose corresponding sensitivity index is less than a preset threshold in the target network layer to all specified parameters in the target network layer, and use this ratio as the sensitivity of the target network layer. And / or, The next network layer following each target network layer is the next network layer after that target network layer.
7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-4.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-4.
Citation Information
Patent Citations
Deep neural network pruning method and system based on random sensitivity ST-SM
CN112884149A