Method and apparatus for pruning neural networks

By setting weight thresholds and iteratively pruning neural networks using a pruning dataset, the method addresses complexity issues, enhancing efficiency and accuracy without retraining, thus facilitating miniaturization and commercialization.

JP7571942B2Active Publication Date: 2024-10-23SAMSUNG ELECTRONICS CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2020146931
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2019-09-16
Filing Date
2020-09-01
Publication Date
2024-10-23
Estimated Expiration
2040-09-01

AI Technical Summary

Technical Problem

The complexity of neural networks leads to increased memory allocation and inefficient performance, resulting in decreased reliability and accuracy for new data predictions due to overfitting, which hinders miniaturization and commercialization.

Method used

A method for pruning neural networks by setting a weight threshold based on weight distribution, using a pruning dataset to predict the influence on inference accuracy, and iteratively determining and pruning layers to maintain performance without relearning.

Benefits of technology

The method enables efficient neural network pruning with minimal accuracy loss, reducing computational complexity and memory requirements while preserving inference accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007571942000007
    Figure 0007571942000007
  • Figure 0007571942000008
    Figure 0007571942000008
  • Figure 0007571942000009
    Figure 0007571942000009
Patent Text Reader

Abstract

To provide a method and apparatus for pruning a neural network.SOLUTION: A method and apparatus for pruning a neural network sets a weight threshold value based on a weight distribution of layers included in a neural network, predicts influence on a change of inference accuracy of a neural network of pruning each layer based on the weight threshold value, determines a current subject layer to be pruned with a weight threshold value among the layers included in the neural network, and prunes the determined current subject layer.SELECTED DRAWING: Figure 7
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to a method and an apparatus for pruning a neural network. [Background technology]

[0002] A neural network is a computer system implemented with reference to a computational architecture. Recently, with the development of neural network technology, research has been actively conducted on using neural networks to analyze input data and extract useful information in various electronic systems.

[0003] A device that processes a neural network requires a large amount of calculations for complex input data. As the amount of data and learning of a neural network increases, the connectivity of the architecture that constitutes the neural network becomes complex, and an overfitting problem may occur in which the accuracy of past learning data increases but the reliability of prediction values ​​for new data decreases. In addition, an increase in the complexity of a neural network leads to an excessive increase in memory allocation, resulting in inefficient performance in miniaturization and commercialization. Therefore, a compression method is being researched to reduce system costs in implementing a neural network while maintaining the performance of the neural network. Summary of the Invention [Problem to be solved by the invention]

[0004] The problem to be solved by the present invention is to provide a method and an apparatus for pruning a neural network. The technical problem to be solved by the present embodiment is not limited to the above-mentioned technical problem, and other technical problems may be inferred from the following embodiments. [Means for solving the problem]

[0005] According to one aspect, a method for pruning a neural network includes the steps of: setting a weight threshold for pruning the neural network at a target pruning ratio based on a weight distribution of layers included in the neural network; predicting an effect of pruning each layer based on the weight threshold on a change in inference accuracy of the neural network using a pruning dataset prepared from a predetermined number of data sources randomly extracted from each class included in a given dataset; determining a current target layer to be pruned with the weight threshold from among the layers included in the neural network based on the predicted effect; and pruning the determined current target layer, wherein the pruning of the neural network is iteratively performed on the remaining layers of the neural network when pruning of the current target layer is completed.

[0006] According to another aspect, a computer readable medium may include a medium having one or more programs recorded thereon, the programs including instructions for performing the methods described above.

[0007] According to yet another aspect, an apparatus for pruning a neural network includes a memory and at least one processor for executing a program to perform the pruning on the neural network, the at least one processor setting a weight threshold for pruning the neural network at a target pruning ratio based on a weight distribution of layers included in the neural network, using a pruning dataset prepared from a predetermined number of data sources randomly extracted from each class included in a given dataset, predicting an effect of pruning each layer based on the weight threshold on a change in inference accuracy of the neural network, determining a current target layer to be pruned with the weight threshold from among the layers included in the neural network based on the predicted effect, and pruning the determined current target layer, and when pruning of the current target layer is completed, the at least one processor iteratively performs the pruning on remaining layers of the neural network. Effect of the Invention

[0008] According to the neural network pruning method performed by the neural network pruning device of this embodiment, pruning of the neural network is performed without re-learning the neural network using a pruning data set, which enables more efficient pruning of the neural network. [Brief description of the drawings]

