Method and apparatus for compressing a classification neural network

By optimizing the channel preservation strategy in the convolutional layer and using feature map metrics to update the pruning scheme, the problem of excessive neural network computational resources is solved, enabling effective deployment on devices with limited computing resources.

CN115879531BActive Publication Date: 2026-01-13BEIJING VOYAGER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111146344.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2026-01-13
Estimated Expiration
2041-09-28

AI Technical Summary

Technical Problem

Existing neural network models require excessive computing resources due to the increase in layers, making them difficult to deploy on devices with limited computing resources.

Method used

By obtaining candidate pruning schemes for convolutional layers, using neural networks to process samples to determine feature maps, and updating the pruning schemes based on the first and second metrics of the feature maps to determine the target pruning scheme, the influence between channels is considered collaboratively to optimize the channel preservation strategy.

Benefits of technology

Effectively compress neural network models, reduce computing resource requirements, improve the scalability of neural networks, and enable them to be deployed on devices with limited computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115879531B_ABST
    Figure CN115879531B_ABST
Patent Text Reader

Abstract

According to an embodiment of the present disclosure, a method, apparatus, electronic device, computer storage medium and computer program product for compressing a classification neural network are provided. The method described herein includes: obtaining a candidate pruning scheme for a convolutional layer of the classification neural network, the candidate pruning scheme indicating that a group of channels in a plurality of channels of the convolutional layer are to be retained; processing a set of samples using the classification neural network to determine feature maps associated with the group of channels; determining a first metric and a second metric based on the feature maps; and updating the candidate pruning scheme based on the first metric and the second metric to determine a target pruning scheme for pruning the convolutional layer of the classification neural network. In this way, the present disclosure can consider the impact of the retained group of channels on the classification neural network in a coordinated manner, thereby more effectively compressing the neural network.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Implementations of the present disclosure relate to the field of artificial intelligence, and more particularly, to a method, an apparatus, an electronic device, a computer storage medium, and a computer program product for compressing a classification neural network. BACKGROUND

[0002] In recent years, with the development of artificial intelligence technology, neural networks have been widely used in many technical fields such as image processing and speech recognition, and have played an important role.

[0003] In order to perform more complex tasks, the number of layers contained in the neural network is increasing, and the size of the network parameters and the computation scale are also increasingly large. This makes the neural network consume a large amount of computing resources when training and using, and such complex neural networks are difficult to be deployed to devices with limited computing resources and memory, such as mobile devices and embedded systems.

[0004] Therefore, how to compress the volume of the neural network model and reduce the computation of the neural network model while ensuring the accuracy of the neural network has become a current focus. SUMMARY

[0005] Embodiments of the present disclosure provide a scheme for compressing a classification neural network.

[0006] In a first aspect of the present disclosure, a method for compressing a classification neural network is provided. The method comprises: obtaining a candidate pruning scheme for a convolutional layer of the classification neural network, the candidate pruning scheme indicating that a group of channels in a plurality of channels of the convolutional layer are to be retained; processing a set of samples using the classification neural network to determine feature maps associated with the group of channels; determining a first metric and a second metric based on the feature maps, the first metric indicating a first difference between feature representations of samples with a same class in the set of samples, and the second metric indicating a second difference between feature representations of samples with different classes; and updating the candidate pruning scheme based on the first metric and the second metric to determine a target pruning scheme for pruning the convolutional layer of the classification neural network.

[0007] In a second aspect of the present disclosure, an apparatus for compressing a classification neural network is provided. The apparatus comprises: an obtaining module configured to obtain a candidate pruning scheme for a convolutional layer of the classification neural network, the candidate pruning scheme indicating that a group of channels in a plurality of channels of the convolutional layer are to be preserved; a processing module configured to process a set of samples with the classification neural network to determine feature maps associated with the group of channels; an analyzing module configured to determine a first metric and a second metric based on the feature maps, the first metric indicating a first difference between feature representations of samples in the set of samples having a same class, and the second metric indicating a second difference between feature representations of samples having different classes; and an updating module configured to update the candidate pruning scheme based on the first metric and the second metric to determine a target pruning scheme for pruning the convolutional layer of the classification neural network.

[0008] In a third aspect of the present disclosure, an electronic device is provided, comprising: a memory and a processor; wherein the memory is configured to store one or more computer instructions, and the one or more computer instructions are executed by the processor to implement the method according to the first aspect of the present disclosure.

[0009] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, having stored thereon one or more computer instructions, and the one or more computer instructions are executed by a processor to implement the method according to the first aspect of the present disclosure.

[0010] In a fifth aspect of the present disclosure, a computer program product is provided, comprising computer executable instructions, and the computer executable instructions, when executed by a processor, implement the method according to the first aspect of the present disclosure.

