WO2019080484A1 - 基于特征图变化对卷积神经网络剪枝的方法 - Google Patents

基于特征图变化对卷积神经网络剪枝的方法

Info

Publication number
WO2019080484A1
WO2019080484A1 PCT/CN2018/087135 CN2018087135W WO2019080484A1 WO 2019080484 A1 WO2019080484 A1 WO 2019080484A1 CN 2018087135 W CN2018087135 W CN 2018087135W WO 2019080484 A1 WO2019080484 A1 WO 2019080484A1
Authority
WO
WIPO (PCT)
Prior art keywords
network
acc
filters
convolutional
filter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2018/087135
Other languages
English (en)
French (fr)
Inventor
王瑜
江帆
盛骁
韩松
单羿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Deephi Intelligent Technology Co Ltd
Original Assignee
Beijing Deephi Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Deephi Intelligent Technology Co Ltd filed Critical Beijing Deephi Intelligent Technology Co Ltd
Priority to US16/759,316 priority Critical patent/US20200311549A1/en
Publication of WO2019080484A1 publication Critical patent/WO2019080484A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/082Learning methods modifying the architecture, e.g. adding, deleting or silencing nodes or connections
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0495Quantised networks; Sparse networks; Compressed networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/09Supervised learning

Definitions

  • the present invention relates to artificial neural networks, and more particularly to pruning of convolutional neural networks based on feature map changes.
  • CNN Convolutional Neural Network
  • Common network compression techniques include pruning, quantification, distillation, and the like.
  • the method proposed by the present invention is one of the pruning techniques, and by removing some "connections" in the network, the amount of parameters and the amount of calculation required for the model can be effectively reduced.
  • the present invention provides a method of pruning a convolutional neural network based on a feature map change.
  • a method of pruning a filter in a convolutional layer based on a feature map change in a convolutional neural network wherein the i-th convolutional layer comprising n filters It is desirable to remove the m filters therein, the method comprising: (1) running a forward calculation on the original neural network model to obtain a feature map x generated by the i+kth convolution layer, where k is Any positive integer; (2) traverse all n filters in the i-th convolutional layer; (3) remove the j-th filter currently traversed, and the remaining filters are the same as the original network model, generating one a new model; (4) running a forward calculation on the new model to obtain the feature map x' generated by the i+kth convolutional layer; (5) calculating the characteristic map difference between x and x'; (6) After traversing all n filters, the n filters are sorted according to the difference of the feature maps of x and x'; (7) the
  • k 2
  • a method for network sensitivity analysis by filter pruning in a convolutional layer in a convolutional neural network comprising: testing the accuracy of the original network model using a verification data set Traversing all convolutional layers in the network except the last k convolutional layers, where k is any positive integer; running the convolutional layer currently traversed in the convolutional neural network according to the first aspect of the invention Steps (1) to (6) in the method of pruning the filter in the convolution layer based on the feature map change; each filter is sequentially removed from the filter having the smallest difference, wherein each shift After removing a filter, the network accuracy after pruning is tested until the last filter is left, and the network accuracy test result ⁇ acc 0 ,acc 1 ,acc 2 ,...,acc n-2 ⁇ is obtained; the current volume is obtained.
  • the filters removed by the layer are all restored, keeping the same as the original network; the network accuracy test results ⁇ acc 0 ,acc 1 ,acc 2 ,...,acc n-2 ⁇ are compared with the original network precision to obtain Precision difference ⁇ acc_loss 0 ,acc_loss 1 ,acc_loss 2 ,...,acc_loss_ n-2 ⁇ , the precision difference indicates the loss of network accuracy after removing the corresponding number of filters. The greater the loss of precision, the higher the sensitivity of the layer to filter removal.
  • a method of pruning a network based on sensitivity in a convolutional neural network comprising: performing convolution in a convolutional neural network according to the second aspect of the present invention Filter pruning in the layer for network sensitivity analysis; setting the model accuracy loss threshold acceptable after pruning; traversing all convolutional layers except the last k convolutional layers in the network, where k is Any positive integer, according to the sensitivity result of the convolution layer currently traversed, determining the maximum number of filters that the layer can remove without exceeding the model precision loss threshold; removing the layer according to the The minimum m filters of the feature map difference ranking; traversing all convolution layers except the last k convolution layers in the network to complete the pruning of these layers.
  • a computer readable medium for recording instructions executable by a processor, when executed by a processor, causing a processor to perform a change based on a feature map in a convolutional neural network
  • a computer readable medium for recording instructions executable by a processor, when executed by a processor, causing a processor to perform a sensitivity based pair in a convolutional neural network
  • a method for pruneting a network comprising the following operations: for the original network model, using a verification data set to test its accuracy; traversing all convolutional layers in the network except the last k convolutional layers, where k is any positive integer;
  • the currently traversed convolutional layer operates steps (1) to (6) in the method of pruning a filter in a convolutional layer based on a feature map change in a convolutional neural network according to the first aspect of the present invention.
  • a computer readable medium for recording an instruction executable by a processor when executed by a processor, causes the processor to perform convolution by convolution in a convolutional neural network
  • Method for performing network sensitivity analysis by filter pruning in a layer comprising the operation of performing network sensitivity on filter pruning in a convolutional layer in a convolutional neural network according to the fifth aspect of the present invention
  • Analytical method set the model accuracy loss threshold acceptable after pruning; traverse all convolutional layers except the last k convolutional layers in the network, where k is any positive integer, according to the current traversal convolution
  • the sensitivity result of the layer determines the maximum number of filters m that the layer can remove without exceeding the model accuracy loss threshold; removes the smallest m pieces of the layer sorted according to the feature map difference value Filter; prune the pruning of these layers after traversing all convolutional layers in the network except the last k convolutional layers.
  • the present invention achieves compression of the entire network by removing portions of the filter in the convolutional layer, a process known as pruning.
  • the main contribution of the present invention is to determine the pruning criterion of the filter in a single convolution layer according to the change of the feature map, analyze the network sensitivity by using the criterion, and finally cut the entire network according to the sensitivity of the network. branch.
  • Figure 1 is a schematic diagram of forward calculations based on the original neural network.
  • Figure 2 is a schematic diagram of the forward calculation after removing a filter.
  • FIG. 3 is a flow diagram of a method of pruning filters in a convolutional layer based on feature map changes in a convolutional neural network in accordance with the present invention.
  • FIG. 4 is a flow diagram of a method for network sensitivity analysis by filter pruning in a convolutional layer in a convolutional neural network in accordance with the present invention.
  • FIG. 5 is a flow diagram of a method of pruning a network based on sensitivity in a convolutional neural network in accordance with the present invention.
  • the Convolutional Neural Network consists mainly of a series of convolutional layer connections.
  • a convolutional layer in turn contains several filters.
  • the present invention removes some of the filters in the convolutional layer. The way to achieve compression of the entire network, this process is called pruning.
  • the main contribution of the present invention is to determine the pruning criterion of the filter in a single convolution layer according to the change of the feature map, analyze the network sensitivity by using the criterion, and finally cut the entire network according to the sensitivity of the network. branch.
  • the convolutional neural network consists of successive convolutional layer connections, which are numbered 0, 1, 2, ... in order from input to output. After the convolution layer convolves on the input data, several feature maps are generated. After the feature map is activated, pooled, etc., it enters the next convolution layer as input data. Pruning is the process of removing a portion of the filter from the convolutional layer.
  • the invention proposes a method for selecting a filter to be removed based on a feature map change value, that is, a pruning criterion.
  • the i-th convolutional layer contains n filters, and it is desirable to remove m of the filters therein.
  • the preferred embodiment determines which filters to remove by calculating the i+2th convolutional layer feature map change. The specific process is as follows:
  • Figure 1 is a schematic diagram of forward calculations based on the original neural network.
  • Figure 2 is a schematic diagram of the forward calculation after removing a filter.
  • the feature map generated by the i+2th convolution layer is recorded, and the difference is made by the difference of the feature map generated by the layer to determine the ith.
  • the order in which filters are removed from the convolutional layer can be extended to record the feature map generated by the i+kth convolution layer, and sorted by the difference of the feature map generated by the layer to determine the removal order of the filter in the i-th convolution layer.
  • k is any positive integer.
  • other spatial or conceptual differences may be used herein as long as they reflect the difference between the feature maps, which can compare the magnitude of the difference.
  • FIG. 3 is a flow diagram of a method of pruning filters in a convolutional layer based on feature map changes in a convolutional neural network in accordance with the present invention.
  • step S320 After all n filters in the i-th convolutional layer are traversed.
  • step S330 the jth filter that is currently traversed is removed, and the remaining filters are identical to the original network model to generate a new model.
  • step S340 a forward calculation is performed on the new model to obtain a feature map x' generated by the i+kth convolution layer.
  • the feature map difference values of x and x' are calculated.
  • step S360 it is judged whether or not all n filters have been traversed.
  • step S360 If the result of the determination in step S360 is negative, that is, there is a filter that has not been traversed, then return to step S320 ("NO" branch of step S360), continue to traverse the filter in the convolution layer, and execute step S330- S360.
  • step S360 determines whether all n filters have been traversed. If the result of the decision in step S360 is affirmative, that is, all n filters have been traversed, the method 300 proceeds to step S370 ("YES" branch of step S360), and n filters are followed by x and x. 'The feature map difference is sorted.
  • step S380 m filters having the smallest difference in the feature map are selected as the removed filter. Thereafter, the pruning method or pruning criterion 300 can be ended.
  • the convolutional neural network model is getting deeper and deeper and often contains a lot of convolutional layers.
  • the m filters can be selected using the pruning criteria described above.
  • the problem is that for each convolutional layer, the number of filters, the dimensions of the convolution kernel, and its location in the model are different. How to determine the number m of filters to remove each convolution layer is not an easy task.
  • the present invention utilizes the pruning criteria proposed above to perform sensitivity analysis on each convolutional layer to determine the sensitivity of each convolutional layer to filter removal, thereby providing a basis for subsequent pruning of the entire network.
  • the method of sensitivity analysis using the pruning criteria is as follows:
  • each filter is removed from the filter with the smallest diff value, and each filter is removed, and the network precision after pruning is tested until the last one remains.
  • the filter gives ⁇ acc 0 ,acc 1 ,acc 2 ,...,acc n-2 ⁇ .
  • the simplest is not to pruning, skip directly; or you can sort according to the sum of the absolute values of the weights of each filter in the convolution kernel, and decide which filters to subtract.
  • the sensitivity analysis may not be performed, that is, in the traversal process of the present invention, all the convolution layers except the last k convolution layers in the network are used; Sensitivity analysis can be performed by sorting the last k convolutional layers using other pruning criteria (such as the above-mentioned judgment of the sum of the absolute values of the weights).
  • FIG. 4 is a flow diagram of a method for network sensitivity analysis by filter pruning in a convolutional layer in a convolutional neural network in accordance with the present invention.
  • the setting in FIG. 3 is used in the method of FIG. 4: in the convolutional neural network, for the i-th convolutional layer containing n filters, it is expected Remove the m filters from it.
  • a method 400 for network sensitivity analysis of filter pruning in a convolutional layer in a convolutional neural network in accordance with the present invention begins in step S410, in which, for the original network model, Test the accuracy with a validated data set.
  • step S420 all convolutional layers except the last k convolutional layers in the network are traversed, where k is any positive integer.
  • step S430 the operations of step S310 to step S370 in the pruning method 300 in FIG. 3 are performed on the currently traversed convolutional layer. Specifically, it includes the following operations:
  • n filters are sorted according to the feature map values of x and x'.
  • each filter is sequentially removed from the filter with the smallest difference, wherein each time the filter is removed, the network precision after pruning is tested until the last one remains. Filter, get network accuracy test results ⁇ acc 0 ,acc 1 ,acc 2 ,...,acc n-2 ⁇ .
  • step S450 all the filters removed from the current convolutional layer are restored, remaining the same as the original network.
  • step S460 the network accuracy test result ⁇ acc 0 ,acc 1 ,acc 2 ,...,acc n-2 ⁇ is compared with the original network precision to obtain an accuracy difference ⁇ acc_loss 0 ,acc_loss 1 ,acc_loss 2 ,...,acc_loss_ n-2 ⁇ , the precision difference indicates the loss of network accuracy after removing the corresponding number of filters, the greater the loss of precision, indicating that the layer is removed from the filter The higher the sensitivity.
  • step S470 it is determined whether all convolutional layers have been traversed (except for the last k convolutional layers).
  • step S470 If the result of the determination in step S470 is negative, that is, there is a convolutional layer that has not been traversed, the process returns to step S420 ("NO" branch of step S470), the traversal of the convolutional layer is continued, and steps S430-S470 are performed.
  • step S470 if the result of the decision in step S470 is affirmative, that is, all convolutional layers have been traversed (except for the last k convolutional layers), the method 400 may end.
  • the simplest is not to pruning, skip directly; or you can sort according to the sum of the absolute values of the weights of each filter in the convolution kernel, and decide which filters to subtract.
  • the sensitivity analysis may not be performed, that is, in the traversal process of the present invention, all the volumes except the last k convolutional layers in the network are targeted.
  • you can use other pruning criteria such as the above-mentioned judgment of the sum of the absolute values of weights) for the last k convolutional layers for sensitivity analysis and pruning, or directly Pruning.
  • FIG. 5 is a flow diagram of a method of pruning a network based on sensitivity in a convolutional neural network in accordance with the present invention.
  • FIG. 3 Since it is a general method and refers to the steps in FIG. 4 and FIG. 4 refers to the partial steps in FIG. 3, the setting in FIG. 3 is used in the method of FIG. 5: in the convolutional neural network, for n filters The ith convolutional layer of the device is expected to remove the m filters.
  • a method 500 for pruning a network based on sensitivity in a convolutional neural network in accordance with the present invention begins in step S510, in which step 4 is performed in a convolutional neural network of FIG.
  • a method 400 of filter prune in the stack for network sensitivity analysis That is, in step S510, all the steps in the method 400 are performed: step S410 to step S470.
  • step S520 a model accuracy loss threshold acceptable after pruning is set.
  • step S530 all convolutional layers in the network except the last k convolutional layers are traversed, where k is any positive integer.
  • step S540 based on the sensitivity result of the convolution layer currently traversed, the maximum number m of filters that can be removed by the layer without exceeding the model accuracy loss threshold is determined.
  • step S550 the smallest m filters sorted by the layer according to the feature map difference value are removed.
  • step S560 it is determined whether all convolutional layers have been traversed (except for the last k convolutional layers).
  • step S560 If the result of the determination in step S560 is negative, that is, there is a convolutional layer that has not been traversed, the flow returns to step S530 ("NO" branch of step S470), the traversal of the convolutional layer is continued, and steps S540-S560 are performed.
  • step S560 if the result of the decision in step S560 is affirmative, that is, all convolutional layers have been traversed (except for the last k convolutional layers), pruning of these layers has been completed, that is, the method 500 ends.
  • Non-transitory computer readable media include various types of tangible storage media.
  • non-transitory computer readable medium examples include magnetic recording media (such as floppy disks, magnetic tapes, and hard disk drives), magneto-optical recording media (such as magneto-optical disks), CD-ROM (Compact Disc Read Only Memory), CD-R, CD-R /W and semiconductor memory (such as ROM, PROM (programmable ROM), EPROM (rewritable PROM), flash ROM and RAM (random access memory)).
  • these programs can be provided to a computer by using various types of transient computer readable media.
  • Examples of transitory computer readable media include electrical signals, optical signals, and electromagnetic waves. The transitory computer readable medium can be used to provide a program to a computer via a wired communication path such as a wire and an optical fiber or a wireless communication path.
  • a computer program or a computer readable medium for recording instructions executable by a processor that, when executed by a processor, causes the processor to execute on a convolutional neural network A method for pruning a filter in a convolution layer based on a feature map change, wherein for the i-th convolution layer including n filters, it is desirable to remove m filters therein, including the following operations: (1) Run a forward calculation on the original neural network model to obtain the feature map x generated by the i+kth convolutional layer, where k is any positive integer; (2) traverse all of the i-th convolutional layer n filters; (3) remove the jth filter currently traversed, the remaining filters are the same as the original network model, generate a new model; (4) run a forward calculation on the new model, Obtaining the feature map x' generated by the i+kth convolution layer; (5) calculating the feature map difference between x and x'; (6) after traversing all n filters, n
  • a computer program or a computer readable medium for recording instructions executable by a processor when executed by a processor, causes the processor to execute on a convolutional neural network
  • a method for pruning a network based on sensitivity comprising the following operations: for the original network model, using a verification data set to test its accuracy; traversing all convolutional layers in the network except the last k convolutional layers, where k is Any positive integer; step (1) to (in the method of pruning the filter in the convolutional layer based on the feature map change in the convolutional neural network according to the present invention for the currently traversed convolutional layer 6) removing each filter in turn from the filter with the smallest difference, wherein each time the filter is removed, the network precision after pruning is tested until the last filter remains, Network accuracy test results ⁇ acc 0 ,acc 1 ,acc 2 ,...,acc n-2 ⁇ ; all filters removed from the current convolutional layer are restored, remaining the same as the original network; If ⁇ acc 0
  • a computer program or a computer readable medium for recording instructions executable by a processor when executed by a processor, causes the processor to execute on a convolutional neural network
  • a method for network sensitivity analysis by filter pruning in a convolutional layer comprising: performing a network for filtering pruning in a convolutional layer in a convolutional neural network according to the present invention Sensitivity analysis method; setting the model accuracy loss threshold acceptable after pruning; traversing all convolutional layers except the last k convolutional layers in the network, where k is any positive integer, according to the current traversal
  • the result of the sensitivity of the convolutional layer determines the maximum number of filters m that can be removed by the layer without exceeding the threshold of the accuracy loss of the model; removes the smallest of the layers sorted according to the difference of the characteristic maps m filters; prune the pruning of these layers after traversing all convolutional layers in the network except the last k convolutional layers.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