[0009] [Figure 1] 1 is a diagram illustrating a neural network according to an embodiment; [Figure 2A] 1 is a diagram for explaining pruning of a neural network according to an embodiment; [Figure 2B] 1 is a diagram for explaining pruning of a neural network according to an embodiment; [Diagram 3] FIG. 2 is a block diagram illustrating a hardware configuration of a neural network pruning device according to an embodiment. [Figure 4] 1 is a diagram illustrating a pruning data set according to an embodiment; [Figure 5A] 1 is a diagram illustrating types of pruning data sets according to an embodiment; [Figure 5B] 1 is a diagram illustrating types of pruning data sets according to an embodiment; [Figure 5C] 1 is a diagram illustrating types of pruning data sets according to an embodiment; [Figure 5D] FIG. 5D is a diagram for explaining in more detail the process of providing the pruning data set of FIG. 5C (third type pruning data set). [Figure 6] 1 is a diagram illustrating a weight threshold setting for neural network pruning according to an embodiment; [Figure 7] 1 is a diagram for explaining a process of performing neural network pruning according to an embodiment. [Figure 8] 1 is a flowchart of a method for pruning a neural network according to one embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0010] The terms used in this embodiment are generally used as much as possible, but they may vary depending on the intentions or precedents of engineers in the field, the emergence of new technologies, etc. In addition, in certain cases, the applicant may arbitrarily select terms, and in such cases, the meanings of the terms are described in detail in the relevant description. Therefore, the terms used in the specification must be defined based on the meanings of the terms and the overall content of the specification, rather than simply by the names of the terms.

[0011] Terms such as "comprise" or "include" used in the present embodiment should not be construed as including all of the various components or steps described in the specification, but should be interpreted as not including some components or steps, or as including additional components or steps.

[0012] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will now be described in detail with reference to the accompanying drawings, in which: FIG.

[0013] FIG. 1 is a diagram for explaining a neural network according to an embodiment.

[0014] A neural network is a computer computing system. For example, automation of pattern recognition or analysis techniques is also implemented through a processor implemented neural network model. It is a specialized computational architecture that can provide a computationally intuitive mapping between input patterns and output patterns, or pattern recognition of input patterns, after substantial training. The training ability to generate such mappings or perform pattern recognition is also referred to as the learning ability of the neural network. Such training ability allows the specialized computational architecture to classify input patterns, or parts of input patterns, as members belonging to one or more predefined groups. A neural network trained by specialized training can have a generalized ability to generate relatively accurate or reliable outputs, for example, even for input patterns that have not been input to the neural network.

[0015] A deep neural network is a method for implementing a neural network, and the neural network may include multiple layers. For example, the deep neural network includes an input layer to which input data is applied, an output layer that outputs a result derived through prediction based on the input data based on learning, and multiple hidden layers that perform neural network operations between the input layer and the output layer.

[0016] Deep neural networks are also classified into various types, such as fully connected networks, convolutional neural networks, and recurrent neural networks, depending on the algorithms they use to process information.

[0017] Hereinafter, as is common practice in the neural network technology field, the input layer also corresponds to the lowest layer, and the output layer also corresponds to the highest layer. On the other hand, the layers may be named in order from the output layer, which is the highest layer, to the input layer, which is the lowest layer. For example, hidden layer 2 is a layer higher than hidden layer 1 and the input layer, but also corresponds to a layer lower than the output layer.

[0018] A deep neural network includes multiple layers, and between adjacent layers, a relatively higher layer outputs a predetermined calculated value by applying a biased value obtained by multiplying the output value of a relatively lower layer by a weight, and the output value is also applied in a similar manner to an adjacent higher layer of the higher layer.

[0019] The method of learning a neural network is called deep learning, and as mentioned above, various algorithms such as convolutional neural network and recurrent neural network are used in deep learning.

[0020] In this case, learning of a neural network means determining and updating weights and biases between layers, or weights and biases between multiple neurons (or nodes) belonging to different layers in adjacent layers.

[0021] For example, the layer structure, or the weights and biases of the layers and neurons, can be collectively defined as the connectivity of the neural network. Therefore, neural network learning can refer to learning by building connectivity.

[0022] 1, each of the layers 101, 103, 105, and 107 may include a number of nodes, which represent neurons of a neural network. That is, in the following description, the terms "neuron" and "node" have the same meaning.

[0023] Referring to Fig. 1, multiple nodes in one layer and multiple nodes in an adjacent layer are fully-connected. For example, node 3-1 in hidden layer 2 105 is connected to all nodes in hidden layer 1 103, i.e., nodes 2-1 to 2-4, and receives values ​​obtained by multiplying the output value of each node by a predetermined weight.

[0024] Data input to the input layer 101 is processed through multiple hidden layers, and a final output value 109 is output in the output layer 107. At this time, a larger weight means that the connectivity between the corresponding two nodes is strengthened, and a smaller weight means that the connectivity between the two nodes is weakened. For example, the weight has a value from 0 to 1, and a weight of 0 means that there is no connectivity between the two nodes. However, the numerical range of the weight is not limited thereto, and may vary depending on the implementation method of the neural network.