[0011] According to various embodiments of the present disclosure, the present disclosure can consider the impact of the preserved group of channels on the classification neural network in a coordinated manner, and thus more effectively compress the classification neural network. In addition, by compressing the classification neural network, embodiments of the present disclosure can reduce the requirements of the neural network on the deployed computing device, thereby improving the scalability of the neural network. BRIEF DESCRIPTION OF DRAWINGS

[0012] The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent upon consideration of the following detailed description, taken in conjunction with the accompanying drawings. In the drawings, like reference numerals refer to like elements, and in which:

[0013] FIG. 1 A schematic diagram showing an example environment in which various embodiments of the present disclosure can be implemented is shown;

[0014] FIG. 2 A flowchart showing a process of compressing a network according to various embodiments of the present disclosure is shown;

[0015] FIG. 3A and FIG. 3B schematic diagram showing the distribution of features according to different categories is shown;

[0016] FIG. 4 a flowchart showing a process of updating a pruning scheme according to embodiments of the present disclosure is shown;

[0017] FIG. 5 a schematic block diagram of an apparatus for compressing a classification neural network according to some embodiments of the present disclosure is shown; and

[0018] FIG. 6 a block diagram of a computing device capable of implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0019] Embodiments of the present disclosure will be described below in greater detail with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be interpreted as being limited to the embodiments set forth herein, but rather, these embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It will be appreciated that the drawings of the present disclosure and the embodiments are for exemplary purposes only and should not be construed as limiting the scope of protection of the present disclosure.

[0020] In the description of embodiments of the present disclosure, the term "includes" and its derivatives, such as "including," should be understood in an open, inclusive sense, that is, "including, but not limited to." The term "based on" should be understood as "based at least in part on." The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment." The terms "a first," "a second," etc. can refer to different or the same objects. Other explicit or implicit definitions can also be included below.

[0021] As used herein, a "neural network" is capable of processing an input and providing a corresponding output, which typically includes an input layer and an output layer and one or more hidden layers between the input layer and the output layer. The layers in the neural network are connected in order, so that the output of a previous layer is provided as the input of a subsequent layer, with the input layer receiving the input of the neural network model and the output of the output layer as the final output of the neural network model. Each layer of the neural network model includes one or more nodes (also referred to as processing nodes or neurons), each of which processes the input from the previous layer. In this document, the terms "neural network", "model", "network" and "neural network model" are used interchangeably.

[0022] As discussed above, in recent years, the depth of neural networks (e.g., convolutional neural networks) is getting deeper and the width is getting wider, which leads to the fact that both training and prediction of these neural networks consume large amount of computing resources. This makes it difficult for these neural networks to be deployed into devices with limited computing resources, such as robots, self-driving vehicles, and mobile terminals, etc.

[0023] Some existing solutions propose to reduce the volume of neural networks and reduce the computational load of the network by pruning the channels of the convolutional layers in the neural networks, which is also referred to as "channel pruning". For example, some conventional solutions filter out unimportant channels by formulating a screening rule and prune these channels.

[0024] Such pruning only considers the importance of the channels independently. However, some channels may have low importance when considered independently, but can achieve better results when combined with other channels. Therefore, only considering the importance of the channels themselves can lead to poor pruning results.

[0025] According to implementations of the present disclosure, a solution for compressing a neural network is proposed. In the solution, first, a candidate pruning scheme for a convolutional layer of a classification neural network can be obtained, the candidate pruning scheme indicating that a group of channels in the plurality of channels of the convolutional layer are to be retained. Further, a set of samples can be processed by the classification neural network to determine feature maps associated with the group of channels.

[0026] Further, a first metric and a second metric can be determined based on the feature maps, where the first metric indicates a first difference between feature representations of samples with a same class in the set of samples, and the second metric indicates a second difference between feature representations of samples with different classes. Subsequently, the candidate pruning scheme can be updated based on the first metric and the second metric to determine a target pruning scheme for pruning the convolutional layer of the classification neural network.

[0027] According to various embodiments of the present disclosure, the present disclosure can consider the impact of the retained group of channels on the classification neural network in a coordinated manner, thereby more effectively compressing the classification neural network. In addition, by compressing the classification neural network, embodiments of the present disclosure can reduce the requirements of the neural network on the deployed computing device, thereby improving the scalability of the neural network.

[0028] Various example implementations of the solution are described in further detail below in conjunction with the accompanying drawings.

[0029] Example Environment