本公开提供一种基于特征图变化对卷积神经网络剪枝的方法。本发明通过将卷积层中的部分过滤器去除的方式实现了对整个网络的压缩,这一过程称为剪枝。本发明主要贡献是根据特征图的变化情况确定单个卷积层中过滤器的剪枝准则,利用该准则对网络敏感度进行分析,并最终根据网络的敏感度对整个网络进行剪枝。

Description

基于特征图变化对卷积神经网络剪枝的方法 技术领域
本发明涉及人工神经网络,更具体涉及基于特征图变化对卷积神经网络剪枝。
背景技术
近年来,随着深度学习(Deep Learning)技术的发展,人工神经网络(Artificial Neural Networks,ANN)被应用在越来越多的领域。卷积神经网络(Convolution Neural Network,CNN)是其中具有代表性的一种网络结构,它在图像处理、语音识别、自然语言处理等领域都有应用。特别是在图像处理方面,得益于网络结构的不断加深,卷积神经网络取得了很大的成功。与此同时,不断加深的网络也使得网络的训练和推理所需的计算资源也成倍的增加,这极大的限制了卷积神经网络的应用场景。
于是,针对神经网络进行压缩的相关技术变得越来越重要。常见的网络压缩技术包括剪枝(pruning)、量化(quantization)、蒸馏(distilling)等。
发明内容
本发明所提出的方法是剪枝技术的一种,通过将网络中的某些“连接”去除,可以有效地减少模型所需的参数量和计算量。
本发明提供一种基于特征图变化对卷积神经网络剪枝的方法。
根据本发明的第一方面,提供一种在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法,其中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器,所述方法包括:(1)对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数;(2)遍历第i个卷积层中的所有n个过滤器;(3)将当前遍历 到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型;(4)在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’;(5)计算x与x’的特征图差值;(6)遍历所有n个过滤器之后,将n个过滤器按照x与x’的特征图差值进行排序;(7)选取所述特征图差值最小的m个过滤器作为移除掉的过滤器。
优选地,k=2。
优选地,所述的x与x’的特征图差值是x与x’的特征图差值的L2范数,记为diff j=||x-x′|| 2
根据本发明的第二方面,提供一种在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法,包括:对于原始网络模型,使用验证数据集测试其精度;遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数;对当前遍历到的卷积层运行根据本发明第一方面所述的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法中的步骤(1)至(6);从所述差值最小的过滤器开始依次移除每个过滤器,其中,每移除掉一个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2};将当前卷积层移除掉的过滤器全部恢复,保持与原始网络相同;将所述网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2}与原始网络精度做差值,得到精度差值{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该精度差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤器移除的敏感度越高。
根据本发明的第三方面,提供一种在卷积神经网络中基于敏感度对网络进行剪枝的方法,包括:执行根据本发明第二方面所述的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法;设定剪枝后所能接受的模型精度损失阈值;遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数,根据当前遍历到的卷积层的敏感度结果,确定在不超 过所述模型精度损失阈值情况下该层所能移除的最大过滤器个数m;移除掉该层按照所述特征图差值排序的最小的m个过滤器;遍历网络中除最后k个卷积层之外的所有卷积层后完成对这些层的剪枝。
根据本发明的第四方面,提供一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法,其中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器,包括如下操作:(1)对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数;(2)遍历第i个卷积层中的所有n个过滤器;(3)将当前遍历到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型;(4)在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’;(5)计算x与x’的特征图差值;(6)遍历所有n个过滤器之后,将n个过滤器按照x与x’的特征图差值进行排序;(7)选取所述特征图差值最小的m个过滤器作为移除掉的过滤器。
根据本发明的第五方面,提供一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中基于敏感度对网络进行剪枝的方法,包括如下操作:对于原始网络模型,使用验证数据集测试其精度;遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数;对当前遍历到的卷积层运行根据本发明第一方面所述的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法中的步骤(1)至(6);从所述差值最小的过滤器开始依次移除每个过滤器,其中,每移除掉一个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2};将当前卷积层移除掉的过滤器全部恢复,保持与原始网络相同;将所述网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2}与原始网络精度做差值,得到精度差值{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该精度差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤器移除的敏感度越高。
根据本发明的第六方面,提供一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法,包括如下操作:执行根据本发明第五方面所述的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法;设定剪枝后所能接受的模型精度损失阈值;遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数,根据当前遍历到的卷积层的敏感度结果,确定在不超过所述模型精度损失阈值情况下该层所能移除的最大过滤器个数m;移除掉该层按照所述特征图差值排序的最小的m个过滤器;遍历网络中除最后k个卷积层之外的所有卷积层后完成对这些层的剪枝。
本发明通过将卷积层中的部分过滤器去除的方式实现了对整个网络的压缩,这一过程称为剪枝(pruning)。本发明主要贡献是根据特征图(feature map)的变化情况确定单个卷积层中过滤器的剪枝准则,利用该准则对网络敏感度进行分析,并最终根据网络的敏感度对整个网络进行剪枝。
附图说明
下面参考附图结合实施例说明本发明。在附图中:
图1是根据原始的神经网络进行前向计算的示意图。
图2是在移除一个过滤器之后进行前向计算的示意图。
图3是根据本发明的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法的流程图。
图4是根据本发明的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法的流程图。
图5是根据本发明的在卷积神经网络中基于敏感度对网络进行剪枝的方法的流程图。
具体实施方式
附图仅用于示例说明,不能理解为对本发明的限制。下面结合附图和实施例对本发明的技术方案做进一步的说明。
卷积神经网络(Convolution Neural Network,CNN)主要由一系列的卷积层连接组成,一个卷积层又包含了若干过滤器(filter),本发明通过将卷积层中的部分过滤器去除的方式实现了对整个网络的压缩,这一过程称为剪枝(pruning)。本发明主要贡献是根据特征图(feature map)的变化情况确定单个卷积层中过滤器的剪枝准则,利用该准则对网络敏感度进行分析,并最终根据网络的敏感度对整个网络进行剪枝。
基于特征图变化的剪枝准则
卷积神经网络是由连续的卷积层连接组成的,根据输入到输出的顺序依次将它们编号为0、1、2、…。卷积层对输入数据做卷积操作后生成若干个特征图,特征图经过激活、池化等操作后作为输入数据进入下一个卷积层。剪枝就是对卷积层一部分过滤器移除的过程。本发明提出了一种基于特征图变化值来选取待移除过滤器的方法,即剪枝准则。
根据本发明的一个优选实施例,假设第i个卷积层包含n个过滤器,期望移除掉其中的m个过滤器。本优选实施例通过计算第i+2个卷积层特征图变化来确定对哪些过滤器进行移除操作。具体过程如下:
1、对原始的神经网络模型运行一次前向计算,保存下第i+2个卷积层生成的特征图,记为x,如图1所示。图1是根据原始的神经网络进行前向计算的示意图。
2、遍历第i个卷积层中的过滤器,将当前遍历到第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型。
3、在新模型上运行一次前向计算,得到第i+2个卷积层生成的特征图,记为x’,如图2所示。图2是在移除一个过滤器之后进行前向计算的示意图。
4、计算x与x’差值的L2范数(L2Norm),即diff j=||x-x′|| 2
5、循环执行步骤2-4,直到该层所有过滤器都完成遍历。
6、对过滤器按照diff值排序。
7、选取diff值最小的m个过滤器作为最终需要移除的过滤器。
值得本领域技术人员注意的是,尽管在上述优选实施例中,是记录第i+2个卷积层生成的特征图,并通过该层生成的特征图的差值来排序以决定第i个卷积层中过滤器的移除顺序。然而,其方法可以推广到记录第i+k个卷积层生成的特征图,并通过该层生成的特征图的差值来排序以决定第i个卷积层中过滤器的移除顺序,其中k为任意正整数。然而,在实现过程中,本领域技术人员肯定能找出一个合适的k值(例如在优选实施例中k=2)使得由此计算出的差值能够最好地反映出过滤器的重要程度,以及后文将提及的敏感度。
此外,在计算x与x’差值时,上述的优选实施例使用了L2范数,即diff j=||x-x′|| 2。然而,本领域技术人员应当理解,这里也可以使用其他空间或概念上的差值,只要其能否反映出特征图之间的差异,其能够比较得出该差异的大小。
基于以上优选实施例,下文将描述根据本发明的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法。
图3是根据本发明的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法的流程图。
由于是通用方法,在图3的方法中进行如下的设定:在卷积神经网络中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器。
如图3中所示,根据本发明的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法300开始于步骤S310,在此步骤,对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数。如前文所述,这里的k值,在优选实施例中,可以取k=2。
接下来,从步骤S320开始,遍历第i个卷积层中的所有n个过滤器。
在步骤S330,将当前遍历到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型。
接下来,在步骤S340,在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’。
在步骤S350,计算x与x’的特征图差值。在本发明的优选实施例中,这里的x与x’的特征图差值是指x与x’的特征图差值的L2范数,记为diff j=||x-x′|| 2
在步骤S360,判断是否已遍历所有n个过滤器。
如果步骤S360的判断结果是否定的,即还有未遍历到的过滤器,则返回步骤S320(步骤S360的“否”分支),继续遍历该卷积层中的过滤器,并执行步骤S330-S360。
另一方面,如果步骤S360的判断结果是肯定的,即已遍历完所有n个过滤器,则方法300前进到步骤S370(步骤S360的“是”分支),将n个过滤器按照x与x’的特征图差值进行排序。
最后,在步骤S380,选取所述特征图差值最小的m个过滤器作为移除掉的过滤器。之后,该剪枝方法或剪枝准则300即可结束。
使用剪枝准则进行敏感度分析
现在卷积神经网络模型越来越深,往往包含了非常多的卷积层。对卷积层来说,给定期望移除的过滤器个数m,利用上述的剪枝准则可以选取出这m个过滤器。问题在于,对于每个卷积层,其过滤器的个数、卷积核的维度以及其在模型中所处的位置,均不相同。如何确定每个卷积层所需移除过滤器的个数m,并不是一件容易的事。本发明利用上文提出的剪枝准则对每个 卷积层进行敏感度分析,以此来确定每个卷积层对过滤器移除的敏感程度,从而为后续整个网络的剪枝提供依据。
根据本发明的一个优选实施例,利用剪枝准则进行敏感度分析的方法如下:
1、对原始网络模型,使用验证数据集测试其精度。
2、遍历网络中的每一个卷积层,对当前遍历到的卷积层运行上文描述的剪枝准则步骤1-6,即图3的方法300中的步骤S310-S370,也就是最终选取剪枝对象之前所有步骤。
3、按照排序后的过滤器diff值,从diff值最小的过滤器开始依次移除每个过滤器,每移除掉一个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到{acc 0,acc 1,acc 2,…,acc n-2}。
4、将当前层移除掉的过滤器全部恢复,保持与原始网络相同。
5、将每次移除掉过滤器后网络的精度{acc 0,acc 1,acc 2,…,acc n-2}与原始网络精度做差值,得到{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤器移除的敏感度越高。
6、重复本方法的步骤2-4直到网络中所有卷积层遍历完成。
这里需要说明的是,由于在本发明的剪枝准则中,在考虑第i个卷积层的过滤器的剪枝时,需要得到第i+k个卷积层(在本发明的优选实施例中,k=2)。所以,在进行敏感度分析时,对于最后的k个卷积层,无法使用本发明的剪枝准则进行敏感度分析,因为此时不存在第i+k个卷积层了。在这种情况下,对于卷积层的剪枝方法而言,可以根据具体情况在实践中可以有不同的做法。比如最简单的是不进行剪枝,直接跳过;也可以根据卷积核中每一个过滤器本身的权重绝对值之和来排序,决定减去哪些过滤器。对于敏感度分析的方法而言,则可以不做其敏感度分析,即在本发明的遍历过程中,针对的是网络中除最后k个卷积层之外的所有卷积层;另一方面,可以针对最后k个卷积层使用其他剪枝准则(例如上面提到的用权重绝对值之和进行判断)进行排序,从而进行敏感度分析。
基于以上优选实施例,下文将描述根据本发明的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法。
图4是根据本发明的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法的流程图。
由于是通用方法且引用图3中的部分步骤,因此在图4的方法中沿用图3中的设定:在卷积神经网络中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器。
如图4中所示,根据本发明的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法400开始于步骤S410,在此步骤,对于原始网络模型,使用验证数据集测试其精度。
接下来,从步骤S420开始,遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数。
在步骤S430,对当前遍历到的卷积层运行图3中的剪枝方法300中的步骤S310至步骤S370的操作。具体地说,包括如下操作:
(1)对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数;
(2)遍历第i个卷积层中的所有n个过滤器;
(3)将当前遍历到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型;
(4)在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’;
(5)计算x与x’的特征图差值;
(6)遍历所有n个过滤器之后,将n个过滤器按照x与x’的特征图差值进行排序。
接下来,在步骤S440,从所述差值最小的过滤器开始依次移除每个过 滤器,其中,每移除掉一个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2}。
然后,在步骤S450,将当前卷积层移除掉的过滤器全部恢复,保持与原始网络相同。
根据本发明的方法400,在步骤S460,将所述网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2}与原始网络精度做差值,得到精度差值{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该精度差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤器移除的敏感度越高。
最后在步骤S470,判断是否已遍历所有卷积层(除最后k个卷积层之外)。
如果步骤S470的判断结果是否定的,即还有未遍历到的卷积层,则返回步骤S420(步骤S470的“否”分支),继续遍历卷积层,并执行步骤S430-S470。
另一方面,如果步骤S470的判断结果是肯定的,即已遍历完所有卷积层(除最后k个卷积层之外),则方法400即可结束。
基于敏感度结果对网络剪枝
得到了敏感度结果,就可以知道每个卷积层对过滤器移除的敏感程度。对于敏感度较低的卷积层,可以移除较多的过滤器;对于敏感度较高的层,就移除较少的过滤器或者不移除过滤器。本文基于剪枝后所能接受的精度损失计算出每个卷积层需要移除的过滤器个数从而实现对整个网络的剪枝。具体如下:
1、运行上文描述的敏感度分析方法。
2、设定剪枝后所能接受的模型精度损失。
3、遍历每个卷积层,根据该层的敏感度结果,找到在不超过精度损失 的情况下该层所能移除的最大过滤器个数m。
4、移除掉该层按照diff值排序的前m个过滤器。
5、重复本方法的步骤3-4直到所有的卷积层都完成剪枝。
如前所述,这里同样需要说明的是,由于在本发明的剪枝准则中,在考虑第i个卷积层的过滤器的剪枝时,需要得到第i+k个卷积层(在本发明的优选实施例中,k=2)。所以,在进行基于敏感度结果对网络剪枝的过程中,对于最后的k个卷积层,无法使用本发明的剪枝准则进行敏感度分析,因为此时不存在第i+k个卷积层了。在这种情况下,对于卷积层的剪枝方法而言,可以根据具体情况在实践中可以有不同的做法。比如最简单的是不进行剪枝,直接跳过;也可以根据卷积核中每一个过滤器本身的权重绝对值之和来排序,决定减去哪些过滤器。对于基于敏感度结果而对网络剪枝的方法而言,则可以不做其敏感度分析,即在本发明的遍历过程中,针对的是网络中除最后k个卷积层之外的所有卷积层;另一方面,可以针对最后k个卷积层使用其他剪枝准则(例如上面提到的用权重绝对值之和进行判断)进行排序,从而进行敏感度分析以及剪枝,或直接进行剪枝。
基于以上优选实施例,下文将描述根据本发明的在卷积神经网络中基于敏感度对网络进行剪枝的方法。
图5是根据本发明的在卷积神经网络中基于敏感度对网络进行剪枝的方法的流程图。
由于是通用方法且引用图4中的步骤而图4引用了图3中的部分步骤,因此在图5的方法中沿用图3中的设定:在卷积神经网络中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器。
如图5中所示,根据本发明的在卷积神经网络中基于敏感度对网络进行剪枝的方法500开始于步骤S510,在此步骤,执行图4的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法400。即,在步骤S510,执行方法400中的所有步骤:步骤S410至步骤S470。
接下来,在步骤S520,设定剪枝后所能接受的模型精度损失阈值。
从步骤S530开始,遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数。
在步骤S540,根据当前遍历到的卷积层的敏感度结果,确定在不超过所述模型精度损失阈值情况下该层所能移除的最大过滤器个数m。
然后,在步骤S550,移除掉该层按照所述特征图差值排序的最小的m个过滤器。
最后在步骤S560,判断是否已遍历所有卷积层(除最后k个卷积层之外)。
如果步骤S560的判断结果是否定的,即还有未遍历到的卷积层,则返回步骤S530(步骤S470的“否”分支),继续遍历卷积层,并执行步骤S540-S560。
另一方面,如果步骤S560的判断结果是肯定的,即已遍历完所有卷积层(除最后k个卷积层之外),则已完成对这些层的剪枝,即方法500结束。
本领域普通技术人员应该认识到,本发明的方法可以实现为计算机程序。如上结合图3所述,根据上述实施例的方法可以执行一个或多个程序,包括指令来使得计算机或处理器执行结合附图所述的算法。这些程序可以使用各种类型的非瞬时计算机可读介质存储并提供给计算机或处理器。非瞬时计算机可读介质包括各种类型的有形存贮介质。非瞬时计算机可读介质的示例包括磁性记录介质(诸如软盘、磁带和硬盘驱动器)、磁光记录介质(诸如磁光盘)、CD-ROM(紧凑盘只读存储器)、CD-R、CD-R/W以及半导体存储器(诸如ROM、PROM(可编程ROM)、EPROM(可擦写PROM)、闪存ROM和RAM(随机存取存储器))。进一步,这些程序可以通过使用各种类型的 瞬时计算机可读介质而提供给计算机。瞬时计算机可读介质的示例包括电信号、光信号和电磁波。瞬时计算机可读介质可以用于通过诸如电线和光纤的有线通信路径或无线通信路径提供程序给计算机。
因此,根据本发明,还可以提议一种计算机程序或一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法,其中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器,包括如下操作:(1)对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数;(2)遍历第i个卷积层中的所有n个过滤器;(3)将当前遍历到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型;(4)在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’;(5)计算x与x’的特征图差值;(6)遍历所有n个过滤器之后,将n个过滤器按照x与x’的特征图差值进行排序;(7)选取所述特征图差值最小的m个过滤器作为移除掉的过滤器。
此外,根据本发明,还可以提议一种计算机程序或一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中基于敏感度对网络进行剪枝的方法,包括如下操作:对于原始网络模型,使用验证数据集测试其精度;遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数;对当前遍历到的卷积层运行根据本发明所述的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法中的步骤(1)至(6);从所述差值最小的过滤器开始依次移除每个过滤器,其中,每移除掉一个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2};将当前卷积层移除掉的过滤器全部恢复,保持与原始网络相同;将所述网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2}与原始网络精度做差值,得到精度差值{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该精度差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤 器移除的敏感度越高。
另外,根据本发明,还可以提议一种计算机程序或一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法,包括如下操作:执行根据本发明所述的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法;设定剪枝后所能接受的模型精度损失阈值;遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数,根据当前遍历到的卷积层的敏感度结果,确定在不超过所述模型精度损失阈值情况下该层所能移除的最大过滤器个数m;移除掉该层按照所述特征图差值排序的最小的m个过滤器;遍历网络中除最后k个卷积层之外的所有卷积层后完成对这些层的剪枝。
上面已经描述了本发明的各种实施例和实施情形。但是,本发明的精神和范围不限于此。本领域技术人员将能够根据本发明的教导而做出更多的应用,而这些应用都在本发明的范围之内。
也就是说,本发明的上述实施例仅仅是为清楚说明本发明所做的举例,而非对本发明实施方式的限定。对于所属领域的普通技术人员来说,在上述说明的基础上还可以做出其他不同形式的变化或变动。这里无需也无法对所有的实施方式予以穷举。凡在本发明的精神和原则之内所作的任何修改、替换或改进等,均应包含在本发明权利要求的保护范围之内。

Claims (8)

  1. 一种在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法,其中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器,所述方法包括:
    (1)对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数;
    (2)遍历第i个卷积层中的所有n个过滤器;
    (3)将当前遍历到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型;
    (4)在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’;
    (5)计算x与x’的特征图差值;
    (6)遍历所有n个过滤器之后,将n个过滤器按照x与x’的特征图差值进行排序;
    (7)选取所述特征图差值最小的m个过滤器作为移除掉的过滤器。
  2. 根据权利要求1所述的方法,其中,k=2。
  3. 根据权利要求1或2所述的方法,其中,所述的x与x’的特征图差值是x与x’的特征图差值的L2范数,记为diff j=||x-x′|| 2
  4. 一种在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法,包括:
    对于原始网络模型,使用验证数据集测试其精度;
    遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数;
    对当前遍历到的卷积层运行权利要求1-3中任意一项所述的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法中的步骤(1)至(6);
    从所述差值最小的过滤器开始依次移除每个过滤器,其中,每移除掉一 个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2};
    将当前卷积层移除掉的过滤器全部恢复,保持与原始网络相同;
    将所述网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-1}与原始网络精度做差值,得到精度差值{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该精度差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤器移除的敏感度越高。
  5. 一种在卷积神经网络中基于敏感度对网络进行剪枝的方法,包括:
    执行根据权利要求4所述的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法;
    设定剪枝后所能接受的模型精度损失阈值;
    遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数,根据当前遍历到的卷积层的敏感度结果,确定在不超过所述模型精度损失阈值情况下该层所能移除的最大过滤器个数m;
    移除掉该层按照所述特征图差值排序的最小的m个过滤器;
    遍历网络中除最后k个卷积层之外的所有卷积层后完成对这些层的剪枝。
  6. 一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法,其中,对于包含n个过滤器的第i个卷积层,期望移除掉其中的m个过滤器,包括如下操作:
    (1)对原始的神经网络模型运行一次前向计算,得到第i+k个卷积层生成的特征图x,其中k为任意正整数;
    (2)遍历第i个卷积层中的所有n个过滤器;
    (3)将当前遍历到的第j个过滤器移除掉,其余过滤器与原始网络模型相同,生成一个新的模型;
    (4)在新模型上运行一次前向计算,得到第i+k个卷积层生成的特征图x’;
    (5)计算x与x’的特征图差值;
    (6)遍历所有n个过滤器之后,将n个过滤器按照x与x’的特征图差值进行排序;
    (7)选取所述特征图差值最小的m个过滤器作为移除掉的过滤器。
  7. 一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中基于敏感度对网络进行剪枝的方法,包括如下操作:
    对于原始网络模型,使用验证数据集测试其精度;
    遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数;
    对当前遍历到的卷积层运行权利要求1-3中任意一项所述的在卷积神经网络中基于特征图变化对卷积层中的过滤器进行剪枝的方法中的步骤(1)至(6);
    从所述差值最小的过滤器开始依次移除每个过滤器,其中,每移除掉一个过滤器,就对剪枝后的网络精度进行测试,直到剩余最后一个过滤器,得到网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2};
    将当前卷积层移除掉的过滤器全部恢复,保持与原始网络相同;
    将所述网络精度测试结果{acc 0,acc 1,acc 2,…,acc n-2}与原始网络精度做差值,得到精度差值{acc_loss 0,acc_loss 1,acc_loss 2,…,acc_loss_ n-2},该精度差值表明了移除相应个数的过滤器后网络精度的损失情况,精度损失越大,说明该层对过滤器移除的敏感度越高。
  8. 一种计算机可读介质,用于记录可由处理器执行的指令,所述指令在被处理器执行时,使得处理器执行在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法,包括如下操作:
    执行根据权利要求4所述的在卷积神经网络中通过对卷积层中的过滤器剪枝进行网络敏感度分析的方法;
    设定剪枝后所能接受的模型精度损失阈值;
    遍历网络中除最后k个卷积层之外的所有卷积层,其中k为任意正整数,根据当前遍历到的卷积层的敏感度结果,确定在不超过所述模型精度损失阈值情况下该层所能移除的最大过滤器个数m;
    移除掉该层按照所述特征图差值排序的最小的m个过滤器;
    遍历网络中除最后k个卷积层之外的所有卷积层后完成对这些层的剪枝。