[0025] On the other hand, as the connectivity through the weights increases, the connectivity of the neural network is strengthened and the complexity increases. This increases the memory allocation for storing the weights, slowing down the overall work performance of the neural network and decreasing its efficiency. Therefore, a compression method is desired that reduces the size of the neural network, reduces system costs, and reduces the amount of calculations performed in implementing the neural network while maintaining the performance of the neural network.

[0026] 2A and 2B are diagrams for explaining pruning of a neural network according to an embodiment.

[0027] 2A, neural network 210 corresponds to the neural network before pruning, and neural network 220 corresponds to the neural network after pruning, which may include coarse-grained neural network pruning (e.g., removing channels, kernels, or nodes in a neural network model) and fine-grained neural network pruning (e.g., pruning individual weights in a neural network model).

[0028] Specifically, in the neural network 210, a connection relationship is formed between all combinations of two neurons included in two adjacent layers different from each other. That is, since the neural network 210 is a fully connected neural network, a weight indicating the connection strength between any two neurons included in the neural network 210 and belonging to adjacent layers different from each other is also a value greater than 0. In this way, when there is connectivity between neurons in all adjacent layers, the complexity of the entire neural network increases, and as a result, the accuracy and reliability of the prediction results of the neural network decrease due to overfitting.

[0029] To reduce the complexity of the neural network, pruning may be performed on the neural network.

[0030] Neural network pruning refers to performing a process of weakening or removing the connectivity between any nodes connected in neural network 210 when the weight between the nodes is equal to or less than a predetermined threshold, as shown in FIG. 2A. For example, when the weight between node 1 and node 2-3 in neural network 210 is equal to or less than a predetermined threshold, pruning is a process of removing the connectivity between node 1 and node 2-3 in neural network 210 by setting the weight between node 1 and node 2-3 to 0, as in pruned neural network 220. Similarly, pruned neural network 220 illustrates an example in which the connectivity between some nodes in neural network 210 has been weakened or removed.

[0031] Each layer of the neural network is searched to determine the appropriate neural network nodes before pruning. At this time, it is desirable to search for layers and weights to be pruned on a line that does not excessively reduce the inference accuracy of the neural network, i.e., the output of the neural network.

[0032] During the pruning process, connections between neurons in the weights of the layers included in the neural network that have values ​​smaller than a predefined weight threshold are searched for, and the connections between neurons with such weights can be removed or weakened.

[0033] 2B, the result of pruning the k-th kernel of the n-th layer, KERNELn_k 230 (n and k are natural numbers), in the neural network is illustrated. Meanwhile, as a setting for pruning the neural network, for example, the weight threshold τ is assumed to be 0.5 people.

[0034] Before pruning, KERNEL n_k 230 has weights of various values. n_k Among the 230 weights, any weights below the weight threshold (τ = 0.5) are pruned to 0, and the pruned KERNEL n_k 240 is generated. Thus, the pruned KERNEL n_k 240 is KERNEL n_k Compared with 230, the weights having a value of 0 weaken the connectivity between adjacent nodes, thereby reducing the amount of calculation between adjacent nodes.

[0035] FIG. 3 is a block diagram illustrating a hardware configuration of a neural network pruning device according to an embodiment.

[0036] 3, the neural network pruning device 100 includes a processor 110 and a memory 120. Only components related to the present embodiment are shown in the neural network pruning device 100 shown in FIG 3. Therefore, it is obvious to those skilled in the art that the neural network pruning device 100 may further include other general components in addition to the components shown in FIG 3.

[0037] The neural network pruning device 100 corresponds to a computer device that performs pruning on a neural network. For example, the neural network pruning device 100 corresponds to a PC (personal computer), a server device, a mobile device, etc., and further corresponds to a device equipped in an autonomous vehicle, robotics, a smartphone, a tablet device, an AR (augmented reality) device, an IoT (Internet of Things) device, etc. that performs voice recognition, image recognition, etc. using a neural network, but is not limited thereto and corresponds to various types of devices.

[0038] The processor 110 is a hardware configuration that performs an overall control function for controlling the operation of the neural network pruning apparatus 100. For example, the processor 110 can generally control the neural network pruning apparatus 100 by executing a program stored in the memory 120 in the neural network pruning apparatus 100. The processor 110 can be realized by a central processing unit (CPU), a graphics processing unit (GPU), an application processor (AP), a neural processing unit (NPU), etc. provided in the neural network pruning apparatus 100, but is not limited thereto.

