WO2021208151A1 - 一种模型压缩方法、图像处理方法以及装置 - Google Patents

一种模型压缩方法、图像处理方法以及装置 Download PDF

Info

Publication number
WO2021208151A1
WO2021208151A1 PCT/CN2020/088252 CN2020088252W WO2021208151A1 WO 2021208151 A1 WO2021208151 A1 WO 2021208151A1 CN 2020088252 W CN2020088252 W CN 2020088252W WO 2021208151 A1 WO2021208151 A1 WO 2021208151A1
Authority
WO
WIPO (PCT)
Prior art keywords
network layer
model
layer
network
channel
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/CN2020/088252
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.)
Sensetime Group Ltd
Original Assignee
Sensetime Group 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 Sensetime Group Ltd filed Critical Sensetime Group Ltd
Priority to JP2021525567A priority Critical patent/JP2022541359A/ja
Priority to KR1020217013984A priority patent/KR20210129031A/ko
Publication of WO2021208151A1 publication Critical patent/WO2021208151A1/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
    • 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/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present disclosure relates to the field of machine learning technology, and in particular to a model compression method, image processing method and device.
  • Channel pruning is currently a common model compression method. This method achieves compression of the neural network model by removing the parameters with smaller weights in the network model after the model is trained.
  • the embodiments of the present disclosure provide at least one model compression method, image processing method and device.
  • the embodiments of the present disclosure provide a model compression method, the method includes: for any one of the at least one of the multi-layer network layers in the model to be compressed, according to the According to the model compression progress of the channel pruning process at any one of the network layers, the first target model is determined, and the first target model is used to obtain the loss information of the sample image, and the first target model
  • the next network layer of any network layer outputs the first feature data of the sample image; based on the loss information and the first feature data, the classification loss guidance information is determined; based on the classification loss guidance information,
  • the network layer of any one layer performs channel pruning processing.
  • the first target model is determined according to the model compression progress during the pruning process of the corresponding channel of the network layer of any layer, and the first target model is used to obtain the loss information of the sample image, and the first
  • the next network layer of any one of the network layers in the target model outputs the first feature data of the sample image; then based on the loss information and the first feature data, the classification loss guidance information is determined, and Based on the classification loss guidance information, perform channel pruning processing on any one of the network layers. Therefore, it is possible to perform pruning for only one layer of neural network each time, and guide the channel pruning processing of this layer of neural network based on the classification loss guidance information when pruning, so as to avoid greater impact on the loss of the model after the compression is completed. In turn, the compression efficiency can be ensured, and the compression effect can be taken into consideration at the same time.
  • the method further includes: performing the pruning process on all the network layers based on the any one of the network layers.
  • the next network layer of any network layer described above performs parameter update processing.
  • the parameters of the layer 1 + 1 network layer are adaptively adjusted.
  • the determining classification loss guidance information based on the loss information and the first feature data includes: determining classification loss guidance based on the loss information and the first feature data Information and feature importance guidance information.
  • the feature importance guide information is used to determine the channel selection indication information, and the channel pruning process is performed on any network layer based on the channel selection information.
  • feature importance guidance information as a guide for channel pruning of the first layer of the network layer, effectively avoiding the reconstruction error caused by non-informative features to the minimum. This information will be used in the first + The layer 1 network layer is deleted during the channel pruning process, so reasonable results can be obtained.
  • determining feature importance guidance information based on the loss information and the first feature data includes: determining the feature based on the first feature data and predetermined adjustment parameters Importance guidance information.
  • the feature importance guide information is determined based on the size of the element value of each element in the first feature data. For a certain channel, the greater the element value of each element in the first feature data, the more important the channel is considered; The smaller the element value of each element in the first feature data is, the less important the channel is considered, and then the channel is adjusted based on this method to solve the problem of feature elimination in the next layer and make the result of channel pruning more reasonable.
  • the first target model is: the to-be-compressed model; In the case that any one of the network layers is not the first network layer to be processed for channel pruning, the first target model includes: the network layer that has been processed for channel pruning, and other uncompressed models in the model to be compressed Network layer for channel pruning processing.
  • the using the first target model to obtain the loss information of the sample image includes: using the first target model to obtain the classification loss prediction result of the sample image; The classification loss prediction result of the sample image, the real classification label corresponding to the sample image, and the predetermined loss function are used to obtain the loss information of the sample image.
  • the determining the classification loss guidance information based on the loss information and the first characteristic data includes: using the reverse of the loss information in the first target model Propagation, determining a partial derivative of a loss function with respect to the first feature data; determining the partial derivative as the classification loss guidance information.
  • the performing channel pruning processing on any network layer based on the classification loss guide information includes: based on the classification loss guide information and the first image of the sample image 2. Feature data, determining channel selection instruction information; or, determining channel selection instruction information based on feature importance guidance information and the second feature data of the sample image; or, based on the classification loss guidance information and feature importance guidance Information and the second feature data of the sample image, determine channel selection indication information; adjust the convolution kernel in any network layer based on the channel selection indication information; wherein, the channel selection indication information is used to indicate The channel to be retained; the second feature data of the sample image is the feature data output from the next network layer of any one of the network layers when the sample image is processed using the to-be-compressed model.
  • the performing parameter update processing on the next network layer of the any network layer based on the any network layer after the pruning process has been performed includes: For any layer of the network that has been pruned, channel adjustments are made to each convolution kernel in the next layer of the network of any layer; based on the any layer that has been pruned Determine the second target model and use the second target model to obtain the pruning process in the second target model
  • the next network layer of any one of the subsequent network layers outputs the third feature data of the sample image; and the second feature data output by the any network layer when the image is processed using the model to be compressed , Obtain the weight parameter of the next layer of the network layer; based on the weight parameter, update the original weight parameter of the next layer of the network layer.
  • an embodiment of the present disclosure also provides an image processing method, including: acquiring an image to be processed; using an image processing model determined based on the first aspect or any one of the first aspect to perform image processing on the image to be processed Processing tasks.
  • an embodiment of the present disclosure provides a model compression device, the device includes: an acquisition module configured to target any one of at least one of the multiple network layers in the model to be compressed, Determine the first target model according to the model compression progress during the pruning process of the corresponding channel of the network layer of any layer, and use the first target model to obtain the loss information of the sample image, and the first target model The next network layer of any one of the network layers in outputting the first feature data of the sample image; a determining module configured to determine classification loss guidance information based on the loss information and the first feature data; The pruning module is configured to perform channel pruning processing on any network layer based on the classification loss guide information.
  • the device further includes: an update module configured to perform channel pruning processing on any one of the network layers by the pruning module based on the pruning processing
  • the network layer of any one layer performs parameter update processing on the next network layer of the network layer of any one layer.
  • the determining module is configured to determine classification loss guidance information and feature importance guidance information based on the loss information and the first feature data.
  • the determining module is configured to determine the feature importance guide information based on the first feature data and predetermined adjustment parameters.
  • the first target model is: the to-be-compressed model; In the case that any one of the network layers is not the first network layer to be processed for channel pruning, the first target model includes: the network layer that has been processed for channel pruning, and other uncompressed models in the model to be compressed Network layer for channel pruning processing.
  • the acquisition module is configured to use the first target model to acquire the classification loss prediction result of the sample image; the classification loss prediction result based on the sample image and the The real classification label corresponding to the sample image and the predetermined loss function are used to obtain the loss information of the sample image.
  • the determining module is configured to use the back propagation of the loss information in the first target model to determine the partial derivative of the loss function with respect to the first characteristic data;
  • the partial derivative is determined as the classification loss guidance information.
  • the pruning module is configured to determine channel selection indication information based on the classification loss guidance information and the second feature data of the sample image; or, based on feature importance guidance information And the second feature data of the sample image, determining channel selection indication information; or, based on the classification loss guidance information, feature importance guidance information, and the second feature data of the sample image, determining channel selection indication information; Based on the channel selection indication information, adjust the convolution kernel in any of the network layers; wherein the channel selection indication information is used to indicate the channel to be retained; the second feature data of the sample image is The feature data output from the network layer of any one layer of the network layer when the sample image is processed by using the to-be-compressed model.
  • the update module is configured to perform pruning processing on each of the convolution kernels in the next layer of the network based on the pruning process.
  • the channel adjustment based on the any layer of the network that has been pruned, and the next layer of the network layer that has been adjusted for the convolution kernel channel, determine the second target model, and use the second target Model to obtain the third feature data of the sample image at the next network layer of the any network layer after the pruning process has been performed in the second target model; and use the model to be compressed to
  • the second feature data output by the network layer of any one layer is used to obtain the weight parameter of the next layer network layer; based on the weight parameter, the original weight parameter of the next layer network layer Perform update processing.
  • an embodiment of the present disclosure further provides an image processing device, including: an acquiring unit configured to acquire an image to be processed; and a processing unit configured to use an image determined based on the first aspect or any one of the first aspect
  • the processing model performs image processing tasks on the to-be-processed image.
  • embodiments of the present disclosure also provide a computer device, including: a processor and a memory connected to each other, the memory storing computer-readable instructions executable by the processor, and when the computer device is running, the When the computer-readable instructions are executed by the processor, the above-mentioned first aspect of the embodiments of the present disclosure or the steps in any possible implementation manner of the first aspect are executed, or the computer-readable instructions are executed by the processor During execution, the steps in the second aspect of the embodiments of the present disclosure or any possible implementation of the second aspect are executed.
  • the embodiments of the present disclosure also provide a computer-readable storage medium having a computer program stored on the computer-readable storage medium.
  • the computer program When the computer program is run by a processor, the first aspect or the Steps in any possible implementation manner in one aspect, or, when the computer program is run by a processor, executes the above-mentioned second aspect of the embodiments of the present disclosure, or the steps in any possible implementation manner in the second aspect.
  • the embodiments of the present disclosure further provide a computer program that, when executed by a processor, implements the above-mentioned first aspect of the embodiments of the present disclosure, or the steps in any one of the possible implementation manners of the first aspect, Or, when the computer program is run by a processor, the above-mentioned second aspect of the embodiment of the present disclosure or the steps in any possible implementation manner of the second aspect are executed.
  • Fig. 1 shows a flowchart of a model compression method provided by an embodiment of the present disclosure
  • Figure 2 shows a schematic diagram of a model compression device provided by an embodiment of the present disclosure
  • Fig. 3 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
  • the channel pruning method that minimizes the loss function removes the channels of each neural network layer iteratively to minimize the impact of the final loss of the final compression model, that is, in each iteration, all neural network layers are processed .
  • This method has a good compression effect on the neural network model; however, in order to evaluate the influence of each channel on the final loss, frequent fine-tuning procedures need to be performed, resulting in slow pruning speed and low efficiency.
  • the layer-by-layer pruning method when pruning a certain layer of neural network layer, it will select the channel to be deleted and adjust the model parameters by minimizing the reconstruction error of the feature data output by the next layer of neural network layer. . Since this method can only perform pruning operations for one neural network layer at a time, and the fine-tuning process for each neural network layer is performed only once, the pruning speed is fast; but it is in the channel of each neural network layer. During the pruning operation, the adjustment of the channel may have a greater impact on the loss of the neural network model after the compression is completed, resulting in the unsatisfactory adjustment result of the channel, resulting in a poor final compression effect. Furthermore, the current method of channel pruning the neural network model has the problem that the efficiency and the compression effect cannot be balanced.
  • the channel pruning operation will be performed on the l+1 network layer, and the output characteristics of the lth network layer after the channel pruning operation , Will become the input features of the l+1 network layer; if the channel pruning operation is performed on the l+1 network layer, some reconstruction features in the input features of the l+1 network layer are deleted , These reconstruction features are reconstructed during the channel pruning operation on the l-th network layer, which means that it is not necessary to reconstruct these when the channel pruning operation is performed on the l-th network layer.
  • the reconstruction feature of the deleted network layer of the first layer which means that when the channel pruning operation is performed on the first network layer, some channels selected to be deleted are inaccurate, and the result will be obtained due to this situation.
  • the compression model of is actually not the most optimized model, there is still room for optimization. This problem is called the next-level feature elimination problem.
  • embodiments of the present disclosure provide a model compression method and device, which are used to perform channel pruning processing on at least one network layer in the multi-layer network layer in the compressed model, and target the at least one network layer in the compression model.
  • the channel pruning processing of this layer of neural network can be guided based on the classification loss guidance information, so as to avoid a large impact on the loss of the model after the compression is completed, and thus to ensure Compression efficiency can also take into account the compression effect.
  • the execution subject of the model compression method provided by the embodiments of the present disclosure is generally a computer device with a certain computing capability.
  • Computer equipment includes, for example, terminal equipment or servers or other processing equipment.
  • the terminal equipment can be User Equipment (UE), mobile equipment, user terminals, terminals, cellular phones, cordless phones, and personal digital assistants (PDAs). ), handheld devices, computing devices, vehicle-mounted devices, wearable devices, etc.
  • UE User Equipment
  • PDAs personal digital assistants
  • the model compression method can be implemented by a processor calling computer-readable instructions stored in a memory.
  • the input feature map dimension of the convolutional layer is 4*10*24, where 4 means The number of channels of the input feature map is 4; 10*24 represents the size of the feature map in each channel; the input feature map is convolved through a 64*4*3*3 convolution kernel, where 64 represents the convolution kernel Each convolution kernel corresponds to a channel; 4 represents the number of channels of the convolution kernel, and 3*3 represents the size of the convolution kernel.
  • the output feature map is: 64*10*24; the channel pruning process is performed on the network layer of this layer, that is, to reduce the number of convolution kernels, so that the number of channels of the resulting output feature map is reduced, thereby reducing the convolution process.
  • the amount of calculation, and the volume of the model For example, when performing channel pruning processing on this layer of network layer, subtracting 5 convolution kernels in this layer of network layer, the convolution kernel will become: 59*4*3*3; finally, the output obtained
  • the characteristic picture is: 59*10*24.
  • FIG. 1 it is a flowchart of a model compression method provided by an embodiment of the present disclosure.
  • the method is used to perform channel pruning processing on at least one of the multi-layer network layers in the compressed model; a possibility
  • any m-layer network layer in the L-layer network layer can be used as the network layer to be subjected to channel pruning processing.
  • m is a positive integer greater than 0 and less than L.
  • the method includes steps S101 to S103, wherein:
  • S101 For any one of the at least one network layer in the multi-layer network layer in the to-be-compressed model, determine the first network layer according to the model compression progress during pruning the corresponding channel of the any network layer. A target model, and using the first target model to obtain the loss information of the sample image, and the network layer of any one of the network layers in the first target model to output the sample image The first feature data.
  • S102 Determine classification loss guidance information based on the loss information and the first feature data.
  • the model compression progress is used to indicate the position of the network layer currently undergoing pruning processing in the model to be compressed, and before that, the network layer that has undergone channel pruning processing is in the model to be compressed s position.
  • the model compression progress may only be used to indicate the position of the network layer currently undergoing pruning processing in the model to be compressed .
  • the corresponding first network layer A target model includes: a model to be compressed.
  • l 1
  • the first network layer is the first network layer in the to-be-compressed model; there are no other network layers before the first network layer.
  • the l-layer network layer performs channel pruning processing, and the l-th network layer is the first-layer network layer to be subjected to channel pruning processing in the model to be compressed.
  • the first target model is the model to be compressed.
  • the first target model is also the model to be compressed.
  • the corresponding first target model includes: the network layer that has been subjected to channel pruning processing, and the to-be-compressed model In other network layers that have not been pruned.
  • a model to be compressed includes L-layer network layers, which are denoted as a1 ⁇ aL respectively; among them, there are three layers of network layer a1, layer 3 network layer a3, and layer 5 network layer a5.
  • the first target model at this time includes: a1', a2, a3', and a4-aL.
  • the model to be compressed includes the L-layer network layer, and the channel pruning process is performed on the layer 1 network layer to the layer L-1 network layer in the model to be processed as an example for description.
  • the using the first target model to obtain the loss information of the sample image may include, for example, inputting the sample image into the first target model, and using the first target model to obtain the classification loss prediction result of the sample image, based on the The classification loss prediction result of the sample image, the real classification label corresponding to the sample image, and the predetermined loss function are used to obtain the loss information of the sample image.
  • the loss information of the first target model is expressed as the following formula (1), for example:
  • C represents the classification loss function of the first target model when the output feature of the l+1 network layer is Y;
  • L c represents the cross-entropy loss function;
  • g represents the true classification label of the sample image.
  • N represents the function mapped from the l+2 network layer to the L network layer when the channel pruning process is performed on the l network layer;
  • W is the parameter of the function, and
  • Y is the input of the function.
  • the loss information of the sample image is determined through the above process.
  • the above loss information is composed of the network layer that has been processed for channel pruning and the network layer that has not been processed for channel pruning after the channel pruning process is performed on the first network layer to the 1-1 network layer.
  • the first feature data is the feature data output from the l+1th network layer in the first target model.
  • the first target model is used to perform image processing on the sample image, and each layer of the network layer can obtain feature data representing the characteristics of the sample image;
  • the feature data output by the l+1th network layer is determined to be the first feature data.
  • the classification loss guidance information is used to characterize the importance of each convolution kernel in the network layer to be processed by the channel pruning process.
  • the classification loss indication information may be obtained in the following manner: using the back propagation of the loss information in the first target model to determine the partial derivative of the loss function with respect to the first feature data; The partial derivative is determined as the classification loss guidance information.
  • the classification loss guidance information ⁇ satisfies the following formula (2)
  • C represents the loss function
  • y i represents the characteristic data output by the l+1 network layer on the i-th channel after the channel pruning process is performed on the l-th network layer
  • y i is a variable; different pruning schemes correspond to different y i .
  • the loss function is used to obtain the partial derivative of the variable y i
  • this step is expressed as determining classification loss guidance information based on the loss information and the first feature data.
  • the channel pruning process can be performed on the first network layer based on the classification loss guide information.
  • the channel selection indication information is used to indicate the channel to be retained;
  • the second feature data of the sample image Is the feature data output from the next network layer of any one of the network layers when the sample image is processed by using the to-be-compressed model;
  • the channel pruning process is performed on the first layer of the network layer
  • the output of the sample image of the first layer of the network layer of the model to be compressed can be obtained.
  • the second feature data determines the channel selection instruction information based on the classification loss guidance information and the second feature data.
  • the i-th channel selection indication information ⁇ satisfies the following formula (3):
  • c out represents the number of output channels of the l+1th network layer; i represents the i-th channel of the output feature.
  • represents classification loss guidance information, which satisfies the above formula (2).
  • I an element in a vector containing a set of binary channel selection indicators. In this formula, it corresponds to an output channel of the output feature of the first layer of the network layer, and is used to indicate whether the corresponding output channel needs to be pruned.
  • the number of elements included in this vector is the same as the number of input channels of the l+1th network layer, that is, the number of output channels of the lth network layer.
  • c in represents the number of input channels of the l+1th network layer. It has a one-to-one correspondence with the output channels of the first network layer.
  • ⁇ corresponding to a certain output channel in the first network layer is 0, it indicates that the output channel is pruned, that is, the output channel is deleted, and the specific operation is to delete the convolution corresponding to the output channel Core; when the ⁇ corresponding to an output channel in the first network layer is 1, it indicates that the output channel is not to be pruned, that is, the channel is reserved, and the specific operation is to retain the convolution kernel corresponding to the output channel .
  • y i 0 represents the second feature data.
  • yi represents the characteristic data output by the l+1th network layer after the channel pruning process is performed on the lth network layer.
  • the above formula (3) is an objective function when determining the channel selection indication information based on the classification loss guidance information and the second feature data of the sample image.
  • the y i here is actually determined based on the different values of ⁇ when fitting the objective function.
  • the convolution kernel of the first network layer is not actually adjusted. .
  • the convolution kernel in any network layer is adjusted based on the finally determined ⁇ .
  • the objective function for example, the Least Absolute Shrinkage and Selection Operator (LASSO) algorithm can be used to implement.
  • LASSO Least Absolute Shrinkage and Selection Operator
  • B refers to the number of remaining channels after channel pruning is performed on the first network layer.
  • B is generally predetermined, and it is used to constrain that the number of remaining channels cannot exceed B after channel pruning is performed on the first network layer.
  • the increase of ⁇ increases the number of 0s in the binary channel selection indicator vector, that is, the number of subtracted channels will increase; the decrease of ⁇ increases the number of 1s in the binary channel selection indicator vector, That is to say, the number of subtracted channels will be reduced; when solving the objective function, we will continue to try the value of ⁇ ; for example, under a certain pruning scheme, gradually increase ⁇ until the constraint condition
  • the convolution kernel of the first network layer After obtaining the channel selection indication information, adjust the convolution kernel of the first network layer based on the channel selection indication information. Exemplarily, if the value of the channel selection indication information corresponding to a certain channel is 0, the convolution kernel corresponding to the channel is deleted; if the value of the channel selection indication information corresponding to a certain channel is 1, then the value of the channel selection indication information corresponding to the channel is retained. The corresponding convolution kernel.
  • the embodiments of the present disclosure also provide another method for determining classification loss guidance information based on loss information and first feature data, including: based on the loss information and The first feature data determines classification loss guidance information and feature importance guidance information.
  • the performing channel pruning processing on any network layer based on the classification loss guide information includes: based on the classification loss guide information, feature importance guide information, and the sample image Determine the channel selection indication information; adjust the convolution kernel in any of the network layers based on the channel selection indication information.
  • the second feature data of the sample image is the feature data output from the next network layer of any one of the network layers when the sample image is processed using the to-be-compressed model.
  • the feature importance guide information is used to indicate the degree of importance of element values at different positions in the feature data.
  • the feature importance guide information may be determined based on the first feature data and predetermined adjustment parameters.
  • the feature importance guide information ⁇ satisfies the following formula (6):
  • is a predetermined constant used to adjust The degree of influence; can be set according to needs. For example, it can be set to 1, 0.9, 1.1, and so on.
  • the i-th channel selection indication information ⁇ satisfies the following formula (7):
  • the channel selection indication information may also be determined only based on the feature importance guide information.
  • the execution of channel pruning processing on any network layer based on the classification loss guidance information may include, for example, the second feature data based on the feature importance guidance information and the sample image , Determine the channel selection indication information; adjust the convolution kernel in any one of the network layers based on the channel selection indication information.
  • the second feature data of the sample image is the feature data output from the next network layer of any one of the network layers when the sample image is processed using the to-be-compressed model.
  • the objective function can be expressed as the following formula (10):
  • the i-th channel is more likely to be deleted during channel pruning of the l-th network layer. In this case, you can use The reconstruction error.
  • the i-th channel is not deleted during channel pruning of the l-th network layer, you can use The reconstruction error. Since in related technologies, the result of channel pruning on the first network layer is determined by many factors, including the spatial position m, the input sample image and the parameters of the model to be compressed, it is difficult to predict whether the first network layer is being pruned.
  • the network layer deletes the channel when the channel is pruned, and then the embodiment of the present disclosure adopts To guide the channel pruning of the first layer of the network layer.
  • the method further includes the following step S104:
  • S104 Perform parameter update processing on the next network layer of any network layer based on the network layer of any network layer after the pruning process has been performed.
  • any network layer is the lth network layer; then the next network layer of the lth network layer is the l+1th network layer.
  • the following method can be used to update the parameters of the l+1th network layer:
  • channel adjustment is performed on each convolution kernel in the first network layer (1+1).
  • the second target model based on the first network layer that has been pruned and the first network layer that has undergone convolution kernel channel adjustment; and use the second target model to obtain the second target model.
  • the first 1+1 network layer in the second target model outputs the third feature data of the sample image; and the second feature data output by any one of the network layers when the image is processed using the model to be compressed, to obtain the first
  • the weight parameter of the l+1 network layer; based on the weight parameter, the original weight parameter of the l+1 network layer is updated.
  • the number of output channels of the l network layer is 6; after a feature map is processed by the l network layer, the output feature map dimension is 6*10*24, which is the input channel of the l+1 network layer The number is also 6; if there are 64 6*3*3 convolution kernels in the l+1 network layer; if one output channel in the l network layer is deleted, the feature map will delete the output channel after the After the first layer of the network layer is processed, the dimension of the output feature map is 5*10*24; under the condition that the output channel of the layer l+1 network layer remains unchanged, the The 64 6*3*3 convolution kernels respectively perform channel deletion, and the final dimension of the 64 convolution kernels in the l+1 network layer is: 5*3*3.
  • the channel of the deleted convolution kernel is consistent with the output channel of the deleted first network layer.
  • the output channels of the l layer network are m1 to m6; the channels of the convolution kernel of the l+1 network layer are m1' to m6' respectively. If the output channel m3 of the l layer network is deleted; correspondingly, To delete the channel m3' of the convolution kernel of the l+1th network layer.
  • the difference between the first target model and the second target model is: in the first target model, the lth network layer is the network layer before the channel pruning operation, and the l+1th network layer is also the original one in the model to be compressed The l+1 network layer; in the second target model, the l network layer is the network layer after the channel pruning operation, and the l+1 network layer is the l+th network layer that has undergone the convolution kernel channel adjustment Layer 1 network layer.
  • the convolution kernels corresponding to some channels have been removed in the first layer of the network layer, the convolution kernels of the first layer of the network layer have also been adjusted accordingly, so adaptability is also required. Adjust the parameters of the l+1 network layer.
  • the channels that have less impact on the layer 1 network layer have been deleted, and the remaining channels are more important channels. Therefore, the remaining channels in the first layer of the network layer can be regarded as equally important. Furthermore, for example, you can make And reduce the classification loss indicator information ⁇ , and minimize the reconstruction error by solving the least squares optimization problem with fixed channel selection indicator information That is, the weight parameter W of the l+1th network layer satisfies the following formula (12):
  • the weight parameter of the layer 1+1 network layer is obtained, and the weight parameter of the layer 1+1 network layer is updated based on the weight parameter.
  • W 0,(l) ,l ⁇ [1,L] are the parameters of the lth network layer, and ⁇ is the parameters of other network layers that will not be pruned (for example, a fully connected layer).
  • Output model M c based on the compression step, and then re-use them training sample images.
  • the final compression model is:
  • the sample image can also be used to fine-tune the compression model.
  • the compression model can be used to obtain the classification result of the sample image, and the classification loss of the sample image can be determined based on the classification result and the classification label of the sample image; based on the classification loss, the parameters of the compression model can be fine-tuned to improve the recognition accuracy of the compressed model .
  • the embodiment of the present disclosure determines the first target model according to the model compression progress during the pruning process of the corresponding channel of any one of the network layers in the multi-layer network layer in the model to be compressed, and uses the first target model to obtain all The loss information of the sample image, and the next network layer of any one of the network layers in the first target model outputs the first feature data of the sample image; based on the loss information and the first feature data , Determine classification loss guidance information, and perform channel pruning processing on any network layer based on the classification loss guidance information.
  • the channel pruning processing of this layer of neural network can be guided based on the classification loss guidance information, so as to avoid a large impact on the loss of the model after the compression is completed, and thus to ensure Compression efficiency can also take into account the compression effect.
  • another embodiment of the present disclosure also uses feature importance guidance information to determine channel selection indication information, and performs channel pruning processing on any network layer based on the channel selection information.
  • feature importance guidance information as a guide for channel pruning of the first layer of the network layer, effectively avoiding the reconstruction error caused by non-informative features to the minimum. This information will be used in the first + The layer 1 network layer is deleted during the channel pruning process, so reasonable results can be obtained.
  • the writing order of the steps does not mean a strict execution order but constitutes any limitation on the implementation process.
  • the specific execution order of each step should be based on its function and possibility.
  • the inner logic is determined.
  • the embodiment of the present disclosure also provides a model compression device corresponding to the model compression method. Since the principle of the device in the embodiment of the present disclosure to solve the problem is similar to the above-mentioned model compression method of the embodiment of the present disclosure, the implementation of the device You can refer to the implementation of the method, and the repetition will not be repeated.
  • An embodiment of the present disclosure also provides an image processing method, including: acquiring a to-be-processed image; using an image processing model determined based on the model compression method provided in any of the foregoing embodiments of the present disclosure to perform image processing tasks on the to-be-processed image .
  • the execution subject of the image processing method provided in the embodiments of the present disclosure is generally a computer device with a certain computing capability.
  • the computer device includes, for example, a terminal device or a server or other processing devices.
  • the terminal device may be a user equipment (UE).
  • UE user equipment
  • Mobile devices user terminals, terminals, cellular phones, cordless phones, personal digital assistants (PDAs), handheld devices, computing devices, in-vehicle devices, wearable devices, etc.
  • the image processing method may be implemented by a processor invoking computer-readable instructions stored in the memory.
  • the image to be processed may be directly collected by a camera device provided on a computer device, or may be obtained from other devices or storage devices through communication.
  • the image processing tasks include, for example, at least one image processing task of action recognition, face recognition, facial emotion recognition, face key point recognition, and living body recognition.
  • the embodiment of the present disclosure can determine the sample image and the label corresponding to each sample image based on a predetermined image processing task; train the model to be compressed based on the sample image and the label corresponding to each sample image.
  • the provided model compression method performs compression processing on it; after the compression model is obtained, some sample images can be used to fine-tune the compression model to obtain a trained image processing model.
  • the image processing method provided by the embodiment of the present disclosure uses an image processing model determined based on the model compression method provided by the embodiment of the present disclosure to perform image processing tasks. Since the model compression method provided by the embodiments of the present disclosure can bring better compression effects, that is, the compression model obtained has a smaller model scale and lower computational complexity than the compression model obtained by the current technology, so it is more suitable for Embedded devices perform image processing.
  • the device includes: an acquisition module 21, a determination module 22, and a pruning module 23; wherein,
  • the acquisition module 21 is configured to target any one of the at least one network layer in the multi-layer network layer in the to-be-compressed model, according to the pruning process of the corresponding channel of the any network layer.
  • Model compression progress, determine the first target model, and use the first target model to obtain the loss information of the sample image, and the output data of the next network layer of any network layer in the first target model The first feature data of the sample image;
  • the determining module 22 is configured to determine classification loss guidance information based on the loss information and the first characteristic data
  • the pruning module 23 is configured to perform channel pruning processing on any network layer based on the classification loss guide information.
  • the first target model is determined according to the model compression progress during the pruning process of the corresponding channel of any network layer, and the first target model is used to obtain the loss information of the sample image, and the first The next network layer of any one of the network layers in the target model outputs the first feature data of the sample image; based on the loss information and the first feature data, the classification loss guidance information is determined, and based on all According to the classification loss guidance information, channel pruning processing is performed on any one of the network layers.
  • the channel pruning processing of this layer of neural network can be guided based on the classification loss guidance information, so as to avoid a large impact on the loss of the model after the compression is completed, and thus to ensure Compression efficiency can also take into account the compression effect.
  • the device further includes: an update module 24, configured to: after the pruning module 23 performs channel pruning processing on any one of the network layers, based on the pruning After the processed any one of the network layers, a parameter update process is performed on the next network layer of the any one of the network layers.
  • the determining module 22 is configured to determine classification loss guidance information and feature importance guidance information based on the loss information and the first feature data.
  • the determining module 22 is configured to determine the feature importance guide information based on the first feature data and predetermined adjustment parameters.
  • the first target model is: the to-be-compressed model
  • the first target model includes: the network layer that has been processed by channel pruning, and other models in the to-be-compressed model The network layer that has not been pruned.
  • the acquiring module 21 is configured to use the first target model to acquire the classification loss prediction result of the sample image; based on the classification loss prediction result of the sample image, the sample The real classification label corresponding to the image and the predetermined loss function are used to obtain the loss information of the sample image.
  • the determining module 22 is configured to use the back propagation of the loss information in the first target model to determine the partial derivative of the loss function with respect to the first feature data;
  • the partial derivative is determined as the classification loss guidance information.
  • the pruning module 23 is configured to determine channel selection instruction information based on the classification loss guide information and the second feature data of the sample image; or, based on the feature importance guide information And the second feature data of the sample image, determining channel selection indication information; or, based on the classification loss guidance information, feature importance guidance information, and the second feature data of the sample image, determining channel selection indication information; Based on the channel selection indication information, adjust the convolution kernel in any of the network layers; wherein, the channel selection indication information is used to indicate the channel to be retained; the second feature data of the sample image is used to The feature data output from the next network layer of any one of the network layers when the sample image is processed by the compression model.
  • the update module 24 is configured to perform a pruning process on each of the convolution kernels in the next layer of the network based on the pruning process.
  • the channel adjustment based on the any layer of the network that has been pruned, and the next layer of the network layer that has been adjusted for the convolution kernel channel, determine the second target model, and use the second target Model to obtain the third feature data of the sample image at the next network layer of the any network layer after the pruning process has been performed in the second target model; and use the model to be compressed to
  • the second feature data output by the network layer of any one layer is used to obtain the weight parameter of the next layer network layer; based on the weight parameter, the original weight parameter of the next layer network layer Perform update processing.
  • model compression device provided in the foregoing embodiment performs model compression
  • only the division of the above-mentioned program modules is used as an example.
  • the above-mentioned processing can be allocated to different program modules as needed, that is, the internal structure of the device Divide into different program modules to complete all or part of the processing described above.
  • the model compression device provided by the foregoing embodiment and the model compression method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
  • An embodiment of the present disclosure further provides an image processing device, the image processing device includes: an acquisition unit and a processing unit; the acquisition unit is configured to acquire an image to be processed; the processing unit is configured to use any of the foregoing embodiments of the present disclosure
  • the image processing model determined by the provided model compression method performs image processing tasks on the image to be processed.
  • the embodiment of the present disclosure also provides a computer device.
  • FIG. 3 it is a schematic structural diagram of the computer device 30 provided by the embodiment of the present disclosure.
  • the computer device 30 includes a processor 31 and a memory 32 connected to each other.
  • the memory 32 stores computer-readable instructions executable by the processor 31.
  • the computer-readable instructions are executed by the processor 31 to perform model compression as provided in any of the foregoing embodiments of the present disclosure.
  • the steps of the method; or when the computer-readable instructions are executed by the processor 31, the image processing model determined by the model compression method provided by the embodiment of the present disclosure is used to perform image processing tasks on the image to be processed.
  • bus system is used to realize the connection and communication between these components.
  • the method disclosed in the foregoing embodiment of the present invention may be applied to the processor 31 or implemented by the processor 31.
  • the processor 31 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 31 or instructions in the form of software.
  • the aforementioned processor 31 may be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the like.
  • the processor 31 may implement or execute various methods, steps, and logical block diagrams disclosed in the embodiments of the present invention.
  • the general-purpose processor may be a microprocessor or any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention can be directly embodied as execution and completion by a hardware decoding processor, or execution and completion by a combination of hardware and software modules in the decoding processor.
  • the software module may be located in a storage medium, and the storage medium is located in the memory 32.
  • the processor 31 reads the information in the memory 32 and completes the steps of the foregoing method in combination with its hardware.
  • the memory 32 may be a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memory.
  • the embodiment of the present disclosure also provides a computer-readable storage medium having a computer program stored on the computer-readable storage medium, and the computer program executes the steps of the model compression method provided by the embodiment of the present disclosure when the computer program is run by a processor, or, When the computer program is run by the processor, it executes the image processing model determined by the model compression method provided by the embodiment of the present disclosure, and executes the image processing task.
  • the computer program product provided by the embodiment of the present disclosure includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the steps of the model compression method or the image processing method described in the above method embodiment
  • the instructions included in the program code can be used to execute the steps of the model compression method or the image processing method described in the above method embodiment
  • the embodiments of the present disclosure also provide a computer program, which, when executed by a processor, implements the steps of any model compression method or image processing method of the foregoing embodiments.
  • the computer program product can be specifically implemented by hardware, software, or a combination thereof.
  • the computer program product is specifically embodied as a computer storage medium.
  • the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc. Wait.
  • SDK software development kit
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a nonvolatile computer readable storage medium executable by a processor.
  • the technical solution of the present disclosure essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present disclosure.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Image Analysis (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Image Processing (AREA)
  • Holo Graphy (AREA)

Abstract

一种模型压缩方法、图像处理方法及装置,该方法包括:针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取所述样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据(S101);基于所述损失信息以及所述第一特征数据,确定分类损失指导信息(S102);基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理(S103)。

Description

一种模型压缩方法、图像处理方法以及装置
相关申请的交叉引用
本公开基于申请号为202010286175.9、申请日为2020年4月13日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此以引入方式并入本公开。
技术领域
本公开涉及机器学习技术领域,具体涉及一种模型压缩方法、图像处理方法以及装置。
背景技术
随着神经网络在各个领域的广泛应用,推动了一系列智能产品的落地。为了让神经网络具有更好的效果,神经网络的层数不断增加,每层神经网络中的参数也越来越多,例如图像处理神经网络中,为了提取到图像中更多的特征,每层神经网络往往需要通过数十个卷积核来对图像进行卷积处理。这造成基于神经网络的产品大多非常依赖良好的运行环境,造成神经网络模型的应用范围受到限制,例如无法实现嵌入式应用。为了实现神经网络模型的嵌入式应用,需要将神经网络模型的体积压缩到一定范围以下。
通道剪枝是当前一种常见的模型压缩方法,该方法通过在训练完模型后,去掉网络模型中权重较小的参数,以实现对神经网络模型的压缩。
发明内容
本公开实施例至少提供一种模型压缩方法、图像处理方法以及装置。
第一方面,本公开实施例提供了一种模型压缩方法,所述方法包括:针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;基于所述损失信息以及所述第一特征数据,确定分类损失指导信息;基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。
这样,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取所述样本图像的损失信息,以及第一目标模 型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;然后基于所述损失信息、以及所述第一特征数据,确定分类损失指导信息,并基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。从而能够在每次仅针对一层神经网络进行剪枝,且剪枝的时候基于分类损失指导信息指导该层神经网络的通道剪枝处理,避免在压缩完成后对模型的损失造成较大影响,进而能够保证压缩效率,又能够兼顾压缩效果。
在一种可选的实施方式中,在对所述任一层网络层执行通道剪枝处理后,所述方法还包括:基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理。
这样,在对第l层网络层进行了通道剪枝操作后,适应性的调整了第l+1层网络层的参数。
在一种可选的实施方式中,所述基于所述损失信息以及所述第一特征数据,确定分类损失指导信息,包括:基于所述损失信息以及所述第一特征数据,确定分类损失指导信息以及特征重要性指导信息。
这样,利用了特征重要性指导信息来确定通道选择指示信息,并基于通道选择信息来对所述任一层网络层执行通道剪枝处理。使用特征重要性指导信息作为对第l层网络层进行通道剪枝时的指导,有效地避免了将不具备信息性的特征所造成的重构误差降到最低,这些信息将在对第l+1层网络层进行通道剪枝过程中被删除,因此可以获得合理的结果。
在一种可选的实施方式中,基于所述损失信息以及所述第一特征数据,确定特征重要性指导信息,包括:基于所述第一特征数据以及预先确定的调整参数,确定所述特征重要性指导信息。
这样,基于第一特征数据中各个元素的元素值的大小来确定特征重要性指导信息,针对某个通道而言,第一特征数据中各个元素的元素值越大,则认为该通道越重要;第一特征数据中各个元素的元素值越小,则认为该通道越不重要,进而基于该方式对通道进行调整,解决下一层特征消除问题,使得更合理的通道剪枝结果。
在一种可选的实施方式中,针对所述任一层网络层为待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型为:所述待压缩模型;针对所述任一层网络层并非待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型包括:已经进行通道剪枝处理的网络层,以及所述待压缩模型中其他未进行通道剪枝处理的网络层。
在一种可选的实施方式中,所述利用所述第一目标模型,获取所述样本图像的损失信息,包括:利用所述第一目标模型,获取样本图像的分类损失预测结果;基于所述样本图像的分类损失预测结果、所述样本图像对应的真实分类标签以及预先确定的损失函数,获取所述样本图像的损失信息。
在一种可选的实施方式中,所述基于所述损失信息、以及所述第一特征数据,确定 分类损失指导信息,包括:利用所述损失信息在所述第一目标模型中的反向传播,确定损失函数相对于所述第一特征数据的偏导数;将所述偏导数确定为所述分类损失指导信息。
在一种可选的实施方式中,所述基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理,包括:基于所述分类损失指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;或者,基于特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;又或者,基于所述分类损失指导信息、特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;基于所述通道选择指示信息,调整所述任一网络层中的卷积核;其中,所述通道选择指示信息用于指示要保留的通道;所述样本图像的第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
在一种可选的实施方式中,所述基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理,包括:基于已进行剪枝处理后的所述任一层网络,对所述任一层网络的下一层网络中的各个卷积核的进行通道调整;基于已进行剪枝处理后的所述任一层网络、以及已进行卷积核通道调整的所述下一层网络层,确定第二目标模型,并利用所述第二目标模型,获取所述第二目标模型中的所述已进行剪枝处理后的所述任一层网络层的下一层网络层输出所述样本图像的第三特征数据;以及利用待压缩模型对图像进行处理时的所述任一层网络层输出的第二特征数据,得到所述下一层层网络层的权重参数;基于所述权重参数,对所述下一层网络层的原始权重参数进行更新处理。
第二方面,本公开实施例还提供一种图像处理方法,包括:获取待处理图像;利用基于第一方面或第一方面任一项所确定的图像处理模型,对所述待处理图像执行图像处理任务。
第三方面,本公开实施例提供一种模型压缩装置,所述装置包括:获取模块,配置为针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;确定模块,配置为基于所述损失信息以及所述第一特征数据,确定分类损失指导信息;剪枝模块,配置为基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。
在一种可选的实施方式中,所述装置还包括:更新模块,配置为在所述剪枝模块对所述任一层网络层执行通道剪枝处理后,基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理。
在一种可选的实施方式中,所述确定模块,配置为基于所述损失信息以及所述第一特征数据,确定分类损失指导信息以及特征重要性指导信息。
在一种可选的实施方式中,所述确定模块,配置为基于所述第一特征数据以及预先 确定的调整参数,确定所述特征重要性指导信息。
在一种可选的实施方式中,针对所述任一层网络层为待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型为:所述待压缩模型;针对所述任一层网络层并非待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型包括:已经进行通道剪枝处理的网络层,以及所述待压缩模型中其他未进行通道剪枝处理的网络层。
在一种可选的实施方式中,所述获取模块,配置为利用所述第一目标模型,获取所述样本图像的分类损失预测结果;基于所述样本图像的分类损失预测结果、与所述样本图像对应的真实分类标签,以及预先确定的损失函数,获取所述样本图像的损失信息。
在一种可选的实施方式中,所述确定模块,配置为利用所述损失信息在所述第一目标模型中的反向传播,确定损失函数相对于所述第一特征数据的偏导数;将所述偏导数确定为所述分类损失指导信息。
在一种可选的实施方式中,所述剪枝模块,配置为基于所述分类损失指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;或者,基于特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;又或者,基于所述分类损失指导信息、特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;基于所述通道选择指示信息,调整所述任一网络层中的卷积核;其中,所述通道选择指示信息用于指示要保留的通道;所述样本图像的所述第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
在一种可选的实施方式中,所述更新模块,配置为基于已进行剪枝处理后的所述任一层网络,对所述任一层网络的下一层网络中的各个卷积核的进行通道调整;基于已进行剪枝处理后的所述任一层网络、以及已进行卷积核通道调整的所述下一层网络层,确定第二目标模型,并利用所述第二目标模型,获取所述第二目标模型中的所述已进行剪枝处理后的所述任一层网络层的下一层网络层输出所述样本图像的第三特征数据;以及利用待压缩模型对图像进行处理时的所述任一层网络层输出的第二特征数据,得到所述下一层层网络层的权重参数;基于所述权重参数,对所述下一层网络层的原始权重参数进行更新处理。
第四方面,本公开实施例还提供一种图像处理装置,包括:获取单元,配置为获取待处理图像;处理单元,配置为利用基于第一方面,或第一方面中任一项确定的图像处理模型,对所述待处理图像执行图像处理任务。
第五方面,本公开实施例还提供一种计算机设备,包括:相互连接的处理器和存储器,所述存储器存储有所述处理器可执行的计算机可读指令,当计算机设备运行时,所述计算机可读指令被所述处理器执行时执行本公开实施例上述第一方面,或第一方面中任一种可能的实施方式中的步骤,或者,所述计算机可读指令被所述处理器执行时执行本公开实施例上述第二方面,或第二方面中任一种可能的实施方式中的步骤。
第六方面,本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质 上存储有计算机程序,该计算机程序被处理器运行时执行本公开实施例上述第一方面,或第一方面中任一种可能的实施方式中的步骤,或者,该计算机程序被处理器运行时执行本公开实施例上述第二方面,或第二方面中任一种可能的实施方式中的步骤。
第七方面,本公开实施例还提供一种计算机程序,所述计算机程序被处理器执行时实现本公开实施例上述第一方面,或第一方面中任一种可能的实施方式中的步骤,或者,该计算机程序被处理器运行时执行本公开实施例上述第二方面,或第二方面中任一种可能的实施方式中的步骤。
为使本公开实施例的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。
附图说明
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。
图1示出了本公开实施例所提供的一种模型压缩方法的流程图;
图2示出了本公开实施例所提供的一种模型压缩装置的示意图;
图3示出了本公开实施例所提供的一种计算机设备的示意图。
具体实施方式
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。
经研究发现,对神经网络模型进行通道剪枝的方法,通常有两种,分别为通过最小化损失函数的剪枝的方法和层接层的剪枝方法。最小化损失函数的通道剪枝方法通过迭代地删除各个神经网络层通道,以使得最终的压缩模型的最终损失影响最小,也即,在每次迭代过程中,都会对所有的神经网络层进行处理。该方法对神经网络模型的压缩效果好;但是,为了评估各通道对最终损耗的影响,需要频繁执行微调过程,造成剪枝速度慢,效率低的问题。而层接层的剪枝方法,在对某一层神经网络层进行剪枝时,会通 过最小化下一层神经网络层输出的特征数据的重构误差来选择要删除的通道并调整模型参数。由于该方法可以每次仅针对一层神经网络层进行剪枝操作,并且针对每层神经网络层的微调过程仅执行一次,因而剪枝速度快;但在对每层神经网络层的通道进行通道剪枝操作时,对通道的调整可能对神经网络模型在压缩完成后的损失造成较大影响,导致对通道的调整结果不够理想,导致最终的压缩效果较差。进而,当前对神经网络模型进行通道剪枝的方法,存在效率和压缩效果无法兼顾的问题。
另外,在对神经网络的第l层网络层进行通道剪枝操作之后,会对第l+1层网络层进行通道剪枝操作,进行通道剪枝作操作之后的第l层网络层的输出特征,将成为第l+1层网络层的输入特征;若在对第l+1层网络层进行通道剪枝操作的时候,删除了第l+1层网络层的输入特征中某些重构特征,这些重构特征是在对第l层网络层进行通道剪枝操作时重构得到的,这样意味着没有必要在对第l层网络层进行通道剪枝操作的时候重构这些在第l+1层网络层被删除的重构特征,这也就意味着,在对第l层网络层进行通道剪枝操作时,选择删除的某些通道是不准确的,进而会由于这种情况造成得到的压缩模型实际上并非是最优化的模型,其还有可能被优化的空间。该问题称为下一层特征消除问题。
针对以上方案所存在的缺陷,均是发明人在经过实践并仔细研究后得出的结果,因此,上述问题的发现过程以及下文中本公开实施例针对上述问题所提出的解决方案,都应该是发明人在本公开实施例过程中对本公开实施例做出的贡献。
基于上述研究,本公开实施例提供了一种模型压缩方法以及装置,用于对待压缩模型中的多层网络层中的至少一层网络层进行通道剪枝处理,并针对至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取所述样本图像的损失信息,以及第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;然后基于所述损失信息、以及所述第一特征数据,确定分类损失指导信息,并基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。从而能够在每次仅针对一层神经网络进行剪枝的时候,基于分类损失指导信息指导该层神经网络的通道剪枝处理,避免在压缩完成后对模型的损失造成较大影响,进而能够保证压缩效率,又能够兼顾压缩效果。
下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开实施例的详细描述并非旨在限制要求保护的本公开实施例的范围,而是仅仅表示本公开的选定实施例。基于本公开实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开实施例保护的范围。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。
为便于对本公开实施例进行理解,首先对本公开实施例所公开的一种模型压缩方法进行详细介绍,本公开实施例所提供的模型压缩方法的执行主体一般为具有一定计算能力的计算机设备,该计算机设备例如包括:终端设备或服务器或其它处理设备,终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、终端、蜂窝电话、无绳电话、个人数字处理(Personal Digital Assistant,PDA)、手持设备、计算设备、车载设备、可穿戴设备等。在一些可能的实现方式中,该模型压缩方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。
首先对网络层中通道的概念进行解释:针对任一层网络层,假如该网络层为卷积层;且输入至该卷积层的输入特征图维度为4*10*24,其中,4表示该输入特征图的通道数为4;10*24表示特征图在各个通道中的尺寸;通过64*4*3*3的卷积核对该输入特征图进行卷积处理,其中64表示卷积核的数量,每一个卷积核对应一个通道;4表示卷积核的通道数,3*3表示卷积核的尺寸。输出特征图为:64*10*24;对该层网络层进行通道剪枝处理,即为减少卷积核的数量,使得得到的输出特征图的通道数减少,进而降低卷积处理过程中的计算量、以及模型的体积。例如在对该层网络层进行通道剪枝处理时,减去该层网络层中的5个卷积核,则卷积核就会变成:59*4*3*3;最终,得到的输出特征图为:59*10*24。
下面对本公开实施例提供的模型压缩方法加以详细说明。
参见图1所示,为本公开实施例提供的模型压缩方法的流程图,该方法用于对待压缩模型中的多层网络层中的至少一层网络层进行通道剪枝处理;一种可能的实施方式中,若待压缩模型中包括L层网络层,可以将L层网络层中的任意m层网络层作为要进行通道剪枝处理的网络层。其中,m为大于0、小于L的正整数。
所述方法包括步骤S101~S103,其中:
S101:针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取所述样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据。
S102:基于所述损失信息以及所述第一特征数据,确定分类损失指导信息。
S103:基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。
下面分别对上述S101~S103加以详细说明。
I:在上述S101中,模型压缩进度,用于指示当前进行剪枝处理的网络层在待压缩模型中的位置,以及在此之前,已经进行过通道剪枝处理的网络层在待压缩模型中的位置。
在一些可选实施例中,在对待压缩模型中的所有网络层均进行通道剪枝处理的时候,模型压缩进度,可以仅用于指示当前进行剪枝处理的网络层在待压缩模型中的位置。
假设上述任一层网络层为待压缩模型中的第l层网络层,在第l层网络层是待压缩模型中待进行通道剪枝处理的第一层网络层的情况下,则对应的第一目标模型包括:待压缩模型。
在一种可能的实施例中,l=1,也即,第l层网络层是待压缩模型中的第一层网络层;在第l层网络层之前不存在其他的网络层,要对第l层网络层进行通道剪枝处理,则第l层网络层即为待压缩模型中待进行通道剪枝处理的第一层网络层。此时,第一目标模型即为待压缩模型。
在另一种可能的实施例中,l为大于1的正整数,例如l=5,也即第l层网络层是待压缩模型中的第5层网络层;在第l层网络层之前的第1层~第4层网络层均不需要进行通道剪枝处理,则第l层网络层也为待压缩模型中待进行通道剪枝处理的第一层网络层。在该种情况下,第一目标模型也为待压缩模型。
在第l层网络层并非待压缩模型中待进行通道剪枝处理的第一层网络层的情况下,则对应的第一目标模型包括:已经进行通道剪枝处理的网络层,以及待压缩模型中其他未进行通道剪枝处理的网络层。
例如,某待压缩模型中包括L层网络层,分别记为a1~aL;其中,需要对其中的第1层网络层a1、第3层网络层a3、第5层网络层a5共三层网络层进行通道剪枝处理。在l=5的情况下,由于已经完成了对a1的通道剪枝处理,得到已进行通道剪枝处理后的网络层a1’;也已经完成了对a3的通道剪枝处理,得到进行通道剪枝处理后的网络层a3’,此时第一目标模型包括:a1’、a2、a3’、以及a4~aL。
本公开实施例以待压缩模型中包括L层网络层,对待处理模型中的第1层网络层至第L-1层网络层进行通道剪枝处理为例进行说明。
在对第l层网络层进行通道剪枝处理时:
所述利用所述第一目标模型,获取样本图像的损失信息,例如可包括:将样本图像输入至第一目标模型中,利用第一目标模型,获取样本图像的分类损失预测结果,基于所述样本图像的分类损失预测结果,与所述样本图像对应的真实分类标签,以及预先确定的损失函数,获取所述样本图像的损失信息。
在该示例中,第一目标模型的损失信息例如表示为如下公式(1):
C=L c[N(Y;W),g]        (1)
其中,C表示第l+1层网络层的输出特征为Y时,第一目标模型的分类损失函数;L c表示交叉熵损失函数;g表示样本图像的真实分类标签。N表示在对第l层网络层进行通道剪枝处理时,第l+2层网络层至第L层网络层所映射成的函数;W为该函数的参数,Y即为该函数的输入。
进而,通过上述过程确定样本图像的损失信息。上述损失信息是在对第1层网络层至第l-1层网络层进行了通道剪枝处理后,由已经进行了通道剪枝处理的网络层和未进行通道剪枝处理的网络层构成的第一目标模型对样本图像进行分类时所得到的损失信 息。
第一特征数据是从第一目标模型中的第l+1层网络层输出的特征数据。本公开实施例中,在确定了第一目标模型后,利用第一目标模型对样本图像进行图像处理,每一层网络层均能够得到表征样本图像的特征的特征数据;将第一目标模型中第l+1层网络层输出的特征数据确定为第一特征数据。
II:在上述S102中,分类损失指导信息,用于表征要进行通道剪枝处理的网络层中各个卷积核的重要性程度。
在一些实施例中,可以采用下述方式得到分类损失指示信息:利用损失信息在所述第一目标模型中的反向传播,确定损失函数相对于所述第一特征数据的偏导数;将所述偏导数确定为所述分类损失指导信息。
示例性的,例如分类损失指导信息α满足下述公式(2)
Figure PCTCN2020088252-appb-000001
其中,C表示损失函数;y i表示在对第l层网络层进行通道剪枝处理后,第l+1层网络层在第i个通道输出的特征数据;
Figure PCTCN2020088252-appb-000002
表示在对第l层网络层进行通道剪枝处理前,第l+1层网络层在第i个通道输出的特征数据,也即,第一目标模型的第l+1层网络层在第i个通道输出的特征数据。
这里需要注意的是,由于在对第l层网络层进行通道剪枝处理的时候,需要不断的尝试减去第l层网络层中的某些通道,以形成多种剪枝方案,最终拟合剪枝处理的结果。因此,在拟合剪枝处理的过程中,y i是一个变量;不同的剪枝方案,对应有不同的y i
Figure PCTCN2020088252-appb-000003
表示使用损失函数对变量y i求偏导,其约束条件是指分类损失指导信息α的值为在y i=y i *的情况下确定的。进而,该步骤表述为基于所述损失信息、以及所述第一特征数据,确定分类损失指导信息。
III:在上述S103中,在确定了分类损失指导信息后,能够基于该分类损失指导信息对第l层网络层进行通道剪枝处理。
示例性的,可以采用下述方式对任一层网络层进行通道剪枝处理:
基于所述分类损失指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;所述通道选择指示信息用于指示要保留的通道;所述样本图像的所述第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据;
基于所述通道选择指示信息,调整所述任一网络层中的卷积核。
在具体实施中,例如若对第l层网络层进行通道剪枝处理,则首先可以利用待压缩模型对样本图像进行处理时,得到待压缩模型的第l+1层网络层输出的样本图像的第二特征数据,再基于分类损失指导信息以及该第二特征数据,确定通道选择指示信息。
示例性的,第i个通道选择指示信息β满足下述公式(3):
Figure PCTCN2020088252-appb-000004
其中,c out表示第l+1层网络层的输出通道数;i表示输出特征的第i个通道。α表示分类损失指导信息,其满足上述公式(2)。
Figure PCTCN2020088252-appb-000005
是包含一组二进制通道选择指示符的向量中的一个元素,在该公式中,其与第l层网络层输出特征的一个输出通道对应,用于指示对应的输出通道是否需要被剪枝,在该向量中包括的元素的数量与第l+1层网络层的输入通道数,也即与第l层网络层的输出通道数相同。其中,c in表示第l+1层网络层的输入通道数。其与第l层网络层的输出通道一一对应。
例如,当与第l层网络层中的某个输出通道对应的β为0时,指示对该输出通道进行剪枝,也即删除该输出通道,具体操作为删除与该输出通道对应的卷积核;当与第l层网络层中的某个输出通道对应的β为1时,指示不对该输出通道进行剪枝,也即保留该通道,具体操作为保留与该输出通道对应的卷积核。
其中,y i 0表示第二特征数据。y i表示在对第l层网络层进行通道剪枝处理后、第l+1层网络层输出的特征数据。需要说明的是,上述公式(3)为在基于所述分类损失指导信息和所述样本图像的第二特征数据,确定通道选择指示信息时的目标函数。这里的y i实际上是在拟合目标函数时,基于的β不同值所确定的,在对目标函数进行拟合的过程中,实际上并未对第l层网络层的卷积核进行调整。在基于该目标函数确定了β后,才会基于最终确定的β调整所述任一网络层中的卷积核。在拟合目标函数时,例如可以采用最小绝对收缩选择算子(Least Absolute Shrinkage and Selection Operator,LASSO)算法来实现。
其中,
Figure PCTCN2020088252-appb-000006
表示重构误差。具体地,在对第l层网络层进行通道剪枝的过程中、在对第l层网络层进行通道剪枝前和通道剪枝后,第l+1层网络层输出的特征数据之间的误差要尽量小。
其中,||β|| 0表示β的L0范数。B是指在对第l层网络层进行通道剪枝后,剩余通道的数量。这里,B一般是预先确定的,其用于约束在对第l层网络层进行通道剪枝后,剩余的通道数量不能超出B。
在另一实施例中,由于求解上述公式(3)是一个非确定多项式(Non-Deterministic Polynomial Problems,NP)难题,可以将L0范数正则化放宽为L1范数正则化,并得出以下目标函数(4):
Figure PCTCN2020088252-appb-000007
其中,λ增加,使得二进制通道选择指示符的向量中的0的数量增加,也即减去的 通道的数量会增加;λ减小,使得二进制通道选择指示符的向量中的1的数量增加,也即减去的通道的数量会减少;在求解目标函数时不断尝试λ的取值;例如在某种剪枝方案下逐渐增加λ,直至满足约束条件||β|| 0≤B。
其中,||β|| 1表示β的L1范数。其他参数参照针对公式(3)的描述,在此不再赘述。
另外,考虑到各个通道中空间位置M的总和以及位置m的索引,上述公式(3)还可以表示成下述公式(5)的形式:
Figure PCTCN2020088252-appb-000008
其中,
Figure PCTCN2020088252-appb-000009
表示待压缩模型的第l+1层网络层在第i个通道的第m个位置的输出特征;y i,m表示在对第l层网络层进行通道剪枝处理后、第l+1层网络层在第i个通道的第m个位置输出的特征数据。其他参数参照针对公式(3)的描述,在此不再赘述。
在得到通道选择指示信息后,基于该通道选择指示信息,调整第l层网络层的卷积核。示例性的,如某一通道对应的通道选择指示信息的值为0,则删除与该通道对应的卷积核;若某一通道对应的通道选择指示信息的值为1,则保留与该通道对应的卷积核。
为了解决本公开实施例中提出的下一层特征消除问题,本公开实施例还提供另一种基于损失信息以及第一特征数据,确定分类损失指导信息的方法,包括:基于所述损失信息以及所述第一特征数据,确定分类损失指导信息以及特征重要性指导信息。
在该种情况下,所述基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理,包括:基于所述分类损失指导信息、特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;基于所述通道选择指示信息,调整所述任一网络层中的卷积核。所述样本图像的第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
这里,特征重要性指导信息用于指示特征数据中不同位置的元素值的重要性程度。示例性的,可以基于第一特征数据以及预先确定的调整参数,确定特征重要性指导信息。
例如,特征重要性指导信息θ满足下述公式(6):
Figure PCTCN2020088252-appb-000010
其中,γ为一预先确定的常数,用于调节
Figure PCTCN2020088252-appb-000011
的影响程度;可以根据需要进行设定。例如可以将其设定为1、0.9、1.1等。
则此时,该第i个通道选择指示信息β满足下述公式(7):
Figure PCTCN2020088252-appb-000012
其他参数参照上述公式(3)的描述,在此不再赘述。
类似的,将上述公式(7)中的L0范数正则化放宽为L1范数正则化后,可以得出下述目标函数(8):
Figure PCTCN2020088252-appb-000013
另外,考虑到各个通道中空间位置M的总和以及位置m的索引,上述公式(7)还可以表示成下述公式(9)的形式:
Figure PCTCN2020088252-appb-000014
其他参数参照上述公式(5)的描述,在此不再赘述。
另外,在本公开另一实施例中,也可以仅仅基于特征重要性指导信息确定通道选择指示信息。
在该种情况下,所述基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理,例如可以包括:基于特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;基于所述通道选择指示信息,调整所述任一网络层中的卷积核。所述样本图像的第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
示例性的,目标函数可以表示为下述公式(10):
Figure PCTCN2020088252-appb-000015
该目标函数可以等效地重写如下述公式(11):
Figure PCTCN2020088252-appb-000016
其中,对于大多数空间位置m,
Figure PCTCN2020088252-appb-000017
时,第i个通道更有可能在对第l层网络层进行通道剪枝时被删除。在这种情况下,可以使用
Figure PCTCN2020088252-appb-000018
的重构误差。另一方面,如果在对第l层网络层进行通道剪枝时、第i个通道没有被删除,可以使用
Figure PCTCN2020088252-appb-000019
的重构误差。由于在相关技术中,对第l层网络层进行通道剪枝的结果是由许多因素决定的,包括空间位置m、输入的样本图像和待压缩模型的参数,因此很难预测是否在对第l层网络层进行通道剪枝时删除该通道,进而本公开实施例中采用
Figure PCTCN2020088252-appb-000020
来指导对第l层网络层的通道剪枝。
本公开另一实施例中,在基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理后,还包括下述步骤S104:
S104:基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理。
在具体实施中,例如任一层网络层为第l层网络层;则第l层网络层的下一层网络层为第l+1层网络层。例如可以采用下述方式对第l+1层网络层进行参数更新处理:
基于已进行剪枝处理后的第l层网络层,对所述第l+1层网络层中的各个卷积核进 行通道调整。
基于已进行剪枝处理后的第l层网络层、以及进行了卷积核通道调整的第l+1层网络层,确定第二目标模型;并利用所述第二目标模型,获取所述第二目标模型中的第l+1层网络层输出所述样本图像的第三特征数据;以及利用待压缩模型对图像进行处理时的所述任一层网络层输出的第二特征数据,得到第l+1层网络层的权重参数;基于所述权重参数,对第l+1层网络层的原始权重参数进行更新处理。
在具体实施中,由于要保持第l层网络层的输出通道和第l+1层网络层的输入通道数量的一致;当第l层网络层的输出通道数量发生变化时,需要调整第l+1层网络层的输入通道数量。
例如,第l层网络层的输出通道数量为6;某特征图在经过第l层网络层处理后,输出特征图维度为6*10*24,也即第l+1层网络层的输入通道数也为6;若第l+1层网络层中有64个6*3*3的卷积核;若删除第l层网络层中的1个输出通道,则特征图在经过删除了输出通道后的第l层网络层处理后,输出的特征图维度为5*10*24;在保证l+1层网络层的输出通道不变的情况下,需要对第l+1层网络层中的64个6*3*3的卷积核分别进行通道删除,最终第l+1层网络层中的64个卷积核的维度为:5*3*3。
其中,删除的卷积核的通道,与删除的第l层网络层的输出通道一致。
如第l层网络的输出通道分别为m1至m6;第l+1层网络层的卷积核的通道分别为m1’至m6’,若将第l层网络的输出通道m3删除;对应的,要将第l+1层网络层的卷积核的通道m3’删除。
在对l+1层网络层的卷积核进行通道调整后,基于进行了剪枝处理后的第l层网络、以及已进行卷积核通道调整的第l+1层网络层,确定第二目标模型。
第一目标模型和第二目标模型的区别在于:第一目标模型中,第l层网络层是经过通道剪枝操作前的网络层,且第l+1层网络层也是待压缩模型中原始的第l+1层网络层;在第二目标模型中,第l层网络层是经过通道剪枝操作后的网络层,第l+1层网络层是进行了卷积核通道调整的第l+1层网络层。其具体构成可以参见上述实施例描述,在此不再赘述。
在一些可选实施例中,由于在第l层网络层中已经去除了某些通道对应的卷积核,第l+1层网络层的卷积核也进行了相应调整,因此还需要适应性的调整第l+1层网络层的参数。
在一些可选实施例中,在对第l层网络层执行了通道剪枝操作后,由于对第l层网络层影响较小的通道已经被删除,剩下的其他通道都是较为重要的通道,因此可以将第l层网络层中剩下的各个通道视为同等重要。进而,例如可以令
Figure PCTCN2020088252-appb-000021
并降低分类损失指示信息α,并通过解决具有固定通道选择指示信息的最小二乘优化问题来最小化重构误差
Figure PCTCN2020088252-appb-000022
也即,第l+1层网络层的权重参数W满足下述公式(12):
Figure PCTCN2020088252-appb-000023
进而根据上述公式(12)得到第l+1层网络层的权重参数,并基于该权重参数对第l+1层网络层的权重参数进行更新处理。
例如:输入待压缩模型M u,其中M u={W 0,(1),W 0,(1),…,W 0,(L),Θ},
其中W 0,(l),l∈[1,L]是第l层网络层的参数,Θ是不会被修剪的其他网络层(例如,全连接层)的参数。
基于下述步骤输出压缩模型M c,然后重新使用样本图像对其进行训练。
1:利用待压缩模型为样本图像提取第1层至第L层网络层中、每层网络层分别对应的第二特征数据Y 0,(1),Y 0,(2),…,Y 0,(L)。其中,
Figure PCTCN2020088252-appb-000024
表示在对第l层网络层进行通道剪枝处理时、第l+1层网络层对应的特征数据Y 0,(l+1)中的第i个输出通道输出的特征数据;
2:设置M c=M u={W 0,(1),W 0,(2),…,W 0,(L),Θ};
3:从l=1至l=L-1,执行下述步骤4至步骤9:
4:根据当前的压缩模型M c,使用正向传播来计算
Figure PCTCN2020088252-appb-000025
其中上标l+1表示第l+1层网络层。
5:使用反向传播计算分类损失指导信息
Figure PCTCN2020088252-appb-000026
其中
Figure PCTCN2020088252-appb-000027
是当前压缩模型在第l+1层网络层第i个通道的输出特征数据;
6、基于LASSO优化算法以及公式(7),获得第l层网络层的通道选择指示信息β (l)
7、通过删除第k个卷积核以修剪第l层网络层中的通道,其中k是β (l)中所有β k (l)=0的索引,将删除了通道之后的第l层网络层对应的权重设为
Figure PCTCN2020088252-appb-000028
以及基于β (l)调整第l+1层网络层中的各个卷积核的通道;
8、基于最小二乘优化方法,以及公式(12),获得第l+1层网络层的调整权重
Figure PCTCN2020088252-appb-000029
并基于
Figure PCTCN2020088252-appb-000030
来更新调整了卷积核通道的第l+1层网络层中的参数;
9、得到压缩模型:
Figure PCTCN2020088252-appb-000031
在执行完上述循环步骤之后,最终得到的压缩模型为:
Figure PCTCN2020088252-appb-000032
在本公开另一实施例中,在基于上述步骤得到压缩模型后,还可以利用样本图像对压缩模型进行微调处理。例如可以利用压缩模型获得样本图像的分类结果,并基于分类结果以及样本图像的分类标签,确定样本图像的分类损失;基于分类损失,微调压缩模型的参数,从而可以提高压缩后的模型的识别精度。
本公开实施例根据在对待压缩模型中的多层网络层中的任一层网络层对应通道剪 枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取所述样本图像的损失信息,以及第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;基于所述损失信息以及所述第一特征数据,确定分类损失指导信息,并基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。从而能够在每次仅针对一层神经网络进行剪枝的时候,基于分类损失指导信息指导该层神经网络的通道剪枝处理,避免在压缩完成后对模型的损失造成较大影响,进而能够保证压缩效率,又能够兼顾压缩效果。
另外,本公开另一实施例还利用了特征重要性指导信息确定通道选择指示信息,并基于通道选择信息来对所述任一层网络层执行通道剪枝处理。使用特征重要性指导信息作为对第l层网络层进行通道剪枝时的指导,有效地避免了将不具备信息性的特征所造成的重构误差降到最低,这些信息将在对第l+1层网络层进行通道剪枝过程中被删除,因此可以获得合理的结果。
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。
基于同一发明构思,本公开实施例中还提供了与模型压缩方法对应的模型压缩装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述模型压缩方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。
本公开实施例还提供一种图像处理方法,包括:获取待处理图像;利用基于本公开前述任一实施例所提供的模型压缩方法确定的图像处理模型,对所述待处理图像执行图像处理任务。本公开实施例所提供的图像处理方法的执行主体一般为具有一定计算能力的计算机设备,该计算机设备例如包括:终端设备或服务器或其它处理设备,终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、终端、蜂窝电话、无绳电话、个人数字处理(Personal Digital Assistant,PDA)、手持设备、计算设备、车载设备、可穿戴设备等。在一些可能的实现方式中,该图像处理方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。
在一些可选实施例中,所述待处理图像可以通过计算机设备上设置的摄像装置直接采集得到,也可以通过通信方式从其他设备或存储装置上获取得到。
本实施例中,图像处理任务例如包括:动作识别、人脸识别、人脸情绪识别、人脸关键点识别、活体识别中至少一种图像处理任务。
本公开实施例可以基于预定的图像处理任务,确定样本图像和与各样本图像对应的标签;基于样本图像和各样本图像对应的标签,训练得到待压缩模型,基于本公开前述任一实施例所提供的模型压缩方法对其进行压缩处理;得到压缩模型后,还可以再利用一些样本图像对压缩模型进行微调,得到训练完成的图像处理模型。
本公开实施例提供的图像处理方法,是利用基于本公开实施例提供的模型压缩方法确定的图像处理模型来执行图像处理任务。由于本公开实施例提供的模型压缩方法能够 带来更好的压缩效果,也即得到的压缩模型较之当前技术得到的压缩模型的模型规模更小,计算复杂度也更低,因此更适用于嵌入式设备进行图像处理。
参照图2所示,为本公开实施例提供的一种模型压缩装置的示意图,所述装置包括:获取模块21、确定模块22和剪枝模块23;其中,
所述获取模块21,配置为针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;
所述确定模块22,配置为基于所述损失信息以及所述第一特征数据,确定分类损失指导信息;
所述剪枝模块23,配置为基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。
本公开实施例根据在对任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取所述样本图像的损失信息,以及第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;基于所述损失信息以及所述第一特征数据,确定分类损失指导信息,并基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。从而能够在每次仅针对一层神经网络进行剪枝的时候,基于分类损失指导信息指导该层神经网络的通道剪枝处理,避免在压缩完成后对模型的损失造成较大影响,进而能够保证压缩效率,又能够兼顾压缩效果。
在一种可能的实施方式中,所述装置还包括:更新模块24,用于配置为在所述剪枝模块23对所述任一层网络层执行通道剪枝处理后,基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理。
在一种可能的实施方式中,所述确定模块22,配置为基于所述损失信息以及所述第一特征数据,确定分类损失指导信息以及特征重要性指导信息。
在一种可能的实施方式中,所述确定模块22,配置为基于所述第一特征数据以及预先确定的调整参数,确定所述特征重要性指导信息。
在一种可能的实施方式中,针对所述任一层网络层为待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型为:所述待压缩模型;
针对所述任一层网络层并非待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型包括:已经进行通道剪枝处理的网络层,以及所述待压缩模型中其他未进行通道剪枝处理的网络层。
在一种可能的实施方式中,所述获取模块21,配置为利用所述第一目标模型,获取所述样本图像的分类损失预测结果;基于所述样本图像的分类损失预测结果、所述样本图像对应的真实分类标签以及预先确定的损失函数,获取所述样本图像的损失信息。
在一种可能的实施方式中,所述确定模块22,配置为利用所述损失信息在所述第一目标模型中的反向传播,确定损失函数相对于所述第一特征数据的偏导数;将所述偏导 数确定为所述分类损失指导信息。
在一种可能的实施方式中,所述剪枝模块23,配置为基于所述分类损失指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;或者,基于特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;又或者,基于所述分类损失指导信息、特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;基于所述通道选择指示信息,调整所述任一网络层中的卷积核;其中,所述通道选择指示信息用于指示要保留的通道;所述样本图像的第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
在一种可能的实施方式中,所述更新模块24,配置为基于已进行剪枝处理后的所述任一层网络,对所述任一层网络的下一层网络中的各个卷积核的进行通道调整;基于已进行剪枝处理后的所述任一层网络、以及已进行卷积核通道调整的所述下一层网络层,确定第二目标模型,并利用所述第二目标模型,获取所述第二目标模型中的所述已进行剪枝处理后的所述任一层网络层的下一层网络层输出所述样本图像的第三特征数据;以及利用待压缩模型对图像进行处理时的所述任一层网络层输出的第二特征数据,得到所述下一层层网络层的权重参数;基于所述权重参数,对所述下一层网络层的原始权重参数进行更新处理。
上述实施例提供的模型压缩装置在进行模型压缩时,仅以上述各程序模块的划分进行举例说明,实际应用中,可以根据需要而将上述处理分配由不同的程序模块完成,即将装置的内部结构划分成不同的程序模块,以完成以上描述的全部或者部分处理。另外,上述实施例提供的模型压缩装置与模型压缩方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
本公开实施例还提供一种图像处理装置,所述图像处理装置包括:获取单元和处理单元;所述获取单元配置为获取待处理图像;所述处理单元配置为利用本公开前述任一实施例所提供的模型压缩方法确定的图像处理模型,对所述待处理图像执行图像处理任务。
本公开实施例还提供了一种计算机设备,如图3所示,为本公开实施例提供的计算机设备30结构示意图,所述计算机设备30包括:相互连接的处理器31和存储器32,所述存储器32存储有所述处理器31可执行的计算机可读指令,当计算机设备运行时,所述计算机可读指令被所述处理器31执行时执行如本公开前述任一实施例提供的模型压缩方法的步骤;或所述计算机可读指令被所述处理器31执行时利用本公开实施例提供的模型压缩方法确定的图像处理模型,对待处理图像执行图像处理任务。
可以理解,计算机设备30中的各个组件可通过总线系统耦合在一起。可理解,总线系统用于实现这些组件之间的连接通信。
上述本发明实施例揭示的方法可以应用于处理器31中,或者由处理器31实现。处理器31可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的 各步骤可以通过处理器31中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器31可以是通用处理器、数字信号处理器(Digital Signal Processor,DSP),或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。处理器31可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本发明实施例所公开的方法的步骤,可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于存储介质中,该存储介质位于存储器32,处理器31读取存储器32中的信息,结合其硬件完成前述方法的步骤。
可以理解,存储器32可以是易失性存储器或非易失性存储器,也可包括易失性和非易失性存储器两者。
本公开实施例还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行本公开实施例提供的模型压缩方法的步骤,或者,该计算机程序被处理器运行时执行利用本公开实施例提供的模型压缩方法确定的图像处理模型,执行图像处理任务。
本公开实施例所提供的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行上述方法实施例中所述的模型压缩方法或图像处理方法的步骤,具体可参见上述方法实施例,在此不再赘述。
本公开实施例还提供一种计算机程序,该计算机程序被处理器执行时实现前述实施例的任意一种模型压缩方法或图像处理方法的步骤。该计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。

Claims (23)

  1. 一种模型压缩方法,包括:
    针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;
    基于所述损失信息以及所述第一特征数据,确定分类损失指导信息;
    基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。
  2. 根据权利要求1所述的模型压缩方法,其中,在对所述任一层网络层执行通道剪枝处理后,所述方法还包括:
    基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理。
  3. 根据权利要求1或2所述的模型压缩方法,其中,所述基于所述损失信息以及所述第一特征数据,确定分类损失指导信息,包括:
    基于所述损失信息以及所述第一特征数据,确定分类损失指导信息以及特征重要性指导信息。
  4. 根据权利要求3所述的模型压缩方法,其中,基于所述损失信息以及所述第一特征数据,确定特征重要性指导信息,包括:
    基于所述第一特征数据以及预先确定的调整参数,确定所述特征重要性指导信息。
  5. 根据权利要求1-4任一项所述的模型压缩方法,其中,针对所述任一层网络层为待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型为:所述待压缩模型;
    针对所述任一层网络层并非待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型包括:已经进行通道剪枝处理的网络层,以及所述待压缩模型中其他未进行通道剪枝处理的网络层。
  6. 根据权利要求1-5任一项所述的模型压缩方法,其中,所述利用所述第一目标模型,获取样本图像的损失信息,包括:
    利用所述第一目标模型,获取所述样本图像的分类损失预测结果;
    基于所述样本图像的分类损失预测结果、所述样本图像对应的真实分类标签以及预先确定的损失函数,获取所述样本图像的损失信息。
  7. 根据权利要求1-6任一项所述的模型压缩方法,其中,所述基于所述损失信息以及所述第一特征数据,确定分类损失指导信息,包括:
    利用所述损失信息在所述第一目标模型中的反向传播,确定损失函数相对于所述第一特征数据的偏导数;
    将所述偏导数确定为所述分类损失指导信息。
  8. 根据权利要求1-7任一项所述的模型压缩方法,其中,所述基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理,包括:
    基于所述分类损失指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;或者,基于特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;又或者,基于所述分类损失指导信息、特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;
    基于所述通道选择指示信息,调整所述任一网络层中的卷积核;
    其中,所述通道选择指示信息用于指示要保留的通道;所述样本图像的第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
  9. 根据权利要求2-8任一项所述的模型压缩方法,其中,所述基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理,包括:
    基于已进行剪枝处理后的所述任一层网络,对所述任一层网络的下一层网络中的各个卷积核进行通道调整;
    基于已进行剪枝处理后的所述任一层网络、以及已进行卷积核通道调整的所述下一层网络层,确定第二目标模型,并利用所述第二目标模型,获取所述第二目标模型中的所述已进行剪枝处理后的所述任一层网络层的下一层网络层输出所述样本图像的第三特征数据;以及利用待压缩模型对图像进行处理时的所述任一层网络层输出的第二特征数据,得到所述下一层网络层的权重参数;
    基于所述权重参数,对所述下一层的原始权重参数进行更新处理。
  10. 一种图像处理方法,包括:
    获取待处理图像;
    利用基于权利要求1-9任一项确定的图像处理模型,对所述待处理图像执行图像处理任务。
  11. 一种模型压缩装置,所述装置包括:
    获取模块,配置为针对待压缩模型中的多层网络层中的至少一层网络层中的任一层网络层,根据在对所述任一层网络层对应通道剪枝处理时的模型压缩进度,确定第一目标模型,并利用所述第一目标模型,获取样本图像的损失信息,以及所述第一目标模型中的所述任一层网络层的下一层网络层输出所述样本图像的第一特征数据;
    确定模块,配置为基于所述损失信息以及所述第一特征数据,确定分类损失指导信息;
    剪枝模块,配置为基于所述分类损失指导信息,对所述任一层网络层执行通道剪枝处理。
  12. 根据权利要求11所述的模型压缩装置,其中,所述装置还包括更新模块,配置为在所述剪枝模块对所述任一层网络层执行通道剪枝处理后,基于已进行剪枝处理后的所述任一层网络层,对所述任一层网络层的下一层网络层进行参数更新处理。
  13. 根据权利要求11或12所述的模型压缩装置,其中,所述确定模块,配置为基于所述损失信息以及所述第一特征数据,确定分类损失指导信息以及特征重要性指导信息。
  14. 根据权利要求13所述的模型压缩装置,其中,所述确定模块,配置为基于所述第一特征数据以及预先确定的调整参数,确定所述特征重要性指导信息。
  15. 根据权利要求11-14任一项所述的模型压缩装置,其中,针对所述任一层网络层为待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型为:所述待压缩模型;针对所述任一层网络层并非待进行通道剪枝处理的第一层网络层的情况,所述第一目标模型包括:已经进行通道剪枝处理的网络层,以及所述待压缩模型中其他未进行通道剪枝处理的网络层。
  16. 根据权利要求11-15任一项所述的模型压缩装置,其中,所述获取模块,配置为利用所述第一目标模型,获取所述样本图像的分类损失预测结果;基于所述样本图像的分类损失预测结果、所述样本图像对应的真实分类标签以及预先确定的损失函数,获取所述样本图像的损失信息。
  17. 根据权利要求11-16任一项所述的模型压缩装置,其中,所述确定模块,配置为利用所述损失信息在所述第一目标模型中的反向传播,确定损失函数相对于所述第一特征数据的偏导数;将所述偏导数确定为所述分类损失指导信息。
  18. 根据权利要求11-17任一项所述的模型压缩装置,其中,所述剪枝模块,配置 为基于所述分类损失指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;或者,基于特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;又或者,基于所述分类损失指导信息、特征重要性指导信息以及所述样本图像的第二特征数据,确定通道选择指示信息;基于所述通道选择指示信息,调整所述任一网络层中的卷积核;其中,所述通道选择指示信息用于指示要保留的通道;所述样本图像的第二特征数据,为利用待压缩模型对所述样本图像进行处理时从所述任一层网络层的下一层网络层输出的特征数据。
  19. 根据权利要求12-18任一项所述的模型压缩装置,其中,所述更新模块,配置为基于已进行剪枝处理后的所述任一层网络,对所述任一层网络的下一层网络中的各个卷积核的进行通道调整;基于已进行剪枝处理后的所述任一层网络、以及已进行卷积核通道调整的所述下一层网络层,确定第二目标模型,并利用所述第二目标模型,获取所述第二目标模型中的所述已进行剪枝处理后的所述任一层网络层的下一层网络层输出所述样本图像的第三特征数据;以及利用待压缩模型对图像进行处理时的所述任一层网络层输出的第二特征数据,得到所述下一层层网络层的权重参数;基于所述权重参数,对所述下一层网络层的原始权重参数进行更新处理。
  20. 一种图像处理装置,该图像处理装置包括:
    获取单元,配置为获取待处理图像;
    处理单元,配置为利用基于权利要求1-9任一项确定的图像处理模型,对所述待处理图像执行图像处理任务。
  21. 一种计算机设备,包括:相互连接的处理器和存储器,所述存储器存储有所述处理器可执行的计算机可读指令,当计算机设备运行时,所述计算机可读指令被所述处理器执行时执行如权利要求1至9任一所述的模型压缩方法的步骤,或者,所述计算机可读指令被所述处理器执行时执行如权利要求10所述的图像处理方法的步骤。
  22. 一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1至9任意一项所述的模型压缩方法的步骤,或者,该计算机程序被处理器运行时执行如权利要求10所述的图像处理方法的步骤。
  23. 一种计算机程序,所述计算机程序被处理器执行时实现如权利要求1至9任意一项所述的模型压缩方法,或者,所述计算机程序被处理器运行时执行如权利要求10所述的图像处理方法。
PCT/CN2020/088252 2020-04-13 2020-04-30 一种模型压缩方法、图像处理方法以及装置 Ceased WO2021208151A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2021525567A JP2022541359A (ja) 2020-04-13 2020-04-30 モデル圧縮方法、画像処理方法および装置
KR1020217013984A KR20210129031A (ko) 2020-04-13 2020-04-30 모델 압축 방법, 이미지 처리 방법 및 장치

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010286175.9 2020-04-13
CN202010286175.9A CN111488986B (zh) 2020-04-13 2020-04-13 一种模型压缩方法、图像处理方法以及装置

Publications (1)

Publication Number Publication Date
WO2021208151A1 true WO2021208151A1 (zh) 2021-10-21

Family

ID=71791551

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/088252 Ceased WO2021208151A1 (zh) 2020-04-13 2020-04-30 一种模型压缩方法、图像处理方法以及装置

Country Status (5)

Country Link
JP (1) JP2022541359A (zh)
KR (1) KR20210129031A (zh)
CN (1) CN111488986B (zh)
TW (1) TWI768382B (zh)
WO (1) WO2021208151A1 (zh)

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114118411A (zh) * 2021-11-30 2022-03-01 北京达佳互联信息技术有限公司 图像识别网络的训练方法、图像识别方法及装置
CN114358245A (zh) * 2021-12-24 2022-04-15 杭州海康威视数字技术股份有限公司 一种模型敏感性确定方法、装置及电子设备
CN114580632A (zh) * 2022-03-07 2022-06-03 腾讯科技(深圳)有限公司 模型优化方法和装置、计算设备及存储介质
CN114813299A (zh) * 2022-05-10 2022-07-29 无锡市第五人民医院 一种药敏检测样品取样预处理混合装置
CN114819140A (zh) * 2022-03-31 2022-07-29 支付宝(杭州)信息技术有限公司 模型剪枝方法、装置和计算机设备
CN114913441A (zh) * 2022-06-28 2022-08-16 湖南大学 通道剪枝方法、目标检测方法及遥感图像车辆检测方法
CN114925821A (zh) * 2022-01-05 2022-08-19 华为技术有限公司 一种神经网络模型的压缩方法及相关系统
CN115034386A (zh) * 2022-06-22 2022-09-09 北京三快在线科技有限公司 一种业务执行的方法、装置、存储介质及电子设备
CN115063673A (zh) * 2022-07-29 2022-09-16 阿里巴巴(中国)有限公司 模型压缩方法、图像处理方法、装置和云设备
CN115222042A (zh) * 2022-07-08 2022-10-21 中国科学院计算技术研究所 一种结构化剪枝的方法以及系统
CN115329952A (zh) * 2022-10-12 2022-11-11 深圳比特微电子科技有限公司 一种模型压缩方法、装置和可读存储介质
CN115452376A (zh) * 2022-08-05 2022-12-09 燕山大学 基于改进轻量级深度卷积神经网络的轴承故障诊断方法
CN115543945A (zh) * 2022-11-29 2022-12-30 支付宝(杭州)信息技术有限公司 一种模型压缩的方法、装置、存储介质及电子设备
CN116189667A (zh) * 2023-04-27 2023-05-30 摩尔线程智能科技(北京)有限责任公司 语音处理模型的量化压缩方法、装置、设备和存储介质
JP2023088136A (ja) * 2021-12-14 2023-06-26 株式会社東芝 学習装置、学習方法、学習プログラム、および学習システム
CN116992358A (zh) * 2023-06-27 2023-11-03 西安电子科技大学 一种基于电子鼻设备的轻量级气体分类方法

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112132279B (zh) * 2020-09-23 2023-09-15 平安科技(深圳)有限公司 卷积神经网络模型压缩方法、装置、设备及存储介质
CN114692816B (zh) * 2020-12-31 2023-08-25 华为技术有限公司 神经网络模型的处理方法和设备
CN112906870B (zh) * 2021-03-17 2022-10-18 清华大学 一种基于小样本的网络模型压缩云端服务方法和装置
CN115115045B (zh) * 2021-12-24 2026-02-06 杭州海康威视数字技术股份有限公司 一种模型剪枝方法、装置及电子设备
CN117077755B (zh) * 2022-05-06 2026-05-12 Oppo广东移动通信有限公司 通道系数调整方法、装置、存储介质以及计算机设备
CN115358386A (zh) * 2022-08-12 2022-11-18 北京达佳互联信息技术有限公司 业务模型生成方法、装置、服务器及存储介质
CN116110134A (zh) * 2023-01-10 2023-05-12 支付宝(杭州)信息技术有限公司 活体检测方法和系统
CN116205286A (zh) * 2023-02-03 2023-06-02 北京达佳互联信息技术有限公司 任务处理模型的生成方法、装置、电子设备及存储介质
CN116562346B (zh) * 2023-07-07 2023-11-10 深圳大学 基于l0范数的人工神经网络模型压缩方法及装置
CN116644781B (zh) * 2023-07-27 2023-09-29 美智纵横科技有限责任公司 模型压缩方法、数据处理方法、装置、存储介质及芯片
TWI906000B (zh) * 2024-10-24 2025-11-21 台達電子工業股份有限公司 使用卷積神經網路模型產生高解析度圖像的方法、優化系統及使用卷積神經網路模型的人機介面

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109858613A (zh) * 2019-01-22 2019-06-07 鹏城实验室 一种深度神经网络的压缩方法、系统及终端设备
US20190294929A1 (en) * 2018-03-20 2019-09-26 The Regents Of The University Of Michigan Automatic Filter Pruning Technique For Convolutional Neural Networks
CN110443165A (zh) * 2019-07-23 2019-11-12 北京迈格威科技有限公司 神经网络量化方法、图像识别方法、装置和计算机设备
CN110705708A (zh) * 2019-10-10 2020-01-17 上海交通大学 卷积神经网络模型的压缩方法、装置及计算机存储介质
CN110929839A (zh) * 2018-09-20 2020-03-27 深圳市商汤科技有限公司 训练神经网络的方法和装置、电子设备和计算机存储介质

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180260695A1 (en) * 2017-03-07 2018-09-13 Qualcomm Incorporated Neural network compression via weak supervision
CN108229533A (zh) * 2017-11-22 2018-06-29 深圳市商汤科技有限公司 图像处理方法、模型剪枝方法、装置及设备
WO2019190340A1 (en) * 2018-03-28 2019-10-03 Intel Corporation Channel pruning of a convolutional network based on gradient descent optimization
JP6951295B2 (ja) * 2018-07-04 2021-10-20 株式会社東芝 学習方法、学習装置および画像認識システム
CN110909861B (zh) * 2018-09-17 2023-05-30 北京市商汤科技开发有限公司 神经网络优化方法及装置、电子设备和存储介质
CN109671020B (zh) * 2018-12-17 2023-10-24 北京旷视科技有限公司 图像处理方法、装置、电子设备和计算机存储介质
CN110490323B (zh) * 2019-08-20 2024-11-26 腾讯科技(深圳)有限公司 网络模型压缩方法、装置、存储介质和计算机设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190294929A1 (en) * 2018-03-20 2019-09-26 The Regents Of The University Of Michigan Automatic Filter Pruning Technique For Convolutional Neural Networks
CN110929839A (zh) * 2018-09-20 2020-03-27 深圳市商汤科技有限公司 训练神经网络的方法和装置、电子设备和计算机存储介质
CN109858613A (zh) * 2019-01-22 2019-06-07 鹏城实验室 一种深度神经网络的压缩方法、系统及终端设备
CN110443165A (zh) * 2019-07-23 2019-11-12 北京迈格威科技有限公司 神经网络量化方法、图像识别方法、装置和计算机设备
CN110705708A (zh) * 2019-10-10 2020-01-17 上海交通大学 卷积神经网络模型的压缩方法、装置及计算机存储介质

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114118411A (zh) * 2021-11-30 2022-03-01 北京达佳互联信息技术有限公司 图像识别网络的训练方法、图像识别方法及装置
JP7809854B2 (ja) 2021-12-14 2026-02-02 株式会社東芝 学習装置、学習方法、学習プログラム、および学習システム
JP2025078854A (ja) * 2021-12-14 2025-05-20 株式会社東芝 学習装置、学習方法、学習プログラム、および学習システム
JP2023088136A (ja) * 2021-12-14 2023-06-26 株式会社東芝 学習装置、学習方法、学習プログラム、および学習システム
CN114358245A (zh) * 2021-12-24 2022-04-15 杭州海康威视数字技术股份有限公司 一种模型敏感性确定方法、装置及电子设备
CN114925821A (zh) * 2022-01-05 2022-08-19 华为技术有限公司 一种神经网络模型的压缩方法及相关系统
CN114580632A (zh) * 2022-03-07 2022-06-03 腾讯科技(深圳)有限公司 模型优化方法和装置、计算设备及存储介质
CN114819140A (zh) * 2022-03-31 2022-07-29 支付宝(杭州)信息技术有限公司 模型剪枝方法、装置和计算机设备
CN114813299B (zh) * 2022-05-10 2023-03-24 无锡市第五人民医院 一种药敏检测样品取样预处理混合装置
CN114813299A (zh) * 2022-05-10 2022-07-29 无锡市第五人民医院 一种药敏检测样品取样预处理混合装置
CN115034386A (zh) * 2022-06-22 2022-09-09 北京三快在线科技有限公司 一种业务执行的方法、装置、存储介质及电子设备
CN114913441A (zh) * 2022-06-28 2022-08-16 湖南大学 通道剪枝方法、目标检测方法及遥感图像车辆检测方法
CN114913441B (zh) * 2022-06-28 2024-04-16 湖南大学 通道剪枝方法、目标检测方法及遥感图像车辆检测方法
CN115222042A (zh) * 2022-07-08 2022-10-21 中国科学院计算技术研究所 一种结构化剪枝的方法以及系统
CN115063673A (zh) * 2022-07-29 2022-09-16 阿里巴巴(中国)有限公司 模型压缩方法、图像处理方法、装置和云设备
CN115452376A (zh) * 2022-08-05 2022-12-09 燕山大学 基于改进轻量级深度卷积神经网络的轴承故障诊断方法
CN115329952A (zh) * 2022-10-12 2022-11-11 深圳比特微电子科技有限公司 一种模型压缩方法、装置和可读存储介质
CN115543945A (zh) * 2022-11-29 2022-12-30 支付宝(杭州)信息技术有限公司 一种模型压缩的方法、装置、存储介质及电子设备
CN116189667A (zh) * 2023-04-27 2023-05-30 摩尔线程智能科技(北京)有限责任公司 语音处理模型的量化压缩方法、装置、设备和存储介质
CN116992358A (zh) * 2023-06-27 2023-11-03 西安电子科技大学 一种基于电子鼻设备的轻量级气体分类方法

Also Published As

Publication number Publication date
CN111488986A (zh) 2020-08-04
TW202139071A (zh) 2021-10-16
KR20210129031A (ko) 2021-10-27
JP2022541359A (ja) 2022-09-26
TWI768382B (zh) 2022-06-21
CN111488986B (zh) 2023-06-27

Similar Documents

Publication Publication Date Title
TWI768382B (zh) 一種模型壓縮方法及圖像處理方法、電腦設備及儲存介質
US12277500B2 (en) Neural network optimization method, electronic device and processor
CN113240079B (zh) 一种模型训练方法及装置
US10074054B2 (en) Systems and methods for Bayesian optimization using non-linear mapping of input
CN114698395B (zh) 神经网络模型的量化方法和装置、数据处理的方法和装置
CN113011532B (zh) 分类模型训练方法、装置、计算设备及存储介质
CN113298931B (zh) 一种物体模型的重建方法、装置、终端设备和存储介质
CN108701250A (zh) 数据定点化方法和装置
CN109584327B (zh) 人脸老化模拟方法、装置以及设备
CN113761934B (zh) 一种基于自注意力机制的词向量表示方法及自注意力模型
CN113743587B (zh) 一种卷积神经网络池化计算方法、系统、及存储介质
US12112524B2 (en) Image augmentation method, electronic device and readable storage medium
CN111382839A (zh) 剪枝神经网络的方法和装置
WO2021169160A1 (zh) 图像归一化处理方法及装置、存储介质
CN110321964A (zh) 识别模型更新方法及相关装置
CN115860100A (zh) 一种神经网络模型训练方法、装置及计算设备
WO2022262660A1 (zh) 针对超分辨率网络的剪枝量化压缩方法、系统及介质
CN114677548A (zh) 基于阻变存储器的神经网络图像分类系统及方法
CN116188878A (zh) 基于神经网络结构微调的图像分类方法、装置和存储介质
CN110874627A (zh) 数据处理方法、数据处理装置及计算机可读介质
CN118747513A (zh) 一种模型压缩的电力图像识别轻量化应用方法
CN115049717B (zh) 一种深度估计方法及装置
KR20250037493A (ko) 모델 훈련 방법 및 관련 디바이스
CN113139964A (zh) 多模态图像分割方法、装置、电子设备和存储介质
US20230401670A1 (en) Multi-scale autoencoder generation method, electronic device and readable storage medium

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2021525567

Country of ref document: JP

Kind code of ref document: A

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20931138

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20931138

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20931138

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 20/04/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 20931138

Country of ref document: EP

Kind code of ref document: A1