[0030] Referring first to FIG. 1 which schematically illustrates a schematic diagram of an environment 100 in which example implementations according to the present disclosure can be implemented. As shown in FIG. 1, the environment 100 can include a computing device 110 and a classification neural network 120.FIG. 1 As shown, environment 100 includes computing device 135. In some implementations, computing device 135 may be a computing device with sufficient computing resources.

[0031] The computing device 135 can receive a classification neural network 120 to be compressed. In some implementations, the classification neural network 120 may be a convolutional neural network (CNN) and includes one or more convolutional layers, for example... FIG. 1 The convolutional layers 125-1 to 125-N shown are referred to individually or collectively as convolutional layer 125. Taking convolutional layer 125-2 as an example, it includes multiple channels 130-1 to 130-M (referred to individually or collectively as channel 130, or output channel 130). These output channels will be provided to the next convolutional layer 125 as input.

[0032] like FIG. 1 As shown, computing device 135 receives a set of samples 110 and uses the set of samples 110 to compress classification neural network 120. In some implementations, examples of the set of samples 110 may include, but are not limited to, image samples, text samples, video samples, and speech samples. Accordingly, classification neural network 120 may be a classification neural network for image processing, a classification neural network for text processing, a classification neural network for video processing, or a classification neural network for speech processing.

[0033] According to the scheme of this disclosure, computing device 135 can determine a pruning strategy for convolutional layers in a classification neural network. FIG. 1 In the example, computing device 135 can determine that the output channels 130-2 and 130-3 of the convolutional layer 125-2 of the classification neural network 120 will be pruned (as shown by dashed lines for output channels 150-2 and 150-3) to obtain a compressed classification neural network 140. In the compressed classification neural network 140, it still includes multiple convolutional layers 145-1 to 145-N. The difference is that the output channels 150-2 and 150-3 in the convolutional layer 145-2 have been pruned, thereby reducing the computational cost of the neural network.

[0034] It should be understood that FIG. 1 The neural network structure shown, along with the number of convolutional layers and output channels, is illustrative and not restrictive. In different applications, neural networks can be designed with other appropriate architectures and / or appropriate numbers of convolutional layers and output channels, as needed.

[0035] The following will combine FIG. 2 Figure 3 illustrates the detailed process of determining the cutting strategy.

[0036] Example Process

[0037] FIG. 2 A flowchart of a process 200 of compressing a classification neural network is shown in accordance with some embodiments of the present disclosure. The process 200 can be implemented by the computing device 135. FIG. 1 For ease of discussion, the process 200 will be described in conjunction with the classification neural network 120. FIG. 1

[0038] As shown in FIG. 2, at block 202, the computing device 135 obtains a candidate pruning scheme for a convolutional layer 125-2 of the classification neural network 120, where the candidate pruning scheme indicates that a group of channels among the plurality of channels 130 of the convolutional layer 125-2 are to be retained. FIG. 2

[0039] In some implementations, for a particular convolutional layer (e.g., the convolutional layer 125-2) in the classification neural network 120, the computing device 135 can determine that it needs to retain a particular number of groups of channels. In some implementations, the number can be pre-specified, e.g., based on expert prior knowledge.

[0040] Alternatively, as will be detailed below, the number can also be determined, e.g., according to a target compression degree of the classification neural network 120. The target compression degree can indicate, e.g., a limit on the number of floating point computations for the compressed classification neural network 120.

[0041] At block 204, the computing device 135 processes the group of samples 110 with the classification neural network 120 to determine a feature map associated with the group of channels.

[0042] In some implementations, the computing device 135 can process the input group of samples with one or more convolutional layers of the classification neural network 120 to determine the original feature maps output by each convolutional layer. Further, the computing device 135 can determine the feature map associated with the group of channels based on the retained group of channels, i.e., the output feature map with only the group of channels retained.

[0043] At block 206, the computing device 135 determines a first metric and a second metric based on the feature map, where the first metric indicates a first difference between the feature representations of the samples in the group of samples that have the same class, and the second metric indicates a second difference between the feature representations of the samples that have different classes.

[0044] For a classification neural network model, it is always desirable that the samples of the same class are relatively concentrated in the feature space, and the samples of different classes are as far apart as possible in the feature space.

[0045] For example, FIG. 3A and FIG. 3B ​​Two different feature distributions 300A and 300B are shown. It can be seen that in the feature distribution 300A, the samples of "class A" are farther away from the samples of "class B" in the feature space, thus supporting more accurate classification; in the feature distribution 300B, the samples of "class A" are more clustered with the samples of "class B" in the feature space, thus making it difficult to effectively classify.

[0046] In some embodiments, the computing device 135 can determine the first metric and the second metric based on the feature map to determine the quality of the feature map. Exemplarily, the class relationship between the samples can be represented by a weight matrix and which can be respectively represented as:

[0047]

[0048]

[0049] where X = [x [1] ,..., x [N] ] represents N samples, y = [y [1] ,..., y [N] ] represents the classification labels corresponding to the samples, and n k represents the number of samples of the kth class.

[0050] Further, the computing device 135 can represent the first difference of the feature representation of the samples in the same class as and represent the second difference of the feature representation of the samples in different classes as where O l = [o [1] ,..., o [N] ] represents the aggregated feature map output by the convolutional layer l.

[0051] With reference to FIG. 2 , at block 208, the computing device 135 updates the candidate pruning scheme based on the first metric and the second metric to determine a target pruning scheme for pruning the convolutional layers of the classification neural network.

[0052] As discussed above, when the pruning scheme can make the first difference smaller and the second difference larger, the corresponding feature map will be able to better support the classification task. Therefore, the computing device 135 can update the candidate pruning scheme with the optimization goal of minimizing the first metric and maximizing the second metric. The optimization goal can be represented as, for example:

[0053]

[0054]

[0055] in tr represents the trace operation of a matrix. To indicate that the i-th element is 1, c l d represents the number of channels in the l-th convolutional layer. l This indicates the number of channels to be retained.

[0056] By using the optimization objective defined in Equation (3), embodiments of this disclosure enable the feature maps output by the cropping scheme to be more suitable for classification tasks.

[0057] In some embodiments, the optimization problem of formula (3) can be further transformed into:

[0058]

[0059]

[0060] in,

[0061]

[0062]

[0063]

[0064] The following will be further referenced FIG. 4 To describe the specific process of solving the optimization problem of formula (4). For example FIG. 4 As shown in box 402, computing device 135 can determine scores for multiple channels based on a first metric and a second metric, wherein the scores indicate the degree of influence of the corresponding channel on the first metric and the second metric.

[0065] For example, computing device 135 can determine the score s of each channel in the l-th convolutional layer based on the following expression. l,i :

[0066]

[0067] In box 404, computing device 135 can determine the difference between the first metric and the second metric. Exemplarily, computing device 135 can determine λ based on the first metric and the second metric according to formula (5). l , to be used as the first measure of difference.

[0068] In box 406, computing device 135 can first measure the difference to update the scores of multiple channels. Exemplarily, computing device 135 can base its scores on λ. l And use formula (8) to update the scores of multiple channels.

[0069] In box 408, computing device 135 can determine a second set of channels to be retained from the multiple channels based on the updated scores of the multiple channels. For example, computing device 135 can select a predetermined number of channels with the highest scores from the multiple channels based on the updated scores.

[0070] In box 410, computing device 135 determines the second metric difference between the updated first metric and the updated second metric based on the second set of channels. Further, computing device 135 may determine the first and second metrics associated with the second set of channels by referring to the process discussed above, and further determine the second metric difference λ′. l .

[0071] In box 412, computing device 135 can determine the difference (e.g., λ′) between the first metric difference and the second metric difference. l -λ l Is it less than a predetermined threshold? If so, the process can proceed to box 416, where computing device 135 can determine the target pruning scheme based on the second set of channels and terminate the iteration.

[0072] Conversely, if in box 412 the difference between the first metric difference and the second metric difference is determined to be greater than or equal to a predetermined threshold, the process can proceed to box 414, whereby the computing device 135 can determine the determined first metric difference as the new first metric difference and return to box 406 for a new round of iteration.

[0073] based on FIG. 4 As illustrated, embodiments of this disclosure can iteratively determine which predetermined number of channels should be retained from a plurality of channels with the goal of optimizing the quality of the output feature map. Thus, embodiments of this disclosure can comprehensively consider the interactions between multiple channels and make the retained channels more suitable for classification neural networks.

[0074] In some implementations, as discussed above, computing device 135 can also determine the target number of a set of channels to be retained out of multiple channels based on the target compression degree of the classification neural network. In some implementations, the target compression degree indicates the target floating-point computation number of the pruned classification neural network.

[0075] In some implementations, computing device 135 may, for example, determine the number of channels that should be retained in each convolutional layer 125 of the classification neural network based on a greedy algorithm. Subsequently, computing device 135 may determine, based on the number of channels that should be retained in each convolutional layer 125, and subsequently on the process discussed in process 200, which specific channels in each convolutional layer 125 should be retained.

[0076] First, the computing device 135 can determine a plurality of benefit factors based on the performance changes caused by preserving additional channels in the plurality of convolutional layers. Specifically, the computing device 135 can set a small number as an initial number for each convolutional layer. Further, the computing device 135 can determine the performance change that would be caused by adding one new channel in each convolutional layer.