[0039] Memory 120 is hardware that stores various neural network data processed in processor 110. For example, memory 120 may store pruning data for a neural network, a data set to be input to a neural network, etc. Memory 120 may also store various applications driven by processor 110, such as an application for neural network pruning, a neural network driving application, a driver, etc.

[0040] The memory 120 may include at least one of a volatile memory or a nonvolatile memory. The nonvolatile memory includes a read only memory (ROM), a programmable read only memory (PROM), an electrically programmable read only memory (EPROM), an electrically erasable and programmable read only memory (EEPROM), a flash memory, a phase-change random access memory (PRAM), a magnetic random access memory (MRAM), a resistive random access memory (RRAM), a ferroelectric random access memory (FRAM), and the like. The volatile memory includes a dynamic random access memory (DRAM), a static random access memory (SRAM), a synchronous dynamic random access memory (SDRAM), and the like. Furthermore, the memory 120 may include at least one of a hard disk drive (HDD), a solid state drive (SSD), a compact flash (CF), a secure digital (SD), a micro-SD (micro secure digital), a mini-SD (mini secure digital), an xD (extreme digital), or a Memory Stick.

[0041] The processor 110 sets a weight threshold for pruning the neural network with a target pruning ratio based on the weight distribution of the layers included in the neural network. At this time, the processor 110 can set a weight value corresponding to the target pruning ratio as the weight threshold under the assumption that the weight distribution corresponds to a Gaussian distribution such as a standard normal distribution. However, the processor 110 can also set a weight threshold suitable for neural network pruning by using various statistical distributions other than the standard normal distribution.

[0042] The processor 110 can perform neural network pruning by inputting a pruning data set to the neural network and iteratively measuring and verifying the inference accuracy of the neural network with respect to the pruning data set. The preparation of the pruning data set will be described in detail below with reference to the drawings.

[0043] The processor 110 uses the prepared pruning data set to predict the effect of pruning each layer based on the weight threshold on the change in the inference accuracy of the neural network. Here, the effect prediction is also performed by calculating a sensitivity for each layer based on the difference between the inference accuracy before pruning for each layer and the inference accuracy after pruning for each layer. Meanwhile, the sensitivity means the degree to which the output of the neural network is affected by the input to the neural network or the weight perturbation of the neural network. For example, the sensitivity measurement can be defined as the mathematical expectation of the output deviation due to the expected input deviation for the entire input pattern for successive intervals. That is, the sensitivity is also used to determine the output response of the neural network model when various input parameters are input to the neural network model.

[0044] The processor 110 determines a current subject layer to be pruned by a weight threshold among layers included in the neural network based on the predicted influence. The processor 110 may determine a layer predicted to have the lowest sensitivity among remaining layers excluding previously pruned layers as the current subject layer. In other words, the layer predicted to have the lowest sensitivity means a layer predicted to have the least influence on the degradation of the inference accuracy of the neural network.

[0045] When the current target layer is determined, the processor 110 prunes the determined current target layer. Specifically, the processor 110 can prune the current target layer by updating the weight threshold and adjusting the pruning ratio of the weights of the current target layer until the inference accuracy of the neural network on the pruning data set drops to a critical accuracy.

[0046] After completing pruning for the current target layer, the processor 110 searches for a new target layer to be pruned among the remaining layers of the neural network, and performs pruning on the newly searched target layer repeatedly, thereby pruning the entire neural network. The condition for completing pruning for the entire neural network is when the neural network pruning reaches an initially set target pruning ratio, or when pruning is completed for all layers included in the neural network.

[0047] FIG. 4 is a diagram illustrating a pruning data set according to an embodiment.

[0048] Referring to FIG. 4, the pruning dataset 420 is also a dataset used to measure and verify changes in the inference accuracy of the neural network (e.g., sensitivity for each layer) while pruning the neural network is being performed.

[0049] The pruned dataset 420 is also prepared from an initial given dataset 410. Here, the given dataset 410 may be a public dataset such as the ImageNet database or the MNIST database, but is not limited thereto, and various kinds of databases may be utilized.

[0050] The pruning dataset 420 may be prepared to reduce the pruning phenomenon caused by overfitting to the given dataset 410, which may occur when the given dataset 410 is used as is, and to shorten the neural network pruning time. However, depending on the type of the given dataset 410, the preparation process of the pruning dataset 420 may vary.

[0051] 5A to 5C are diagrams for explaining types of pruning data sets according to an embodiment.

[0052] 5A, the pruning dataset 512 (first type pruning dataset) may be the same as the given dataset 511. As described above, in the case where it is expected that the problem of overfitting will not occur when the given dataset 511 is used in neural network pruning, the pruning dataset 512 may be prepared to be the same as the given dataset 511. For example, when the given dataset 511 corresponds to the ImageNet database, the first type pruning dataset is also a data source of millions to tens of millions of images in the ImageNet database.