PCT/CN2018/087135 2017-10-26 2018-05-16 基于特征图变化对卷积神经网络剪枝的方法 Ceased WO2019080484A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/759,316 US20200311549A1 (en) 2017-10-26 2018-05-16 Method of pruning convolutional neural network based on feature map variation

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711011383.2A CN109711528A (zh) 2017-10-26 2017-10-26 基于特征图变化对卷积神经网络剪枝的方法
CN201711011383.2 2017-10-26

Publications (1)

Publication Number Publication Date
WO2019080484A1 true WO2019080484A1 (zh) 2019-05-02

Family

ID=66247012

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/087135 Ceased WO2019080484A1 (zh) 2017-10-26 2018-05-16 基于特征图变化对卷积神经网络剪枝的方法

Country Status (3)

Country Link
US (1) US20200311549A1 (zh)
CN (1) CN109711528A (zh)
WO (1) WO2019080484A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263628A (zh) * 2019-05-09 2019-09-20 杭州飞步科技有限公司 障碍物检测方法、装置、电子设备以及存储介质
CN110276450A (zh) * 2019-06-25 2019-09-24 交叉信息核心技术研究院(西安)有限公司 基于多粒度的深度神经网络结构化稀疏系统和方法
CN114723016A (zh) * 2022-04-26 2022-07-08 中南大学 片上光子卷积神经网络及其构建方法

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11488019B2 (en) * 2018-06-03 2022-11-01 Kneron (Taiwan) Co., Ltd. Lossless model compression by batch normalization layer pruning in deep neural networks
US11580399B2 (en) * 2019-04-30 2023-02-14 Samsung Electronics Co., Ltd. System and method for convolutional layer structure for neural networks
CN110619385B (zh) * 2019-08-31 2022-07-29 电子科技大学 基于多级剪枝的结构化网络模型压缩加速方法
CN110874631B (zh) * 2020-01-20 2020-06-16 浙江大学 一种基于特征图稀疏化的卷积神经网络剪枝方法
US11568248B2 (en) * 2020-03-31 2023-01-31 Ati Technologies Ulc Feature reordering based on similarity for improved memory compression transfers during machine learning jobs
US11657285B2 (en) * 2020-07-30 2023-05-23 Xfusion Digital Technologies Co., Ltd. Methods, systems, and media for random semi-structured row-wise pruning in neural networks
CN112132062B (zh) * 2020-09-25 2021-06-29 中南大学 一种基于剪枝压缩神经网络的遥感图像分类方法
CN114492783B (zh) * 2020-10-26 2025-09-23 超星未来极挚(上海)科技有限公司 一种多任务神经网络模型的剪枝方法及装置
CN112734036B (zh) * 2021-01-14 2023-06-02 西安电子科技大学 基于剪枝卷积神经网络的目标检测方法
CN112950591B (zh) * 2021-03-04 2022-10-11 鲁东大学 用于卷积神经网络的滤波器裁剪方法及贝类自动分类系统
WO2022198606A1 (zh) * 2021-03-26 2022-09-29 深圳市大疆创新科技有限公司 深度学习模型的获取方法、系统、装置及存储介质
CN113033675B (zh) * 2021-03-30 2022-07-01 长沙理工大学 图像分类方法、装置和计算机设备
CN115205170A (zh) * 2021-04-09 2022-10-18 Oppo广东移动通信有限公司 图像处理方法、装置、存储介质及电子设备
CN114330690B (zh) * 2021-12-30 2025-05-27 以萨技术股份有限公司 卷积神经网络压缩方法、装置及电子设备
CN114757350B (zh) * 2022-04-22 2024-09-27 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室) 一种基于强化学习的卷积网络通道裁剪方法及系统
CN116757263B (zh) * 2023-05-10 2025-07-25 江南大学 一种基于特征图通道间距离的滤波器修剪方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102054028A (zh) * 2010-12-10 2011-05-11 黄斌 具备页面渲染功能的网络爬虫系统及其实现方法
CN105930723A (zh) * 2016-04-20 2016-09-07 福州大学 一种基于特征选择的入侵检测方法
CN107066553A (zh) * 2017-03-24 2017-08-18 北京工业大学 一种基于卷积神经网络与随机森林的短文本分类方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102054028A (zh) * 2010-12-10 2011-05-11 黄斌 具备页面渲染功能的网络爬虫系统及其实现方法
CN105930723A (zh) * 2016-04-20 2016-09-07 福州大学 一种基于特征选择的入侵检测方法
CN107066553A (zh) * 2017-03-24 2017-08-18 北京工业大学 一种基于卷积神经网络与随机森林的短文本分类方法

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263628A (zh) * 2019-05-09 2019-09-20 杭州飞步科技有限公司 障碍物检测方法、装置、电子设备以及存储介质
CN110263628B (zh) * 2019-05-09 2021-11-23 杭州飞步科技有限公司 障碍物检测方法、装置、电子设备以及存储介质
CN110276450A (zh) * 2019-06-25 2019-09-24 交叉信息核心技术研究院(西安)有限公司 基于多粒度的深度神经网络结构化稀疏系统和方法
CN114723016A (zh) * 2022-04-26 2022-07-08 中南大学 片上光子卷积神经网络及其构建方法