[0077] In some implementations, the performance change can be represented, for example, by the change in the channel score. For example, the change can be represented as:

[0078]

[0079] wherein represents the scores of the plurality of channels in the l-th convolutional layer is arranged in descending order.

[0080] In some implementations, the computing device 135 can also determine a plurality of overhead factors based on the change in the number of floating point calculations caused by preserving additional channels in the plurality of convolutional layers, which can be represented, for example, as:

[0081]

[0082] wherein,

[0083]

[0084]

[0085] wherein q l x q l , w l and h l represent the kernel size, the feature map width and the feature map height of the l-th convolutional layer, respectively.

[0086] Further, the computing device 135 can determine the number of channels to be preserved in each convolutional layer of the plurality of convolutional layers based on the plurality of benefit factors and the plurality of overhead factors.

[0087] In some implementations, the computing device 135 can determine in which convolutional layer an additional channel should be preserved based on maximizing the ratio of the benefit factor to the overhead factor. This process can be obtained by solving, for example, equation (13).

[0088]

[0089] Based on such a manner, the computing device 135 can iteratively determine the convolutional layer in which one or more channels should be added each time, and until the total number of floating point calculations reaches the target number of floating point calculations.

[0090] Based on this approach, embodiments of this disclosure can automatically determine the number of channels that should be retained in each convolutional layer using a greedy algorithm, thereby improving the performance of model compression.

[0091] In some implementations, computing device 135 may compress the classification neural network 140 based on a target pruning scheme. In some implementations, computing device 135 may also deploy the pruned neural network 140 on a target computing device, wherein the number of computing resources on the target computing device is less than a threshold number. Examples of target computing devices include, but are not limited to, devices with relatively limited computing resources such as robots, autonomous vehicles, and mobile terminals.

[0092] In this way, the embodiments of this disclosure can reduce the computational resource requirements of neural networks, improve the versatility of neural networks, and thus enable them to be applied to more devices.

[0093] Example Devices and Apparatus

[0094] Embodiments of this disclosure also provide corresponding apparatus for implementing the above methods or processes. FIG. 5 A schematic structural block diagram of an apparatus 500 for a compressed classification neural network according to some embodiments of the present disclosure is shown.

[0095] like FIG. 5 As shown, the apparatus 500 may include an acquisition module 510 configured to acquire candidate pruning schemes for a convolutional layer of a classification neural network, the candidate pruning schemes indicating that a set of channels among a plurality of channels of the convolutional layer will be retained. The apparatus 500 may also include a processing module 520 configured to process a set of samples using the classification neural network to determine feature maps associated with the set of channels. The apparatus 500 may further include an analysis module 530 configured to determine a first metric and a second metric based on the feature maps, the first metric indicating a first difference between feature representations of samples of the same class in the set of samples, and the second metric indicating a second difference between feature representations of samples of different classes. Furthermore, the apparatus 500 may also include an update module 540 configured to update the candidate pruning schemes based on the first and second metrics to determine a target pruning scheme for pruning the convolutional layer of the classification neural network.

[0096] In some implementations, the update module 540 is also configured to: determine the scores of multiple channels based on the first metric and the second metric, the scores indicating the degree of influence of the corresponding channels on the first metric and the second metric; and update the candidate pruning scheme based on the scores of the multiple channels.

[0097] In some implementations, the set of channels is a first set of channels, and the updating module 540 is further configured to: determine a first metric difference between the first metric and the second metric; and iteratively perform the following processes: update the scores of the plurality of channels based on the first metric difference; determine a second set of channels to be reserved from the plurality of channels based on the updated scores of the plurality of channels; determine a second metric difference between the updated first metric and an updated second metric based on the second set of channels; if a difference between the first metric difference and the second metric difference is less than a predetermined threshold, determine the target pruning scheme based on the second set of channels and terminate the iteration; and if the difference between the first metric difference and the second metric difference is greater than or equal to the predetermined threshold, determine the second metric difference as a new first metric difference.

[0098] In some implementations, the apparatus 500 further includes a planning module configured to determine a target number of a set of channels to be reserved from the plurality of channels based on the target compression level of the classification neural network.

[0099] In some implementations, the target compression level indicates a target number of floating-point computations of the pruned classification neural network.

[0100] In some implementations, the classification neural network includes a plurality of convolutional layers, and the planning module is further configured to: determine a plurality of benefit factors based on performance changes caused by reserving additional channels in the plurality of convolutional layers; determine a plurality of overhead factors based on changes in the number of floating-point computations caused by reserving additional channels in the plurality of convolutional layers; and determine the number of channels to be reserved in each convolutional layer of the plurality of convolutional layers based on the plurality of benefit factors and the plurality of overhead factors.

