Neural network optimization method, computer system, and computer-readable storage medium

The hybrid pruning of neural networks using multiple algorithms addresses inefficiencies in single-type pruning, resulting in a computationally efficient and accurate neural network model.

JP7546630B2Active Publication Date: 2024-09-06WISTRON CORP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2022139608
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2022-04-27
Filing Date
2022-09-02
Publication Date
2024-09-06
Estimated Expiration
2042-09-02

AI Technical Summary

Technical Problem

Existing neural network pruning methods are single-type, leading to inefficiencies in model simplification and computational cost reduction.

Method used

A hybrid pruning approach using multiple pruning algorithms, such as channel and weight pruning, is applied sequentially, followed by retraining the pruned neural network to maintain accuracy.

Benefits of technology

This method achieves a deep learning neural network with reduced computational cost and high accuracy by combining different pruning algorithms, optimizing the model structure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007546630000007
    Figure 0007546630000007
  • Figure 0007546630000006
    Figure 0007546630000006
  • Figure 0007546630000008
    Figure 0007546630000008
Patent Text Reader

Abstract

To provide an optimization method for simplifying a neural network model, a computer system, and a computer-readable storage medium.SOLUTION: A method provided herein comprises: pruning a neural network sequentially using two different pruning algorithms (S210); and retraining the pruned neural network in response to each pruning algorithm pruning the neural network (S220).SELECTED DRAWING: Figure 2
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present disclosure relates to neural network technology, and more particularly to an optimization method and computer system for neural networks, and a computer-readable storage medium. [Background technology]

[0002] With the rapid development of artificial intelligence (AI) technology in recent years, the number of parameters and the amount of calculations in neural network models are increasing rapidly. Accordingly, compression techniques for neural network models are also evolving. Of note is "pruning," an important technique for compressing models. However, all existing pruning methods are single-type pruning. Summary of the Invention [Problem to be solved by the invention]

[0003] Embodiments of the present disclosure provide a neural network optimization method and computer system, as well as a computer-readable storage medium, that provide a hybrid pruning solution to achieve model simplification. [Means for solving the problem]

[0004] A method for optimizing a neural network according to an embodiment of the present disclosure includes, but is not limited to, pruning the neural network sequentially using two different pruning algorithms, and re-training the pruned neural network according to each of the pruning algorithms that prune the neural network.

[0005] A computer system for a neural network according to one embodiment of the present disclosure includes, but is not limited to, a memory and a processor. The memory is configured to store code. The processor is coupled to the memory. The processor is configured to load and execute the code to sequentially prune the neural network using two different pruning algorithms and re-train the pruned neural network according to each of the pruning algorithms for pruning the neural network.

[0006] A non-transitory computer readable storage medium according to an embodiment of the present disclosure is configured to store code, the code being loaded by a processor to execute the neural network optimization method described above. Effect of the Invention

[0007] Based on the above, the neural network optimization method, computer system, and computer-readable storage medium according to the embodiments of the present disclosure use various pruning algorithms to realize a deep learning neural network with low computational cost.

[0008] In order to make the above and other features and advantages of the present disclosure easier to understand, exemplary embodiments are described in detail below with reference to the accompanying drawings. [Brief description of the drawings]

[0009] The accompanying drawings are included to provide a further understanding of the present disclosure, and are incorporated in and constitute a part of this specification. The drawings illustrate exemplary embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0010] [Figure 1] FIG. 1 is a block diagram of components of a computer system according to one embodiment of the present disclosure. [Diagram 2]1 is a flowchart of a method for optimizing a neural network according to an embodiment of the present disclosure. [Diagram 3] 1 is a flowchart of channel pruning via geometric median (CPGM) according to an embodiment of the present disclosure. [Figure 4] 1 is a flow chart of a slimming method according to an embodiment of the present disclosure. [Diagram 5] 1 is a flow chart of a combination of slimming and ThiNet methods according to an embodiment of the present disclosure. [Figure 6] 1 is a flowchart of the combination of the CPGM method and the ThiNet method according to an embodiment of the present disclosure. [Figure 7] 1 is a schematic diagram of structured and unstructured trimming according to an embodiment of the present disclosure. [Figure 8] FIG. 2 is a schematic diagram of a user interface according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0011] 1 is a block diagram of components of a computer system 100 according to an embodiment of the present disclosure. Referring to FIG. 1, computer system 100 includes, but is not limited to, a memory 110 and a processor 130. Computer system 100 may be a desktop computer, a laptop computer, a smartphone, a tablet computer, a server, medical or product testing equipment, or other computing device.