[0053] Referring to FIG. 5B, the pruning dataset 522 (second type pruning dataset) is also prepared by randomly extracting a predetermined number of data sources from each of various classes included in the given dataset 521. For example, it can be assumed that the given dataset 521 is a dataset acquired from the ImageNet database including more than about 1 million data sources having about 1,000 classes. In such a case, the pruning dataset 522 is also prepared as a new dataset including only the extracted data sources by randomly extracting about 1 to 10 data sources from each of about 1,000 classes of the given dataset 521. Meanwhile, the number of randomly extracted data for each class can be set arbitrarily or can vary for each class. According to the preparation method described in FIG. 5B, the size of the dataset is relatively greatly reduced, so that the processing time of the neural network pruning can be shortened and the phenomenon that the pruned neural network is overfitted only to a specific database can be prevented.

[0054] On the other hand, pruning of known neural networks such as “Inception-v3” can also be performed using a second type of pruning dataset based on already known classes from the ImageNet database, provided by the method described in FIG. 5B.

[0055] However, since neural networks that train on unknown datasets, such as the Aic-classifier, cannot know the inference algorithm, it is necessary to select classes that a neural network such as the Aic-classifier can effectively infer from the classes already defined in the ImageNet database.

[0056] Referring to FIG. 5C, a given dataset 531 is provided to prune a neural network that learns with an unknown dataset, such as the "Aic-classifier". The processor 110 (FIG. 3) may generate a pruned dataset 533 (a third type of pruned dataset) by another preparation method. Specifically, the given dataset 531 is input to a neural network, and the processor 110 performs inference on a data source (e.g., an image) of the given dataset 531 using the neural network. The processor 110 may determine labels of each of the data sources classified in the given dataset 531 as an inference result of the neural network. Here, the labels are also identifiers indicating which classification the data source belongs to. The processor 110 selects a class having an accuracy level or higher and determines the class as a valid class 532. Finally, the processor 110 may randomly extract a predetermined number of data sources, for example, 1 to 10 data sources, from each valid class 532, and prepare a new data set including only the extracted data sources as a pruning data set 533. However, as described in FIG. 5B, the number extracted for each valid class 532 may be set arbitrarily, but may vary for each class.

[0057] FIG. 5D is a diagram for explaining in more detail the process of providing the pruning data set of FIG. 5C (the third type of pruning data set).

[0058] 5D, it is assumed that a given dataset includes a total of 1,000 classes from CLASS 1 to CLASS 1000. The processor 110 randomly extracts samples of 100 data sources for each class. The processor 110 then uses a neural network to perform inference on each data source (e.g., image) and determine a label for each data source. Here, the label is also an identifier indicating which classification the data source belongs to.

[0059] The processor 110 determines that a class whose ratio of the most frequent label in the entire class is equal to or greater than a predetermined accuracy (e.g., 60%) is a valid class. As a result, the processor 110 can select the classes CLASS 1, CLASS 3, ..., CLASS 999 that satisfy such a condition as valid classes.

[0060] The processor 110 may randomly extract a predetermined number (e.g., 1 to 50) of data sources from each valid class, and prepare a new data set including only the extracted data sources as a third type pruning data set. Meanwhile, the number of samples randomly extracted for each class, the predetermined accuracy value for selecting the valid class, and the number of data sources randomly extracted from the valid class may be set arbitrarily, but may vary for each class.

[0061] The processor 110 of the neural network pruning device 100 (FIG. 3) can use the pruning data set prepared by the method described in FIGS. 5A to 5D to measure and verify the inference accuracy required for the pruning process of the neural network.

[0062] FIG. 6 is a diagram illustrating setting a weight threshold for neural network pruning according to an embodiment.

[0063] 6, the processor 110 sets a weight threshold for pruning the neural network at a target pruning ratio based on the weight distribution of layers included in the neural network. At this time, the processor 110 may set a weight value corresponding to the target pruning ratio to the weight threshold under the assumption that the weight distribution corresponds to a Gaussian distribution such as a standard normal distribution.

[0064] The following Equation 1 is used to calculate the weight threshold τ corresponding to the target pruning ratio (α%). (Formula 1)

number

[0065] Specifically, the processor 110 first obtains a Z value corresponding to the target pruning ratio (α%) on the standard normal distribution assumed for the weight distribution of the layers included in the neural network. Then, the processor 110 calculates the weight threshold τ using the average μ and standard deviation σ of the weights.