[0101] In some implementations, the apparatus 500 further includes a compression module configured to compress the classification neural network based on the target pruning scheme, and a deployment module configured to cause the compressed classification neural network to be deployed to a target computing device, the target computing device having a number of computing resources less than a threshold number.

[0102] In some implementations, the set of samples is a set of image samples, and the classification neural network is a classification neural network for image processing.

[0103] The units included in device 500 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more units may be implemented using software and / or firmware, such as machine-executable instructions stored on a storage medium. In addition to or as an alternative to machine-executable instructions, some or all of the units in device 500 may be implemented at least partially by one or more hardware logic components. By way of example and not limitation, exemplary types of hardware logic components that may be used include field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-chips (SoCs), complex programmable logic devices (CPLDs), and so on.

[0104] FIG. 6 A block diagram of a computing device / server 600 in which one or more embodiments of the present disclosure may be implemented is shown. It should be understood that... FIG. 6 The computing device / server 600 shown is merely exemplary and should not be construed as limiting the functionality and scope of the embodiments described herein.

[0105] like FIG. 6 As shown, the computing device / server 600 is in the form of a general-purpose computing device. Components of the computing device / server 600 may include, but are not limited to, one or more processors or processing units 610, memory 620, storage devices 630, one or more communication units 640, one or more input devices 650, and one or more output devices 660. The processing unit 610 may be a physical or virtual processor and is capable of performing various processes according to programs stored in memory 620. In a multiprocessor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capabilities of the computing device / server 600.

[0106] The computing device / server 600 typically includes multiple computer storage media. Such media can be any available media accessible to the computing device / server 600, including but not limited to volatile and non-volatile media, removable and non-removable media. Memory 620 can be volatile memory (e.g., registers, cache, random access memory (RAM)), non-volatile memory (e.g., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof. Storage device 630 can be removable or non-removable media and can include machine-readable media, such as flash drives, disks, or any other media that can be used to store information and / or data (e.g., training data for training) and can be accessed within the computing device / server 600.

[0107] The computing device / server 600 can further include additional removable / non-removable, volatile / non-volatile storage devices. Although not shown, an interface for each of the additional storage devices can be connected to the bus 620. The storage devices 620 can include, without limitation, magnetic disks, magnetic tapes, CD-ROMs, DVDs, Blu-ray Discs®, or any other medium which can be used to store information and which can be accessed by the computing device / server 600. The storage devices 620 can also include a computer program product 625 having one or more program modules configured to carry out the various methods or actions of the various embodiments of the present disclosure. FIG. 6 Although not shown in FIG. 6, a disk drive and a CD-ROM drive can be provided for reading from or writing to a removable, non-removable, or removable media disk (e.g., a "floppy drive" or "hard drive"). In such cases, each drive can be connected to the bus (not shown) by one or more data media interfaces. The memory 620 can include a computer program product 625 having one or more program modules configured to carry out the various methods or actions of the various embodiments of the present disclosure.

[0108] The communication unit 640 enables communication with other computing devices over a communication medium. Additionally, the functionality of the components of the computing device / server 600 can be implemented in a single computing cluster or multiple computing machines that are capable of communicating over a communication connection. Thus, the computing device / server 600 can operate in a networked environment using logical connections to one or more other servers, network personal computers (PCs), or another network node.

[0109] The input device 650 can be one or more input devices, such as a mouse, a keyboard, a trackball, etc. The output device 660 can be one or more output devices, such as a display, a speaker, a printer, etc. The computing device / server 600 can also communicate with one or more external devices (not shown) such as a storage device, a display device, etc. through the communication unit 640, as needed, communicate with one or more devices that enable a user to interact with the computing device / server 600, or communicate with any devices (e.g., a network card, a modem, etc.) that enable the computing device / server 600 to communicate with one or more other computing devices. Such communication can be carried out via an input / output (I / O) interface (not shown).

[0110] According to an example implementation of the present disclosure, a computer readable storage medium is provided having stored thereon one or more computer instructions, wherein the one or more computer instructions are executed by a processor to implement the method described above.

[0111] Various aspects of the disclosure can be described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to implementations of the disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer readable program instructions.

[0112] These computer readable program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer readable program instructions can also be stored in a computer readable storage medium that can include a non-transitory computer readable storage medium that can be a computer- readable storage medium having no data, programs, program modules, e.g., instructions for operation, or digital content stored thereon or therein for a short time or not at all. The computer readable storage medium can also have instructions stored thereon or therein which may

[0113] The computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0114] The computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0115] Implementations of the present disclosure have been described above, and examples of the disclosure are illustrative, not exhaustive, and are not limited to the disclosed implementations. Numerous modifications and adaptations thereof will be apparent to those skilled in the art without departing from the scope and spirit of the disclosed implementations. The scope of the disclosure includes all the modifications and variations from the disclosed implementations falling within the scope of the appended claims and their equivalents. The selection of the terms to be used in the description is intended to best explain the principles of the implementations, practical application, or improvement over the technology in the field made by the implementations, or to enable other ordinary skilled in the art to understand the implementations disclosed herein.