[0012] Memory 110 may be of any type, such as fixed or removable random access memory (RAM), read only memory (ROM), flash memory, a conventional hard disk drive (HDD), a solid state drive (SSD), etc. In one embodiment, memory 110 is configured to store code, software modules, configurations, data, or files (e.g., training samples, model parameters, pruning sets, or redundant channels).

[0013] The processor 130 is coupled to the memory 110. The processor 130 may be a central processing unit (CPU), a graphics processing unit (GPU), a programmable general-purpose or special-purpose microprocessor, a digital signal processor (DSP), a programmable controller, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a neural network accelerator, other similar components, or a combination of the aforementioned components. In one embodiment, the processor 130 is configured to perform all or a portion of the operations of the computer system 100 and to load and execute each code, software module, file, and data stored in the memory 110.

[0014] In some embodiments, computer system 100 further includes input device 150. Input device 150 may be a touch panel, a mouse, a keyboard, a trackball, a switch, or a key. In one embodiment, input device 150 is configured to receive a user operation, such as a swipe, touch, press, or click operation.

[0015] In some embodiments, computer system 100 further includes a display 170. Display 170 may be a liquid crystal display (LCD), a light emitting diode (LED) display, an organic light emitting diode (OLED) display, a quantum dot display, or other types of displays. In one embodiment, display 170 is configured to display an image. The content of the image may be a user interface.

[0016] Hereinafter, the methods described in the embodiments of the present disclosure will be described with reference to devices, components, and modules in the computer system 100. Note that each process of the method can be adjusted according to circumstances and is not limited to the description here.

[0017] FIG. 2 is a flow chart of a neural network optimization method according to an embodiment of the present disclosure. Referring to FIG. 2, the processor 130 sequentially prunes the neural network using two different pruning algorithms (step S210). Specifically, the neural network is trained with a deep learning algorithm. The deep learning algorithm is, for example, YOLO (You only look once), AlexNet, ResNet, Region Based Convolutional Neural Networks (R-CNN), or Fast R-CNN (Fast CNN). It should be noted that the neural network may be used for image classification, object detection, or other inference, and the embodiment of the present disclosure is not intended to limit the use of the neural network. The trained neural network may meet a preset accuracy criterion.

[0018] It is worth noting that a trained neural network has parameters (e.g., weights, number of channels, biases, or activation functions) corresponding to each layer. Too many parameters may affect computational efficiency. One of the compression techniques for neural networks is pruning. Pruning is used to subtract elements (e.g., channels, filters / kernels, feature maps, layers, neurons, or other parameters) that have no or low potential influence from the neural network.

[0019] Different from the related art, the embodiments of the present disclosure provide a hybrid pruning solution, where two or more pruning algorithms may be channel, weight, filter, activation, gradient, and hidden layer pruning, or pruning search algorithms, which can achieve the highest compression ratio and the lowest accuracy loss compared to single pruning solutions.

[0020] In one embodiment, one of the pruning algorithms used in the embodiments of the present disclosure is a channel pruning (also called filter pruning) algorithm, such as ThiNet, network slimming, filter pruning via geometric median (FPGM), or channel pruning via geometric median (CPGM).

[0021] For example, the ThiNet method prunes the current layer according to the statistics of the next layer, and hopes to prune filters that have little or minimal impact on the output of the current layer. Therefore, the pruned channels make the mean square error smaller than the error threshold. Then, the channels are pruned layer by layer. Finally, the remaining channels that approximate all the channels of each layer are derived.