[0066] For example, if the target pruning ratio (α%) is 30%, it is also calculated that Z=0.39, and the weight mean μ and standard deviation σ are further calculated, through which the weight threshold τ for neural network pruning is also set.

[0067] However, the processor 110 may use a variety of other statistical distributions besides the standard normal distribution to set appropriate weight thresholds for neural network pruning.

[0068] FIG. 7 is a diagram for explaining a process of performing neural network pruning according to an embodiment.

[0069] Referring to FIG. 7, in step 701, the processor 110 uses the method described in FIG. 6 to set a weight threshold for pruning the neural network at a target pruning ratio based on the weight distribution of the layers included in the neural network.

[0070] In operation 702, the processor 110 calculates the sensitivity for each layer of the neural network, and determines the layer having the lowest sensitivity as the current target layer. Here, the layer determined to have the lowest sensitivity corresponds to the layer predicted to have the least effect on the degradation of the inference accuracy of the neural network due to the neural network pruning. The processor 110 may use at least one of the pruning data sets previously described in FIG. 5A to FIG. 5D for the sensitivity calculation, and by using such pruning data set, the effect of pruning of each layer based on the weight threshold on the change in the inference accuracy of the neural network may be predicted.

[0071] The sensitivity can also be calculated using the following formula 2. (Formula 2)

number

[0072] Referring to Equation 2, τ is a weight threshold, t is the order of pruning for the layers of the neural network, and k is the index of the current target layer to be pruned. For example, if the current target layer to be pruned corresponds to the third layer to be pruned in the neural network, t=3. W t denotes the weight at order t,

number

number

[0073] That is, according to Equation 2, the sensitivity is also calculated for each layer based on the difference between the inference accuracy before pruning for each layer and the inference accuracy after pruning for each layer.

[0074] In step 703, the processor 110 prunes weights in the current layer that are equal to or less than a weight threshold τ.

[0075] In step 704, the processor 110 measures the inference accuracy of the neural network on the pruned data set according to the pruning result of the current target layer.

[0076] In step 705, processor 110 compares the measured inference accuracy with the critical accuracy to determine whether the measured inference accuracy has fallen below the critical accuracy. If the measured inference accuracy has not fallen as low as the critical accuracy, the process proceeds to step 707. However, if the measured inference accuracy has fallen below the critical accuracy, the process proceeds to step 706.

[0077] In operation 706, the processor 110 updates the weight threshold τ by increasing the weight threshold τ if the inference accuracy due to the pruning of the current target layer according to the weight threshold τ has not decreased to the critical accuracy. For example, the processor 110 updates the weight threshold τ by increasing it by δ, such as τ=τ+δ. Here, δ is a value that can be arbitrarily set in consideration of various factors such as the weight distribution of the neural network and the pruning ratio for the current target layer.

[0078] Based on the updated weight threshold, the processor 110 again performs steps 703 to 705. That is, the processor 110 updates the weight threshold until the inference accuracy of the neural network for the pruning data set drops to the critical accuracy, and prunes the current target layer by adjusting the pruning ratio of the weights of the current target layer.

[0079] Alternatively, steps 703 to 706 may be performed using Equation 3 below. (Formula 3)

number

[0080] Referring to Equation 3, β indicates the critical accuracy, and as described above, when the decrease in inference accuracy is below a certain level, the weight threshold τ is increased, and pruning is performed on the current target layer while increasing the pruning ratio for the current target layer.

[0081] Furthermore, if it is determined in step 705 that the measured inference accuracy is lower than the critical accuracy, the processor 110 terminates pruning for the current target layer and performs step 707 .

[0082] In step 707, the processor 110 determines whether pruning has been completed for all layers of the neural network. If it is determined that pruning has not been completed for all layers, the processor 110 proceeds to step 708.

[0083] In operation 708, the processor 110 stores the pruning result of the currently targeted layer just performed in the memory 120, and repeats the process from operation 702 to perform pruning on the next layer (t+1).

[0084] If the processor 110 determines in step 707 that pruning has been completed for all layers, it ends the neural network pruning.

[0085] The processor 110 uses the pruned neural network to perform inference.

[0086] Meanwhile, as a condition for terminating the neural network pruning, it has been described that in operation 707, it is determined whether pruning for all layers is completed. However, without being limited thereto, according to another embodiment, the processor 110 may determine whether an initially set target pruning ratio is reached as a condition for terminating the neural network pruning. That is, in operation 707, the processor 110 may control the neural network pruning to be terminated when a result of iterative pruning for layers of the neural network reaches an initially set target pruning ratio.

[0087] According to another embodiment, the processor 110 may determine that a condition for terminating neural network pruning is met when a target pruning ratio is reached or pruning for all layers is completed.

