Pruning method of end-side deep learning model
By adopting an adaptive hardware-aware pruning method, multi-level test pruning rates are set based on device parameters and model parameters, which solves the contradiction between high accuracy and low latency in ophthalmic surgery under limited hardware resources, and realizes efficient and stable operation of the model in ophthalmic surgical equipment.
Patent Information
- Application Number
- CN202511495284.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2025-12-16
AI Technical Summary
Existing edge-side deep learning models struggle to achieve both high accuracy and low latency in ophthalmic surgery under limited hardware resources. Traditional pruning methods lack theoretical basis, resulting in a tradeoff between model accuracy and efficiency. Furthermore, the optimization process is cumbersome and difficult to adapt to the dynamic requirements of different surgical scenarios.
By using an adaptive hardware-aware pruning method, multi-level test pruning rates are set based on device and model parameters, and a comprehensive score is calculated to obtain the optimal pruning rate. After pruning, the model is directly deployed on the device to adapt to the real-time and accuracy requirements of different surgical scenarios.
This method enables efficient and stable model pruning in ophthalmic surgical equipment, balancing model accuracy and efficiency. It solves the problem that traditional methods cannot simultaneously achieve high accuracy and low latency, thus shortening the development cycle.
Smart Images

Figure CN121145966A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of neural network technology, and in particular to a pruning method for edge-side deep learning models. Background Technology
[0002] Ophthalmic microsurgery is one of the most precise types of microsurgery, heavily reliant on the surgeon's experience and expertise. However, the number of highly experienced ophthalmologists is limited, and intraoperative judgment and manipulation often depend on subjective experience, making it difficult to meet the growing demand for precision medicine. Against this backdrop, intelligent assistance systems based on deep learning models (such as iris segmentation and surgical navigation) have been introduced into ophthalmic surgery. These systems provide surgeons with high-precision, real-time visual analysis and operational guidance, significantly improving surgical safety and accuracy.
[0003] These intraoperative intelligent assistance models typically require training a high-precision network on massive computing resources before being deployed on surgical equipment terminals to support real-time inference during surgery. Ophthalmic surgery is a highly interactive real-time scenario, and the inference latency of intraoperative deep learning models not only affects fluency but also directly relates to surgical safety and operational accuracy. However, the hardware in ophthalmic surgical instruments has strict limitations in computing power, memory, and power consumption, making it difficult for original models to simultaneously achieve high accuracy and low latency under such limited resource conditions. To ensure practical usability, model compression is often necessary, with pruning being a widely used method.
[0004] Traditional pruning methods typically rely on manually setting the pruning rate, roughly estimating the sparsity ratio of each layer based on experience, in order to maintain model performance as much as possible under computational constraints. However, this approach has several significant problems: First, manually set pruning rates often lack theoretical basis and system optimization. Under strictly limited equipment conditions, existing pruning strategies struggle to simultaneously achieve high accuracy and low latency performance goals, often sacrificing model accuracy for increased inference speed, or causing excessive compression that prevents the model from meeting the reliability requirements of real-time intraoperative assistance. Second, fixed and experience-based pruning rates cannot flexibly adapt to the dynamic requirements of real-time performance and accuracy in different surgical scenarios. Furthermore, traditional methods usually require repeated verification and manual tuning, a cumbersome process lacking theoretical guidance. This leads to long development cycles, low efficiency, and severely restricts their practical application in real-world medical environments.
[0005] Therefore, there is an urgent need for a model compression scheme that can automatically adapt to hardware computing power and achieve an effective trade-off between accuracy and efficiency.
[0006] It should be noted that the above description of the background technology is only for the purpose of providing a clear and complete explanation of the technical solutions of the present invention and facilitating understanding by those skilled in the art. It should not be assumed that the above technical solutions are known to those skilled in the art simply because they have been described in the background section of the present invention. Summary of the Invention
[0007] The purpose of this invention is to disclose a pruning method for edge-side deep learning models that can adaptively prune deep learning models based on hardware awareness, balancing model accuracy and efficiency, so as to support efficient and stable operation in a variety of ophthalmic surgical devices.
[0008] To achieve the above objectives, this invention provides a pruning method for edge-side deep learning models, comprising:
[0009] Obtain the device parameters corresponding to the device, and determine the initial learning model and the corresponding model parameters based on the device parameters;
[0010] A first test pruning rate is set according to the device parameters and the model parameters. The model accuracy after pruning the initial learning model based on the first test pruning rate is calculated. The largest first test pruning rate among all first test pruning rates whose model accuracy meets the first accuracy threshold is taken as the first target test pruning rate.
[0011] A second test pruning rate is set according to the first target test pruning rate. The model accuracy after pruning the initial learning model based on the second test pruning rate is calculated. All second test pruning rates that meet the second accuracy threshold are taken as the second target test pruning rates.
[0012] Calculate the comprehensive score corresponding to each second target test pruning rate, take the second target test pruning rate with the highest comprehensive score as the target pruning rate, and prune the initial learning model based on the target pruning rate to obtain the target learning model.
[0013] As a further improvement of the present invention, the device parameters include the available computing power of the device, and the model parameters include the structural layer, the channels contained in the structural layer, and the input-output relationship between the channels.
[0014] As a further improvement of the present invention, after determining the model parameters, the pruning method further includes: calculating the parameter sensitivity corresponding to the channels contained in each structural layer based on the type of each structural layer;
[0015] Wherein, if the structure layer is a convolutional layer, the learnable scaling parameter in the batch normalized layer connected after the convolutional layer is used as the parameter sensitivity; if the structure layer is a Transformer layer, the L1 norm of each channel is calculated and the L1 norm is normalized to obtain the parameter sensitivity.
[0016] As a further improvement to the present invention, calculating the accuracy of the model includes:
[0017] The initial learning model is pruned based on the parameter sensitivity of the channels contained in the structural layer to obtain the pruned initial learning model.
[0018] The pruned initial learning model is trained using business data, and the model accuracy of the trained initial learning model is calculated.
[0019] As a further improvement of the present invention, the pruning method further includes:
[0020] If the model accuracy corresponding to all first test pruning rates does not meet the first accuracy threshold, then determine whether the number of training iterations has reached the first preset number of iterations; if yes, then change the device or lower the first accuracy threshold; if no, then reset the first test pruning rate.
[0021] If the model accuracy corresponding to all second test pruning rates does not meet the second accuracy threshold, then determine whether the number of training iterations has reached the second preset number of iterations; if yes, then change the device or lower the second accuracy threshold; if no, then reset the second test pruning rate.
[0022] Wherein, the first precision threshold is less than the second precision threshold.
[0023] As a further improvement of the present invention, the model accuracy is determined by inputting a labeled test set into the trained initial learning model, comparing the output result with the label, and obtaining the comparison result.
[0024] As a further improvement of the present invention, the step of pruning the initial learning model based on the target pruning rate to obtain the target learning model includes:
[0025] All channels in all structural layers are sorted according to their parameter sensitivity. The last channel in the sorted list is removed according to the target pruning rate. The input-output relationship between channels is adjusted according to the initial input-output relationship.
[0026] or,
[0027] The channels in a single structural layer are sorted according to their parameter sensitivity. The last channel in the sorted channel is removed according to the target pruning rate. The input-output relationship between the channels is then adjusted according to the initial input-output relationship.
[0028] As a further improvement of the present invention, the step of setting the first test pruning rate according to the device parameters and the model parameters includes:
[0029] The maximum first test pruning rate is set according to the equipment parameters and the model parameters, and then decreased sequentially according to the first preset step size to obtain several first test pruning rates.
[0030] As a further improvement of the present invention, the step of setting the second test pruning rate based on the first target test pruning rate includes:
[0031] The first target test pruning rate is used as the upper bound, and then extended downwards to form a safe range;
[0032] Within the safe zone, several second test pruning rates are set according to a second preset step size.
[0033] As a further improvement of the present invention, the formula for calculating the comprehensive score is as follows:
[0034]
[0035] Where S refers to the overall score, and A... P This refers to the accuracy of the model after pruning, A N This refers to the model accuracy before pruning, T P This refers to the deployment time of the model after pruning, T N This refers to the model deployment time before pruning, α refers to the accuracy weighting coefficient, and β refers to the deployment time weighting coefficient.
[0036] Compared with the prior art, the beneficial effects of the present invention are:
[0037] In the present invention, an initial learning model and corresponding model parameters are determined based on device parameters of a device end. A first test pruning rate is set according to the device parameters and the model parameters, and a second test pruning rate is set according to a first target test pruning rate. Finally, the initial learning model is pruned with the second target test pruning rate having the highest comprehensive score to obtain a target learning model. Based on this, setting the first test pruning rate according to adaptive hardware perception and the initial learning model can adapt to the dynamic requirements of real-time performance and accuracy in different surgical scenarios. At the same time, under the condition of meeting the accuracy requirement, by setting the test pruning rate multiple times with gradually refined granularity, the finally obtained target pruning rate is closer to the most accurate pruning rate, which not only reduces the computing power consumption but also improves the efficiency. Moreover, after pruning, the target learning model is directly deployed on the device end to solve the problem of real-time contradiction in cloud collaboration. Thus, the pruning method disclosed in the present invention can take into account both model accuracy and efficiency to support efficient and stable operation in diverse ophthalmic surgical devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 FIG. is a schematic diagram of the steps of a pruning method for a deep learning model on the device end according to the present invention;
[0039] Figure 2 FIG. is a structural diagram of an initial learning model in an implementation manner;
[0040] Figure 3 FIG. is a schematic diagram before and after pruning of the initial learning model in an implementation manner;
[0041] Figure 4 FIG. is an overall flowchart of the pruning method. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0042] The present invention will be described in detail below with reference to the embodiments shown in the drawings. However, it should be noted that these embodiments are not limitations on the present invention, and any equivalent transformation or substitution in terms of function, method, or structure made by those of ordinary skill in the art based on these embodiments shall fall within the protection scope of the present invention.
[0043] Please refer to Figures 1 to 4 As shown, the present invention discloses a specific implementation manner of a pruning method for a deep learning model on the device end (hereinafter referred to as "pruning method"). This pruning method is used to prune an initial learning model to obtain a target learning model according to device parameters corresponding to the device end and model parameters corresponding to the initial learning model. It can adaptively prune the deep learning model based on hardware perception, taking into account both model accuracy and efficiency, and solving the problems that traditional pruning methods cannot simultaneously meet the performance goals of high accuracy and low latency, are not flexible, and require repeated verification and manual tuning, which is a cumbersome process.
[0044] Refer to Figure 1As shown, the pruning method includes the following steps S1 to S4.
[0045] Step S1: Obtain the corresponding device parameters on the device side, and determine the initial learning model and corresponding model parameters based on the device parameters.
[0046] For example, "device-side" refers to ophthalmic surgical instruments that require the deployment of an initial learning model or a target learning model to assist ophthalmologists in performing surgery. The device parameters corresponding to the device-side include its available computing power, which can be determined by testing the device-side with predefined computing tasks to achieve the desired computing power metrics. Computing power metrics include one or any combination of CPU / GPU peak computing power, memory bandwidth, and inference latency.
[0047] It should be noted that different deployment devices have different hardware bottlenecks when performing computing tasks. The device parameters are designed to determine the maximum available computing power of the device, which is then used to select an initial learning model and to initially evaluate whether the initial and target learning models can be deployed on the device. If the computing power consumed by the initial learning model is much greater than the maximum available computing power of the device, the device should be replaced or a lower-powered initial learning model should be selected.
[0048] For example, model parameters include structural layers, the channels contained in the structural layers, and the initial input-output relationships between the channels. An initial learning model is selected based on the device parameters corresponding to the device, and the initial learning model is parsed to obtain its corresponding model parameters. The initial learning model typically contains multiple different structural layers. For example, parameters... Figure 2 As shown, Figure 2 The diagram illustrates a specific example of an initial learning model. This initial learning model contains three structural layers: structural layers 1 through 3. Structural layer 1 contains channels 11 through 1n, structural layer 2 contains channels 21 through 2m, and structural layer 3 contains channels 31 through 3k. Taking channel 21 in structural layer 2 as an example, the input to channel 21 is channels 11, 13, and 15 in structural layer 1, and the output of channel 21 is channel 31 in structural layer 3. In subsequent pruning, if channel 21 in structural layer 2 is removed, then channels 11, 13, and 15 in structural layer 1 must all be directly assigned to channel 31 in structural layer 3. Here, m, n, and k are all positive integers.
[0049] In one implementation, after determining the model parameters, the pruning method further includes calculating the parameter sensitivity of each channel contained in the structural layer based on the type of each structural layer. Parameter sensitivity is an indicator for analyzing the importance of the channels contained in the structural layer. The structural layer types include convolutional layers and Transformer layers, which are two core neural network structures. The design idea of convolutional layers is to extract spatial or local features through local receptive fields and weight sharing. A batch normalization layer (BN layer) is usually followed by a convolutional layer to accelerate training and improve model stability by standardizing the distribution of intermediate outputs. The design idea of Transformer layers is to capture global dependencies between any positions in the input sequence through a self-attention mechanism, making them suitable for tasks involving long-range associations.
[0050] If the structure layer is a convolutional layer, then the learnable scaling parameter in the batch normalization layer connected after the convolutional layer is used as the parameter sensitivity.
[0051] If the structure layer is a Transformer layer, the L1 norm of each channel is calculated, and the L1 norm is normalized to obtain the parameter sensitivity. Specifically, the L1 norm of each channel is calculated using business data, and the L1 norm is normalized. The normalized value is used as the parameter sensitivity of the channel. The initial model structure is presented in the form of a weight matrix. Taking the weight matrix W as an example, for the i-th channel of the weight matrix W, its parameter sensitivity S... i The L1 norm of the channel weight vector is calculated using the formula Sum-W. i =||W i ||1=∑ j w ij , Among them, W i It refers to the i-th channel of the weight matrix W, ||W i ||1 refers to the L1 norm of the i-th channel, ∑ j w ij This refers to summing the absolute values of all elements in the i-th channel.
[0052] Step S2: Set the first test pruning rate according to the equipment parameters and model parameters, calculate the model accuracy after pruning the initial learning model based on the first test pruning rate, and take the largest first test pruning rate among all first test pruning rates whose model accuracy meets the first test pruning rate as the first target test pruning rate.
[0053] Specifically, a first test pruning rate (e.g., 0.9, 0.8, 0.7, 0.6, 0.5, etc.) is set according to the equipment parameters and model parameters, and a first accuracy threshold (e.g., 90%) is preset. Based on the first test pruning rate, the initial learning model is pruned sequentially, the model accuracy of the pruned initial learning model is calculated, and the first test pruning rates that meet the first accuracy threshold are selected as candidates. The largest first test pruning rate among all candidate first test pruning rates is selected as the first target test pruning rate.
[0054] In one implementation, setting the first test pruning rate based on device parameters and model parameters includes: setting a maximum first test pruning rate based on the device parameters and model parameters, and then decreasing it sequentially according to a first preset step size to obtain several first test pruning rates. The maximum first test pruning rate is determined manually based on the computing power constraints of the device (i.e., device parameters) and the model structure of the initial learning model (i.e., model parameters). The remaining first test pruning rates are set sequentially decreasing according to the first preset step size, with the granularity gradually refined to ensure the accuracy of the first target test pruning rate.
[0055] For example, based on the equipment parameters and model parameters, the maximum first test pruning rate is set to 0.9, and the first preset step size is 0.1. By decreasing the first preset step size sequentially, several first test pruning rates are obtained, namely 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, and 0.1.
[0056] In one implementation, calculating the model accuracy after pruning the initial learning model based on the first test pruning rate includes: pruning the initial learning model according to the parameter sensitivity of the channels contained in the structural layer based on the first test pruning rate to obtain the pruned initial learning model; training the pruned initial learning model using business data, and calculating the model accuracy of the trained initial learning model.
[0057] It should be noted that if the model accuracy corresponding to all first test pruning rates does not meet the first accuracy threshold, then it is determined whether the number of training iterations (i.e., the number of times the initial learning model after pruning is trained using business data) has reached the first preset number of iterations; if yes, then the device is replaced or the first accuracy threshold is lowered; if no, then the first test pruning rate is reset.
[0058] Furthermore, pruning the initial learning model based on the parameter sensitivity of the channels contained in the structural layer according to the first test pruning rate includes: sorting the channels contained in the structural layer according to their parameter sensitivity, subtracting the last channel in the sorted list according to the first test pruning rate, and adjusting the input-output relationship between the channels according to the initial input-output relationship; or, sorting the channels contained in a single structural layer according to their parameter sensitivity, subtracting the last channel in the sorted list according to the first test pruning rate, and adjusting the input-output relationship between the channels according to the initial input-output relationship.
[0059] For example, the first test pruning rate is 0.5. The initial learning model contains three structural layers: the first layer contains 50 channels, the second layer contains 40 channels, and the third layer contains 60 channels, for a total of 150 channels. These 150 channels are sorted according to their parameter sensitivity. The bottom 75 channels are removed based on the first test pruning rate, and the input-output relationships between the channels are adjusted according to the initial input-output relationship. Alternatively, the first 50 channels in the first structural layer are sorted according to their parameter sensitivity, and the bottom 25 channels are removed based on the first test pruning rate. Next, the 40 channels in the second structural layer are sorted according to their parameter sensitivity, and the bottom 20 channels are removed based on the first test pruning rate. Then, the 60 channels in the third structural layer are sorted according to their parameter sensitivity, and the bottom 30 channels are removed based on the first test pruning rate. Finally, the input-output relationships between the channels are adjusted according to the initial input-output relationship.
[0060] It should be noted that in this invention, after pruning the initial learning model, the input-output relationship between channels is adjusted according to the initial input-output relationship, which can avoid the structural breakage caused by pruning.
[0061] In practical applications, in order to reduce unnecessary computing power and improve computing speed, the model accuracy after pruning the initial learning model based on the first test pruning rate can be calculated sequentially from large to small. Once the model accuracy meets the first accuracy threshold, the calculation is stopped. This achieves the goal of reducing unnecessary computing power and improving computing speed, and can shorten the model compression and verification cycle in ophthalmic surgery (such as tissue segmentation and image matching AI tasks).
[0062] Step S3: Set the second test pruning rate according to the first target test pruning rate, calculate the model accuracy after pruning the initial learning model based on the second test pruning rate, and take all second test pruning rates that meet the second accuracy threshold as the second target test pruning rates.
[0063] Specifically, a safe interval is determined based on the first target test pruning rate. Within the safe interval, several second test pruning rates are set, and a second accuracy threshold (e.g., 95%) is preset. The initial learning model is pruned sequentially based on the second test pruning rates. The model accuracy of the pruned initial learning model is calculated, and the second test pruning rate that satisfies the second accuracy threshold is taken as the second target test pruning rate.
[0064] In one embodiment, setting a second test pruning rate based on a first target test pruning rate includes: using the first target test pruning rate as an upper bound and extending it downwards to form a safety interval; within the safety interval, setting a plurality of second test pruning rates according to a second preset step size.
[0065] For example, the first target test pruning rate is 0.5. Using 0.5 as the upper bound, the range is expanded downwards by 0.1 to form a safe interval [0.5, 0.4]. The second preset step size is 0.01. By decreasing the second preset step size sequentially, several second test pruning rates are obtained, namely 0.5, 0.49, 0.48, 0.47, 0.46, 0.45, 0.44, 0.43, 0.42, 0.41, and 0.4.
[0066] In one implementation, calculating the model accuracy after pruning the initial learning model based on the second test pruning rate includes: pruning the initial learning model according to the parameter sensitivity of the channels contained in the structure layer based on the second test pruning rate to obtain the pruned initial learning model; training the pruned initial learning model using business data, and calculating the model accuracy of the trained initial learning model.
[0067] It should be noted that if the model accuracy corresponding to all second test pruning rates does not meet the second accuracy threshold, then it is determined whether the number of training iterations (i.e., the number of times the initial learning model after pruning is trained using business data) has reached the second preset number of iterations; if yes, then the device is replaced or the second accuracy threshold is lowered; if no, then the second test pruning rate is reset.
[0068] Furthermore, the initial learning model is pruned based on the parameter sensitivity of the channels contained in the structural layer according to the second test pruning rate, which is similar to the aforementioned pruning of the initial learning model based on the parameter sensitivity of the channels contained in the structural layer according to the first test pruning rate. For details, please refer to the previous description, which will not be repeated here. In short, the channels contained in the structural layer are sorted according to their parameter sensitivity, and the last channel in the sorted list is removed according to the second test pruning rate. The input-output relationship between the channels is then adjusted according to the initial input-output relationship. Alternatively, the channels contained in a single structural layer are sorted according to their parameter sensitivity, and the last channel in the sorted list is removed according to the second test pruning rate. The input-output relationship between the channels is then adjusted according to the initial input-output relationship.
[0069] In practical applications, to reduce unnecessary computing power and improve computation speed, the safe interval can be divided into several sub-intervals. The initial learning model is pruned using the second test pruning rate within the highest sub-interval, and the model accuracy corresponding to the pruned initial learning model is calculated. If the model accuracy meets the second accuracy threshold, fine-tuning continues towards a higher second test pruning rate; if the model accuracy does not meet the second accuracy threshold, fine-tuning continues towards a lower second test pruning rate. This process yields multiple second test pruning rates that meet the second accuracy threshold, which are then used as the second target test pruning rate.
[0070] Step S4: Calculate the comprehensive score corresponding to each second target test pruning rate, take the second target test pruning rate with the highest comprehensive score as the target pruning rate, and prune the initial learning model based on the target pruning rate to obtain the target learning model.
[0071] Specifically, a comprehensive score is calculated based on the model accuracy before and after pruning and the model deployment time before and after pruning. The second target test pruning rate with the highest comprehensive score is taken as the target pruning rate. The initial learning model is pruned based on the target pruning rate to obtain the target learning model.
[0072] In one implementation, the formula for calculating the overall score is: Where S refers to the overall score, and A... P This refers to the accuracy of the model after pruning, A N This refers to the model accuracy before pruning, T P This refers to the deployment time of the model after pruning, T N This refers to the model deployment time before pruning, α refers to the accuracy weighting coefficient, and β refers to the deployment time weighting coefficient.
[0073] In one implementation, the initial learning model is pruned based on the target pruning rate to obtain the target learning model. This is similar to the aforementioned pruning of the initial learning model based on the parameter sensitivity of the channels contained in the structural layer according to the first test pruning rate, as described above, and will not be repeated here. In short, the channels contained in the structural layer are sorted according to their parameter sensitivity, the last channel in the sorted sequence is removed according to the target pruning rate, and the input-output relationship between the channels is adjusted according to the initial input-output relationship; or, the channels contained in a single structural layer are sorted according to their parameter sensitivity, the last channel in the sorted sequence is removed according to the target pruning rate, and the input-output relationship between the channels is adjusted according to the initial input-output relationship.
[0074] It should be noted that the aforementioned first precision threshold and second precision threshold are both determined based on the available computing power of the device and the computing power required to run the initial learning model under different precision thresholds. The first precision threshold and the second precision threshold can be the same value or different values. Preferably, the first precision threshold is less than the second precision threshold; for example, the first precision threshold is 90% and the second precision threshold is 95%.
[0075] More specifically, participants Figure 3 As shown, the weight matrix represents the initial learning model with 25 channels, and the importance matrix represents the parameter sensitivity of each channel. Assuming a target pruning rate of 0.2, the last channel in the ranking is subtracted based on the parameter sensitivity according to the target pruning rate to obtain the pruned weight matrix.
[0076] In this invention, model accuracy is determined by inputting a labeled test set into the trained initial learning model, comparing the output results with the labels, and obtaining the comparison result. If the initial learning model is a classification task model, the comparison result includes test accuracy and test recall. If the initial learning model is a semantic segmentation task model, the comparison result is the intersection over union (IoU). If the initial learning model is a registration task model, the comparison result includes mean squared error and rotation matrix error, etc.
[0077] In summary, in this invention, the reference... Figure 4 As shown, deploying the model on the device side based on the pruning method specifically includes the following steps S401 to S420.
[0078] Step S401: Obtain the device parameters corresponding to the device and determine the initial learning model based on the device parameters.
[0079] Step S402: Determine whether the deployment of the initial learning model on the device meets the preset time requirement; if yes, proceed to step S403; if no, proceed to step S404.
[0080] Step S403: Deploy the initial learning model on the device.
[0081] Step S404: Analyze the initial learning model to obtain the model parameters corresponding to the initial learning model.
[0082] Step S405: Set the first test pruning rate according to the equipment parameters and model parameters.
[0083] Step S406: Calculate the model accuracy after pruning the initial learning model based on the first test pruning rate.
[0084] Step S407: Determine whether there is a first test pruning rate that satisfies the first accuracy threshold of the model; if yes, proceed to step S408; if no, proceed to step S409.
[0085] Step S408: Take the largest of the first test pruning rates that meet the first precision threshold as the first target test pruning rate.
[0086] Step S409: Determine whether the first preset number of iterations has been reached; if yes, proceed to step S410; if no, proceed to step S405.
[0087] Step S410: Replace the device or lower the first precision threshold.
[0088] Step S411: Set the second test pruning rate based on the first target test pruning rate.
[0089] Step S412: Calculate the model accuracy after pruning the initial learning model based on the second test pruning rate.
[0090] Step S413: Determine whether there is a second test pruning rate that satisfies the second accuracy threshold of the model; if yes, proceed to step S414; if no, proceed to step S419.
[0091] Step S414: All second test pruning rates that meet the second precision threshold are taken as the second target test pruning rates.
[0092] Step S415: Calculate the comprehensive score corresponding to the pruning rate of each second target test.
[0093] Step S416: Take the second target test pruning rate with the highest comprehensive score as the target pruning rate.
[0094] Step S417: Prune the initial learning model based on the target pruning rate to obtain the target learning model.
[0095] Step S418: Deploy the target learning model on the device.
[0096] Step S419: Determine whether the second preset number of iterations has been reached; if yes, proceed to step S420; if no, proceed to step S411.
[0097] Step S420: Replace the device or lower the second precision threshold.
[0098] In this invention, an initial learning model and its corresponding model parameters are determined based on device parameters. A first test pruning rate is set according to the device parameters and model parameters, and a second test pruning rate is set according to the first target test pruning rate. Finally, the initial learning model is pruned using the second target test pruning rate with the highest comprehensive score to obtain the target learning model. Based on this, setting the first test pruning rate according to adaptive hardware awareness and the initial learning model can adapt to the dynamic requirements of real-time performance and accuracy in different surgical scenarios. Simultaneously, under the condition of meeting accuracy requirements, the granularity is gradually refined by setting the test pruning rate multiple times, making the final target pruning rate closer to the most accurate pruning rate. This not only reduces computational power consumption but also improves efficiency. Furthermore, the target learning model is directly deployed on the device after pruning, resolving the real-time contradiction problem in cloud collaboration. Therefore, the pruning method disclosed in this invention can simultaneously consider model accuracy and efficiency to support efficient and stable operation in diverse ophthalmic surgical devices.
[0099] The detailed descriptions listed above are merely specific descriptions of feasible embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. All equivalent embodiments or modifications made without departing from the spirit of the present invention should be included within the scope of protection of the present invention.
[0100] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0101] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A pruning method for an edge-side deep learning model, characterized in that, include: Obtain the device parameters corresponding to the device, and determine the initial learning model and the corresponding model parameters based on the device parameters; A first test pruning rate is set according to the device parameters and the model parameters. The model accuracy after pruning the initial learning model based on the first test pruning rate is calculated. The largest first test pruning rate among all first test pruning rates whose model accuracy meets the first accuracy threshold is taken as the first target test pruning rate. A second test pruning rate is set according to the first target test pruning rate. The model accuracy after pruning the initial learning model based on the second test pruning rate is calculated. All second test pruning rates that meet the second accuracy threshold are taken as the second target test pruning rates. Calculate the comprehensive score corresponding to each second target test pruning rate, take the second target test pruning rate with the highest comprehensive score as the target pruning rate, and prune the initial learning model based on the target pruning rate to obtain the target learning model.
2. The pruning method according to claim 1, characterized in that, The device parameters include the available computing power of the device, and the model parameters include the structural layer, the channels contained in the structural layer, and the input-output relationship between the channels.
3. The pruning method according to claim 2, characterized in that, After determining the model parameters, the pruning method further includes: calculating the parameter sensitivity of each channel contained in the structural layer based on the type of each structural layer; Wherein, if the structure layer is a convolutional layer, the learnable scaling parameter in the batch normalized layer connected after the convolutional layer is used as the parameter sensitivity; if the structure layer is a Transformer layer, the L1 norm of each channel is calculated and the L1 norm is normalized to obtain the parameter sensitivity.
4. The pruning method according to claim 2, characterized in that, Calculating the accuracy of the model includes: The initial learning model is pruned based on the parameter sensitivity of the channels contained in the structural layer to obtain the pruned initial learning model. The pruned initial learning model is trained using business data, and the model accuracy of the trained initial learning model is calculated.
5. The pruning method according to claim 4, characterized in that, The pruning method also includes: If the model accuracy corresponding to all first test pruning rates does not meet the first accuracy threshold, then determine whether the number of training iterations has reached the first preset number of iterations; if yes, then change the device or lower the first accuracy threshold; if no, then reset the first test pruning rate. If the model accuracy corresponding to all second test pruning rates does not meet the second accuracy threshold, then determine whether the number of training iterations has reached the second preset number of iterations; if yes, then change the device or lower the second accuracy threshold; if no, then reset the second test pruning rate. Wherein, the first precision threshold is less than the second precision threshold.
6. The pruning method according to claim 4, characterized in that, The model accuracy is determined by inputting a labeled test set into the trained initial learning model, comparing the output with the labels, and obtaining the comparison result.
7. The pruning method according to claim 2, characterized in that, The step of pruning the initial learning model based on the target pruning rate to obtain the target learning model includes: All channels in all structural layers are sorted according to their parameter sensitivity. The last channel in the sorted list is removed according to the target pruning rate. The input-output relationship between channels is adjusted according to the initial input-output relationship. or, The channels in a single structural layer are sorted according to their parameter sensitivity. The last channel in the sorted channel is removed according to the target pruning rate. The input-output relationship between the channels is then adjusted according to the initial input-output relationship.
8. The pruning method according to claim 1, characterized in that, The step of setting the first test pruning rate based on the device parameters and the model parameters includes: The maximum first test pruning rate is set according to the equipment parameters and the model parameters, and then decreased sequentially according to the first preset step size to obtain several first test pruning rates.
9. The pruning method according to claim 1, characterized in that, The step of setting the second test pruning rate based on the first target test pruning rate includes: The first target test pruning rate is used as the upper bound, and then extended downwards to form a safe range; Within the safe zone, several second test pruning rates are set according to a second preset step size.
10. The pruning method according to claim 1, characterized in that, The formula for calculating the comprehensive score is as follows: Where S refers to the overall score, and A... P This refers to the accuracy of the model after pruning, A N This refers to the model accuracy before pruning, T P This refers to the deployment time of the model after pruning, T N This refers to the model deployment time before pruning, α refers to the accuracy weighting coefficient, and β refers to the deployment time weighting coefficient.
Citation Information
Patent Citations
Model pruning method, device and equipment based on hardware characteristics and storage medium
CN114970856A
Federal learning model pruning method and device and nonvolatile storage medium
CN116306884A
Model lightweight deployment method and device based on hardware performance of end system
CN120745715A
Method and system for jointly pruning and hardware acceleration of pre-trained deep learning models
US20240046099A1
Method and apparatus for reducing parameter density of deep neural network (DNN)
WO2018053835A1