[0022] For example, FIG. 3 is a flow chart of the CPGM method according to an embodiment of the present disclosure. Referring to FIG. 3, the CPGM method refers to searching for Euclidean distance and redundant filter weights based on the filter weights proposed by the FPGM method. First, the processor 130 may set a norm ratio and a distance ratio. The norm ratio is a ratio set according to the magnitude of the filter weights to be placed. That is, the norm ratio is the ratio of the magnitudes to be preserved in all weights. For example, the norm ratio is 90% of the filter weights. The distance ratio is the proportion of the channel indexes that are close to the median value of the filter weights based on the Euclidean distance and are removed. That is, the distance ratio is a ratio represented by the similarity of two filters / channels (distance is related to the similarity). The processor 130 may sort the weights based on the set norm ratio and distance ratio (step S310). For example, the filter weights of the trained neural network are sorted in descending order, and the top 90% weights are extracted based on the norm ratio. The processor 130 may determine the Euclidean distance of the filters (step S320), for example, the distance between any tensor and all filters in the multidimensional space. The processor 130 may then determine similar filters and store corresponding channel indexes (step S330). For example, the point where the sum of Euclidean distances in each layer is the smallest is defined as the geometric center point. If a filter is close to the geometric center point of the layer to which it belongs in the multidimensional space (i.e., the closer, the higher the similarity, and the farther, the lower the similarity), the filter may be considered as data redundant and replaced. For example, the filter / channel is a redundant filter / channel and may be pruned. The index is a number representing the filter / channel. The processor 130 may assign one or more filter / channel indexes to a pruning set. That is, the set includes the redundant filters / channels to be pruned.

[0023] For example, FIG. 4 is a flowchart of a slimming method according to an embodiment of the present disclosure. Referring to FIG. 4, the processor 130 may rearrange the scaling coefficients of the channels in each batch normalization layer (e.g., from the first layer to the Nth layer in the figure, where N is a positive integer). The scaling coefficients will be multiplied to the output values ​​of the corresponding channels during forward propagation. During neural network training, the scaling coefficients are learned together with other weights and subject to constraints (e.g., L1 norm sparsity penalty). It is noteworthy that after training, if the scaling coefficient is small, the corresponding channel may be regarded as a redundant channel (may be classified into a pruning set), and if the scaling coefficient is large, the corresponding channel may be disabled / stopped / not regarded as a redundant channel. As shown in the figure, the global batch normalization threshold BNT is assumed to be 0.15. Thus, the channels with scaling factors of 0.001, 0.035, 0.1, 0.0134, and 0.122 in the first tier are redundant channels 401, and the channels with the listed scaling factors in the second tier are all redundant channels 401. Channels with scaling factors greater than the batch normalization threshold BNT are non-redundant channels 402. Processor 130 may then prune the redundant channels 401 and retain the non-redundant channels 402.

[0024] For example, based on both the ThiNet method and the Greedy method, the processor 130 may provide a validation dataset for each channel, and use an L2 norm function to compare and obtain the difference between the output feature maps of the pruned and non-pruned channels. If the difference is smaller than the difference threshold, the pruned channel may be regarded as a redundant channel, and if the difference is not smaller than the difference threshold, the pruned channel may be regarded as a non-redundant channel. The difference from the conventional ThiNet is that in this embodiment, the sparsity ratio sent to ThiNet is local sparsity, and the local sparsity ratio used in each layer may be different.

[0025] In one embodiment, the channel pruning algorithm includes a first channel pruning algorithm and a second channel pruning algorithm. The processor 130 may obtain a first pruning set according to the first channel pruning algorithm. The first pruning set includes one or more (redundant) channels to prune selected by the first channel pruning algorithm. Furthermore, the processor 130 may obtain a second pruning set according to a second channel pruning algorithm. The second pruning set includes one or more (redundant) channels to prune selected by the second channel pruning algorithm. That is, the processor 130 uses different channel pruning algorithms to obtain corresponding pruning sets. Then, the processor 130 may determine one or more redundant channels to prune according to the first pruning set and the second pruning set. For example, the processor 130 may obtain an intersection, union, any, or a fixed number of channels of these pruning sets, thereby providing a hybrid channel pruning solution.