[0116] Example Implementations

[0117] TS 1. A method of compressing a classification neural network, comprising:

[0118] obtaining a candidate pruning scheme for a convolutional layer of a classification neural network, the candidate pruning scheme indicating that a group of channels of a plurality of channels of the convolutional layer are to be retained;

[0119] processing a set of samples with the classification neural network to determine feature maps associated with the group of channels;

[0120] based on the feature maps, determining a first metric indicating a first difference between feature representations of samples of the set of samples having a same class and a second metric indicating a second difference between feature representations of samples having different classes; and

[0121] based on the first metric and the second metric, updating the candidate pruning scheme to determine a target pruning scheme for pruning the convolutional layer of the classification neural network.

[0122] TS 2. The method of TS 1, wherein updating the candidate pruning scheme comprises:

[0123] based on the first metric and the second metric, determining scores for the plurality of channels, the scores indicating a degree of influence of a respective channel on the first metric and the second metric; and

[0124] based on the scores for the plurality of channels, updating the candidate pruning scheme.

[0125] TS 3. The method of TS 2, wherein the group of channels is a first group of channels, and updating the candidate pruning scheme based on the scores for the plurality of channels comprises:

[0126] determining a first metric difference between the first metric and the second metric; and

[0127] iteratively performing the following processes:

[0128] based on the first metric difference, updating the scores for the plurality of channels;

[0129] based on the updated scores for the plurality of channels, determining a second group of channels from the plurality of channels that are to be retained;

[0130] based on the second group of channels, determining a second metric difference between an updated first metric and an updated second metric;

[0131] determining the target pruning scheme based on the second set of channels and terminating the iteration if a difference between the first metric difference and the second metric difference is less than a predetermined threshold; and

[0132] determining the second metric difference as a new first metric difference if the difference between the first metric difference and the second metric difference is greater than or equal to the predetermined threshold.

[0133] TS 4. The method of TS 1, further comprising:

[0134] determining a target number of the set of channels from the plurality of channels to be preserved based on a target compression level of the classification neural network.

[0135] TS 5. The method of TS 4, wherein the target compression level indicates a target number of floating point computations of the pruned classification neural network.

[0136] TS 6. The method of TS 4, wherein the classification neural network comprises a plurality of convolutional layers, and determining a target number of the set of channels from the plurality of channels to be preserved comprises:

[0137] determining a plurality of benefit factors based on changes in performance caused by preserving additional channels in the plurality of convolutional layers;

[0138] determining a plurality of overhead factors based on changes in a number of floating point computations caused by preserving additional channels in the plurality of convolutional layers; and

[0139] determining a number of channels to be preserved in each convolutional layer of the plurality of convolutional layers based on the plurality of benefit factors and the plurality of overhead factors.

[0140] TS 7. The method of TS 1, further comprising:

[0141] compressing the classification neural network based on the target pruning scheme; and

[0142] deploying the compressed classification neural network to a target computing device having a number of computing resources less than a threshold number.

[0143] TS 8. The method of TS 1, wherein the set of samples is a set of image samples, and the classification neural network is a classification neural network for image processing.

[0144] TS 9. An apparatus for compressing a classification neural network, comprising:

[0145] an obtaining module configured to obtain a candidate pruning scheme for a convolutional layer of a classification neural network, the candidate pruning scheme indicating that a group of channels in a plurality of channels of the convolutional layer are to be retained;

[0146] a processing module configured to process a set of samples with the classification neural network to determine feature maps associated with the group of channels;

[0147] an analyzing module configured to determine, based on the feature maps, a first metric indicating a first difference between feature representations of samples of the set of samples having a same class and a second metric indicating a second difference between feature representations of samples having different classes; and

[0148] an updating module configured to update, based on the first metric and the second metric, the candidate pruning scheme to determine a target pruning scheme for pruning the convolutional layer of the classification neural network.

[0149] TS 10. An electronic device, comprising:

[0150] a memory and a processor;

[0151] wherein the memory is configured to store one or more computer instructions, and wherein the one or more computer instructions are executed by the processor to implement the method according to any one of TSs 1-8.