[0088] Meanwhile, in the past, neural networks were repeatedly retrained to minimize the accuracy loss caused by pruning. However, when neural networks are repeatedly retrained, a lot of resources (e.g., time, GPUs, etc.) are required for retraining. Specifically, a simulation result for pruning the Inception-v3 model by 57% showed that it took more than seven days when using six GPUs, and two to three days in the case of ResNet-101, which has the fastest speed.

[0089] According to the neural network pruning method performed by the neural network pruning device 100 of this embodiment, pruning of the neural network can be performed without re-learning the neural network using a pruning data set, thereby enabling more efficient pruning of the neural network.

[0090] 8 is a flowchart of a method for pruning a neural network according to an embodiment. Since the method of FIG. 8 relates to the embodiment described in the previous drawings, the contents described in the previous drawings may also be applied to the method of FIG. 8, even if the contents are omitted below.

[0091] In step 801, the processor 110 sets a weight threshold for pruning the neural network at a target pruning ratio based on the weight distribution of layers included in the neural network.

[0092] In step 802, the processor 110 uses the pruned data set to predict the effect of pruning each layer based on a weight threshold on the change in inference accuracy of the neural network.

[0093] In step 803, the processor 110 determines, based on the predicted influence, a currently selected layer among the layers included in the neural network to be pruned by a weight threshold.

[0094] In step 804, the processor 110 prunes the determined currently targeted layer.

[0095] When pruning for the current target layer is completed, the processor 110 iteratively performs pruning for the remaining layers of the neural network.

[0096] Table 1 below shows the simulation results comparing the accuracy of the conventional method and the method of this embodiment when pruning is performed without re-learning. Here, the simulation results of this embodiment are the result of pruning the Inception-v3 neural network after randomly extracting one data source from each of the 1,000 classes in the ImageNet database to provide a total of 1,000 data sources. [Table 1] Before training, the accuracy of the neural network was 77.97%. As described above, when pruning without re-learning, the accuracy of the conventional method was significantly reduced, while the accuracy of the method of the present embodiment was simulated to be reduced by only 1.78%. Therefore, the pruning method of the present embodiment can prune a neural network without re-learning, while reducing accuracy loss and achieving a high pruning rate.

[0097] Meanwhile, the above-mentioned embodiments can be created into a program that can be executed by a computer, and can also be embodied in a general-purpose digital computer that runs the program using a computer-readable recording medium. Also, the data structures used in the above-mentioned embodiments can be recorded in a computer-readable recording medium through various means. Computer-readable recording media include recording media such as magnetic recording media (e.g., ROM, floppy disk, hard disk, etc.) and optically readable media (e.g., CD-ROM (compact disc read only memory), DVD (digital versatile disc), etc.).

[0098] Those skilled in the art in the art to which the present embodiment relates can understand that the present embodiment can be embodied in modified forms without departing from the essential characteristics described above. Therefore, the disclosed embodiments should be considered from an explanatory perspective, not a limiting perspective. The scope of the rights is shown in the claims, not the above description, and all differences within the scope equivalent thereto should be interpreted as being included in the present embodiment. [Explanation of symbols]

[0099] 100 Neural Network Pruning Device 101 Input Layers 103,105 Hidden layer 107 Output Layer 110 Processor 120 Memory

Claims

1. 1. A method for pruning a neural network, comprising: setting a weight threshold for pruning the neural network at a target pruning ratio based on a weight distribution of layers included in the neural network; Using a pruning dataset prepared from a predetermined number of data sources randomly extracted from each class included in a given dataset, predicting the effect of pruning each layer based on the weight threshold on a change in inference accuracy of the neural network; determining a current layer to be pruned from among the layers in the neural network based on the predicted influence using the weight threshold; pruning the determined current target layer; The method, wherein the pruning for the neural network is performed iteratively for remaining layers of the neural network when pruning for the current target layer is completed.

2. The step of determining a current target layer includes: The method of claim 1 , further comprising determining, as the current target layer, a layer predicted to have the lowest sensitivity to the influence from among remaining layers in the neural network excluding previously pruned layers.

3. The step of predicting the effect comprises: The method of claim 2 , wherein the impact is predicted by calculating a sensitivity for each layer based on a difference between an inference accuracy before pruning for each layer and an inference accuracy after pruning for each layer.

4. The layer predicted to have the lowest sensitivity is The method of claim 2 , wherein the layer corresponds to a layer predicted to have the least impact on degradation of the inference accuracy of the neural network.

5. The step of setting the weight threshold value comprises: The method of claim 1 , further comprising: setting the weight threshold to a weight value corresponding to the target pruning ratio under the assumption that the weight distribution corresponds to a standard normal distribution.

6. The step of pruning the currently targeted layer includes:

2. The method of claim 1, further comprising pruning the currently targeted layer by updating the weight threshold and adjusting a pruning ratio of weights in the currently targeted layer until an inference accuracy of the neural network on the pruned data set drops to a critical accuracy.

7. The weight threshold is updated by 7. The method of claim 6, further comprising increasing the current weight threshold if the inference accuracy of the neural network including pruned weights at the current weight threshold has not decreased to a critical accuracy.

8. The pruning of the neural network includes: The method of claim 1 , which terminates when the target pruning ratio is reached or when pruning for all layers of the neural network is completed.

9. providing said pruning data set; The pruned data set includes:

2. The method of claim 1, wherein the dataset is generated by randomly sampling a predetermined number of data sources for each class included in the given dataset, or the dataset is generated by selecting valid classes from the given dataset and randomly sampling a predetermined number of data sources for each selected valid class.

10. The step of providing a pruning data set comprises: randomly sampling a predetermined number of data sources from each class in the given data set; determining a label corresponding to each of the randomly selected samples by performing inference on the randomly selected samples using the neural network; determining a class having a ratio of the most frequent label that is equal to or greater than a predetermined accuracy level as a valid class among the classes included in the given data set; randomly sampling a predetermined number of data sources from each of the determined valid classes; The method of claim 9 , wherein the pruning data set is based on the predetermined number of data sources randomly sampled from the determined valid classes.

11. The method of claim 1 , further comprising pruning the neural network without retraining the neural network using the pruning data set.

12. A non-transitory computer-readable recording medium having a program recorded thereon for causing a computer to execute the method according to any one of claims 1 to 11.

13. An apparatus for pruning a neural network, comprising: Memory, At least one processor that executes a program to perform the pruning on the neural network; The at least one processor Setting a weight threshold for pruning the neural network at a target pruning ratio based on a weight distribution of layers included in the neural network; Using a pruning dataset prepared from a predetermined number of data sources randomly extracted from each class included in a given dataset, predicting the effect of pruning each layer based on the weight threshold on a change in inference accuracy of the neural network; determining a current layer to be pruned from among the layers included in the neural network based on the predicted influence using the weight threshold; Pruning the determined current target layer; The at least one processor When pruning for the current layer is completed, the apparatus iteratively performs pruning on remaining layers of the neural network.

14. The at least one processor The apparatus of claim 13 , further comprising: determining, as the currently targeted layer, a layer predicted to have the lowest sensitivity to the influence from among remaining layers in the neural network excluding previously pruned layers.

15. The at least one processor The device of claim 14 , wherein the impact is predicted by calculating a sensitivity for each layer based on a difference between an inference accuracy before pruning for each layer and an inference accuracy after pruning for each layer.

16. The layer predicted to have the lowest sensitivity is The apparatus of claim 14 , wherein the layer corresponds to a layer predicted to have the least impact on degradation of inference accuracy of the neural network.

17. The at least one processor The apparatus of claim 13 , further comprising: setting the weight threshold to a weight value corresponding to the target pruning ratio under the assumption that the weight distribution corresponds to a standard normal distribution.

18. The at least one processor 14. The apparatus of claim 13, further comprising: pruning the currently targeted layer by updating the weight threshold and adjusting a pruning ratio of weights in the currently targeted layer until an inference accuracy of the neural network on the pruned data set drops to a critical accuracy.

19. The weight threshold is updated by 20. The apparatus of claim 18, further comprising: increasing the current weight threshold if the inference accuracy of the neural network including pruned weights at the current weight threshold has not decreased to a critical accuracy.

20. The at least one processor The apparatus of claim 13 , further comprising: terminating the pruning of the neural network when the target pruning ratio is reached or pruning of all layers of the neural network is completed.

21. The pruned data set includes: The apparatus according to claim 13, wherein the dataset is generated by randomly sampling a predetermined number of data sources for each class included in the given dataset, or the dataset is generated by selecting valid classes from the given dataset and randomly sampling a predetermined number of data sources for each selected valid class.

22. The at least one processor 22. The apparatus of claim 21, wherein the pruning dataset is generated by randomly sampling a predetermined number of data source samples from each class included in the given dataset, determining labels corresponding to each sample by performing inference on the randomly selected samples using the neural network, determining a class among the classes included in the given dataset whose proportion of the most frequent labels is equal to or greater than a predetermined accuracy as a valid class, and randomly sampling a predetermined number of data sources from each of the determined valid classes.

Citation Information

Patent Citations

  • Method for optimizing hierarchical neural network and device therefor

    JP1993197821A

  • Automatic tuning of artificial neural networks

    US20160358070A1

  • Hybrid neural network pruning

    US20190362235A1