[0026] For example, FIG. 5 is a flow chart of the combination of the slimming method and the ThiNet method according to an embodiment of the present disclosure. Referring to FIG. 5, for the trained neural network, the processor 130 may use the slimming method to determine a scaling factor threshold (e.g., the batch normalization threshold mentioned above) for each layer (step S510), and convert the global scaling factor threshold into a local sparseness corresponding to the sparseness ratio of each layer. The processor 130 may determine a first pruning set for each layer according to the local sparseness of each layer (step S520). Then, the processor 130 may select filters to be pruned using the ThiNet method (i.e., determine a second pruning set) according to the local sparseness (step S530). The processor 130 may determine redundant channels to be pruned according to the intersection of the pruning sets of the slimming method and the ThiNet method (step S540), and prune the redundant channels accordingly (step S550).

[0027] FIG. 6 is a flow chart of the combination of the CPGM method and the ThiNet method according to an embodiment of the present disclosure. Referring to FIG. 6, for a trained neural network, the processor 130 may use the CPGM method to determine a first pruning set according to a set norm ratio and distance ratio (step S610), and use the ThiNet method to determine a second pruning set according to a set distance ratio (step S620). It is noteworthy that the ThiNet method focuses on finding the channel effect of the output feature map. The CPGM method not only prunes the filter weights, but also obtains the difference between the weights of the redundant channels and the previous weights. Then, the processor 130 may determine the redundant channels to prune according to the intersection of the pruning sets of the ThiNet method and the CPGM method (step S630), and prune the redundant channels accordingly (step S640).

[0028] It should be noted that in other embodiments, other or more channel pruning algorithms may also be combined.

[0029] In one embodiment, another of the pruning algorithms used in the embodiments of the present disclosure is the weight pruning (also called element-wise pruning) algorithm. The weight pruning algorithm is, for example, the lottery hypothesis.

[0030] Taking the lottery hypothesis as an example, the processor 130 randomly initializes the neural network. The neural network includes multiple sub-networks. The processor 130 may iteratively train the neural network and find sub-networks that are more likely to win. During the process, the processor 130 may establish a mask to set a known pruning strategy. This strategy relates to which sub-networks influence the neural network, i.e., which sub-networks can win. The processor 130 may then prune sub-networks that do not have significant influence (cannot win) according to the mask. Taking weights as an example, the processor 130 may sort the weights and prune a certain proportion or number of the smallest weights.

[0031] In one embodiment, in response to pruning the neural network using the channel pruning algorithm, the processor 130 may then prune the neural network using a weight pruning algorithm. The channel pruning algorithm belongs to structured pruning, and the weight pruning algorithm belongs to unstructured pruning. Unstructured pruning prunes irregularly, so it may be difficult to ensure accuracy. By performing structured pruning first, the weights can be restored to stable values ​​and the overall structure can be ensured. Therefore, subsequent unstructured pruning can fine-tune the network to a more accurate one.

[0032] For example, Figure 7 is a schematic diagram of structured pruning and unstructured pruning according to one embodiment of the present disclosure. Referring to Figure 7, the processor 130 may prune the trained neural network using a structured pruning strategy to obtain a pruned neural network. The processor 130 may then prune the pruned neural network using an unstructured pruning strategy to obtain a final pruned neural network. The structured pruning strategy keeps the unpruned channels 703 and removes the redundant channels 702. The unstructured pruning strategy removes the redundant weights 701.

[0033] In other embodiments, other unstructured pruning methods (eg, gradients or activation) can also be used, or unstructured pruning can be performed before structured pruning.

[0034] In one embodiment, the processor 130 may converge the scaling coefficients of one or more batch normalization layers of the neural network before pruning. For example, the processor 130 may perform sparse training on the trained neural network. An L1 penalty is added to the loss function used to train the neural network. Batch normalization is the normalization of each mini-batch until a normal distribution with mean 0 and standard deviation 1 is formed. The overall correlation of the scaling coefficients between layers may converge, for example, helping the slimming method find a more suitable channel (e.g., with higher accuracy and / or less volume).

[0035] In some embodiments, if the scaling coefficients of the trained neural network approach preset values, the processor 130 may omit sparse learning or other schemes for converging the scaling coefficients.