[0152] TS 11. A computer-readable storage medium having stored thereon one or more computer instructions, wherein the one or more computer instructions are executed by a processor to implement the method according to any one of TSs 1-8.

[0153] TS 12. A computer program product comprising computer executable instructions, wherein the computer executable instructions, when executed by a processor, implement the method according to any one of TSs 1-8.

Claims

1. A method for compressing a classification neural network, comprising: Obtain candidate pruning schemes for convolutional layers of a classification neural network, wherein the candidate pruning schemes indicate that a set of channels among a plurality of channels of the convolutional layer will be retained; The classification neural network is used to process a set of samples to determine the feature maps associated with the set of channels; Based on the feature map, a first metric and a second metric are determined, wherein the first metric indicates a first difference between the feature representations of samples with the same class in the set of samples, and the second metric indicates a second difference between the feature representations of samples with different classes; as well as Based on the first metric and the second metric, the candidate pruning scheme is updated to determine the target pruning scheme for pruning the convolutional layer of the classification neural network; Wherein, the set of samples is a set of image samples, and the classification neural network is a classification neural network used for image processing; or The set of samples is a set of text samples, and the classification neural network is a classification neural network used for text processing; or The set of samples is a set of video samples, and the classification neural network is a classification neural network used for video processing; or The set of samples is a set of speech samples, and the classification neural network is a classification neural network used for speech processing.

2. The method according to claim 1, wherein updating the candidate pruning scheme comprises: Based on the first metric and the second metric, a score is determined for the plurality of channels, the score indicating the degree of influence of the corresponding channel on the first metric and the second metric; as well as The candidate pruning scheme is updated based on the scores of the multiple channels.

3. The method of claim 2, wherein the set of channels is a first set of channels, and updating the candidate pruning scheme based on the scores of the plurality of channels comprises: Determine the first metric difference between the first metric and the second metric; as well as The following process is executed iteratively: Based on the first metric difference, update the scores of the multiple channels; Based on the updated scores of the multiple channels, a second group of channels is determined from the multiple channels to be retained; Based on the second set of channels, determine the difference between the updated first metric and the updated second metric; If the difference between the first metric difference and the second metric difference is less than a predetermined threshold, then the target pruning scheme is determined based on the second set of channels and the iteration is terminated; as well as If the difference between the first metric difference and the second metric difference is greater than or equal to the predetermined threshold, then the second metric difference is determined as the new first metric difference.

4. The method according to claim 1, further comprising: Based on the target compression degree of the classification neural network, the target number of the set of channels to be retained among the multiple channels is determined.

5. The method of claim 4, wherein the target compression degree indicates the target floating-point computation number of the pruned classification neural network.

6. The method of claim 4, wherein the classification neural network comprises a plurality of convolutional layers, and determining the target number of the set of channels to be retained from the plurality of channels comprises: Based on the performance changes caused by retaining additional channels in the multiple convolutional layers, multiple benefit factors are determined; Based on the change in floating-point computations caused by retaining additional channels in the multiple convolutional layers, multiple overhead factors are determined; as well as Based on the plurality of benefit factors and the plurality of overhead factors, the number of channels retained in each of the plurality of convolutional layers is determined.

7. The method according to claim 1, further comprising: Based on the target pruning scheme, compress the classification neural network; as well as The compressed classification neural network is deployed on a target computing device, the number of computing resources of which is less than a threshold number.

8. An apparatus for compressing a classification neural network, comprising: The acquisition module is configured to acquire candidate pruning schemes for a convolutional layer of a classification neural network, the candidate pruning schemes indicating that a set of channels among a plurality of channels of the convolutional layer will be retained; The processing module is configured to process a set of samples using the classification neural network to determine feature maps associated with the set of channels; An analysis module is configured to determine a first metric and a second metric based on the feature map, wherein the first metric indicates a first difference between the feature representations of samples of the same class in the set of samples, and the second metric indicates a second difference between the feature representations of samples of different classes. as well as The update module is configured to update the candidate pruning scheme based on the first metric and the second metric to determine the target pruning scheme for pruning the convolutional layer of the classification neural network; Wherein, the set of samples is a set of image samples, and the classification neural network is a classification neural network used for image processing; or The set of samples is a set of text samples, and the classification neural network is a classification neural network used for text processing; or The set of samples is a set of video samples, and the classification neural network is a classification neural network used for video processing; or The set of samples is a set of speech samples, and the classification neural network is a classification neural network used for speech processing.

9. An electronic device, comprising: Memory and processor; The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having stored thereon one or more computer instructions, wherein the one or more computer instructions are executed by a processor to implement the method according to any one of claims 1 to 7.

11. A computer program product comprising computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the method according to any one of claims 1 to 7.