Also Published As

Publication number Publication date
US20200311549A1 (en) 2020-10-01
CN109711528A (zh) 2019-05-03

Similar Documents

Publication Publication Date Title
WO2019080484A1 (zh) 基于特征图变化对卷积神经网络剪枝的方法
CN111145737B (zh) 语音测试方法、装置和电子设备
KR102921852B1 (ko) 표적 검출 모델의 자동 모델링 방법 및 장치
KR102281676B1 (ko) 파형 음원 신호를 분석하는 신경망 모델에 기반한 음원 분류 방법 및 분석장치
CN117373487B (zh) 基于音频的设备故障检测方法、装置及相关设备
KR102189811B1 (ko) 멀티 홉 이웃을 이용한 컨볼루션 학습 기반의 지식 그래프 완성 방법 및 장치
CN110797031A (zh) 语音变音检测方法、系统、移动终端及存储介质
CN114446284B (zh) 说话人日志生成方法、装置、计算机设备及可读存储介质
CN113744721A (zh) 模型训练方法、音频处理方法、设备及可读存储介质
CN111488990B (zh) 一种基于性能感知的模型裁剪方法、装置、设备和介质
CN116840743A (zh) 电力变压器故障处理方法、装置、电子设备及存储介质
JPS59121100A (ja) 連続音声認識装置
CN112395273A (zh) 一种数据处理方法及装置、存储介质
CN113420178B (zh) 一种数据处理方法以及设备
CN119669428A (zh) 融合知识图谱和大模型的智能问答方法、装置及存储介质
CN111951812A (zh) 一种动物情感识别方法、装置及电子设备
CN117765976A (zh) 歌曲鉴别方法、计算机设备和存储介质
CN117809118A (zh) 一种基于深度学习的视觉感知识别方法、设备及介质
KR100770895B1 (ko) 음성 신호 분리 시스템 및 그 방법
CN114387991B (zh) 用于识别野外环境音的音频数据处理方法、设备及介质
CN114548307A (zh) 分类模型训练方法和装置、分类方法和装置
CN119293162A (zh) 模型训练方法、信息处理方法、装置、电子设备、存储介质及计算机程序产品
CN114397306B (zh) 一种电网均压环超复杂类别缺陷多阶段模型联合检测方法
CN120220656A (zh) 语音识别方法、装置、设备及计算机可读存储介质
JP2023094073A (ja) ニューラルネットワーク最適化方法、プログラム、および機械学習装置

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18871236

Country of ref document: EP

Kind code of ref document: A1