[0036] Referring to FIG. 2, in response to each pruning algorithm pruning the neural network, the processor 130 retrains the pruned neural network (step S220). Specifically, after each pruning, the processor 130 may retrain the pruned neural network. When the neural network (model) converges, the processor 130 may prune the pruned neural network using another pruning algorithm. For example, the neural network is retrained after channel pruning, and when the neural network converges, weight pruning is then performed. During weight pruning, when the learning reaches a certain number of iterations, the processor 130 may sort the weights in ascending order, and then remove the smallest weight in the sorting according to the pruning ratio. Finally, the processor 130 may initialize the remaining weights back to the parameters of the original pre-trained model, and then retrain the pruned neural network to generate the final lightweight model.

[0037] That is, if channels are pruned, the stored channels are initialized and then the parameters of these stored channels are learned. If weights are pruned, the stored weights are initialized and then the parameters of these stored weights are learned. Re-learning of activation pruning, hidden layer pruning, or other pruning may be done as appropriate and thus is not repeated here.

[0038] It should be noted that in the above description, the combination of two pruning algorithms is taken as an example, but in other embodiments, more pruning algorithms may be combined.

[0039] In one embodiment, the processor 130 may receive an input operation via the input device 150. The input operation is used to set a pruning ratio, and at least one of two or more pruning algorithms is selected to prune according to the pruning ratio. That is, the pruning ratio is the ratio of elements (e.g., channels, weights, or activity) to prune to the total elements of each layer or each filter. For example, the keyboard receives an input operation for a pruning ratio of 50%. For channel pruning, the processor 130 selects 50% of the channels of one layer or multiple layers as redundant channels. For weight pruning, the processor 130 may remove 50% of the smallest weights.

[0040] In one embodiment, the processor 130 may use validation samples of known inference results to determine the accuracy loss of the pruned neural network. For example, if 10 out of 100 validation samples are incorrect in inference, the accuracy loss is 10%. The processor 130 may compare the accuracy loss to a quality threshold of the pruned neural network. The quality threshold is the accuracy loss that is allowed. For example, the quality threshold is 15%, 20%, or 25%. The processor 130 may change the pruning ratio of at least one of the pruning algorithms depending on the comparison of the accuracy loss to the quality threshold. That is, the quality threshold is used to evaluate whether to change the pruning ratio. For example, if the accuracy loss is lower than the quality threshold, the processor 130 may increase the pruning ratio. If the accuracy loss is higher than the quality threshold, the processor 130 may decrease the pruning ratio. In one embodiment, the processor 130 may treat the pruned neural network with the largest pruning ratio and whose accuracy loss is less than a quality threshold as the final lite model.

[0041] In one embodiment, input operations received via input device 150 may be used to set a quality threshold and at least one of two or more pruning algorithms may be selected to prune according to the quality threshold. For example, a mouse may receive input operations for a quality threshold of 15%.

[0042] In one embodiment, the processor 130 may provide (display) a user interface via the display 170. For example, FIG. 8 is a schematic diagram of a user interface according to one embodiment of the present disclosure. Referring to FIG. 8, the user interface includes a model setting 801, a pruning ratio setting 802, and a quality threshold setting 803. The model setting 801 is used to select a type of neural network, for example, third generation (V3) YOLO or Single Shot MultiBox Detector (SSD) Visual Geometry Group (VGG) 16. The pruning ratio setting 802 is used to select a pruning ratio, for example, 10% to 90%. The quality threshold setting 803 is used to set a quality threshold (i.e., a tolerable error rate), for example, 0% to 20%.

[0043] An embodiment of the present disclosure further provides a non-transitory computer-readable storage medium (e.g., a hard disk, an optical disk, a flash memory, a solid-state drive (SSD), etc.) for storing the code. The processor 130 or other processor of the computer system 100 can load the code and execute operations corresponding to one or more optimization methods according to an embodiment of the present disclosure. These operations have been described above and will not be repeated here.

[0044] In summary, the neural network optimization method and computer system, as well as the computer-readable storage medium according to the embodiments of the present disclosure, use hybrid pruning to reduce the overall computational complexity of the neural network. For example, the channel pruning algorithm and the weight pruning algorithm can be combined to reduce the number of channels and weights. According to the embodiments of the present disclosure, the pruning strategy is evaluated in terms of pruning ratio and accuracy, so that the requirements of high pruning ratio and high accuracy can be met. Furthermore, the embodiments of the present disclosure provide a user interface, so that the operator can easily understand and become familiar with the operation.

[0045] Although the present disclosure has been described with reference to the above exemplary embodiments, they are not intended to limit the present disclosure. Those skilled in the art can make changes and modifications without departing from the spirit and scope of the present disclosure. Therefore, the scope of protection of the present disclosure is defined by the following claims. [Industrial Applicability]

[0046] The neural network optimization method, computer system, and computer-readable storage medium according to the present invention can be applied to electronic devices and control methods thereof. [Explanation of symbols]

[0047] 100 Computer Systems 110 Memory 130 processors 150 Input Devices 170 Display S210~S220, S310~S330, S510~S550, S610~S640 Step 401 Redundant Channel 402 Non-redundant channels BNT Batch Normalization Threshold 701 Redundant Weights 702 Redundant Channel 703 Unpruned Channels 801 Model Settings 802 Pruning Ratio Settings 803 Quality Threshold Setting

Claims

1. 1. A method for optimizing a neural network, the method comprising: converging a plurality of scaling coefficients of at least two batch normalization layers of the neural network, each of the plurality of scaling coefficients being used to determine whether a corresponding channel in one of the batch normalization layers is a redundant channel; pruning the neural network sequentially using two different pruning algorithms in response to converging the plurality of scaling factors; retraining the pruned neural network according to each of the pruning algorithms for pruning the neural network; Equipped with one of the two pruning algorithms is a channel pruning algorithm, and sequentially pruning the neural network using the two different pruning algorithms includes: Transform a global scaling factor threshold into a local sparsity corresponding to a sparsity ratio of each of the batch normalization layers, the local sparsity used for the at least two batch normalization layers being different; pruning redundant channels that have a scaling factor smaller than the local sparsity of the corresponding batch normalization layer; Including, How to optimize neural networks.

2. 2. A method for optimizing a neural network according to claim 1, comprising the steps of: the other of the two pruning algorithms is a weight pruning algorithm, and the step of sequentially pruning the neural network using the two different pruning algorithms includes: pruning the neural network using the weight pruning algorithm in response to pruning the neural network using the channel pruning algorithm; A method for optimizing a neural network comprising:

3. 2. A method for optimizing a neural network according to claim 1, comprising the steps of: comparing the accuracy loss of the pruned neural network to the quality threshold; modifying the pruning ratio of at least one of the two pruning algorithms according to a result of the comparison with the quality threshold; The method for optimizing a neural network further comprises:

4. 1. A computer system for a neural network, the computer system comprising: A memory configured to store a code; A memory coupled to said memory and said code converging a plurality of scaling coefficients of at least two batch normalization layers of the neural network, each of the plurality of scaling coefficients being used to determine whether a corresponding channel in one of the batch normalization layers is a redundant channel; 2. Sequentially pruning the neural network using two different pruning algorithms in response to converging the plurality of scaling factors; and retraining the pruned neural network according to each of the pruning algorithms for pruning the neural network; a processor configured to load and execute the Equipped with One of the two pruning algorithms is a channel pruning algorithm, and the processor further comprises: converting a global scaling factor threshold into a local sparsity corresponding to a sparsity ratio of each of the batch normalization layers, the local sparsity used for the at least two batch normalization layers being different; A computer system configured to prune redundant channels having a scaling factor smaller than the local sparsity of a corresponding batch normalization layer.

5. A non-transitory computer readable storage medium for storing code, the code comprising: A non-transitory computer readable storage medium which, when loaded by a processor, performs the method of optimizing a neural network of claim 1.

Citation Information

Patent Citations

  • YOLOV3 model pruning method for intelligent vehicle-mounted platform

    CN113947203A

  • Structured pruning method and device based on local sparse constraint

    CN114282666A

  • Deep Learning System

    JP2021526253A

  • Neural network architecture pruning

    US20210264278A1

  • Method and device for pruning convolutional layer in neural network

    US20210287092A1