Image classification method and device based on pruning model, equipment and storage medium

By applying group sparsity constraints to each channel of the image classification model, ensuring that the multipliers and offsets are 0, the problem of pruning operations affecting network performance is solved, and an efficient image classification method is achieved.

CN114861908BActive Publication Date: 2025-11-07ZHEJIANG PHOENIX YUNRUI TECH CO LTD +2
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210435610.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-24
Publication Date
2025-11-07
Estimated Expiration
2042-04-24

AI Technical Summary

Technical Problem

In existing image classification models, pruning operations during compression may delete channels that still have function, affecting the network's classification performance and leading to performance degradation.

Method used

By applying group sparsity constraints to the multipliers and offsets of each channel in the image classification model, the multipliers and offsets of unimportant channels are simultaneously set to 0, thereby ensuring that the output of such channels is 0 and avoiding the deletion of channels that still have an effect.

Benefits of technology

It achieves a reduction in the number of model parameters and an increase in computation speed while maintaining good classification performance, and is suitable for various hardware platforms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114861908B_ABST
    Figure CN114861908B_ABST
Patent Text Reader

Abstract

The application discloses a pruning model-based image classification method and device, equipment and a storage medium. The method comprises the following steps: constructing an initial image classification model; constructing a total loss function according to a loss function of the image classification model and a preset group sparsity constraint; training the image classification model according to a preset training data set and the total loss function to obtain a trained initial image classification model; pruning the trained initial image classification model according to the group sparsity constraint of each channel; and performing image classification processing according to the pruned image classification model. According to the image classification method provided in the application, the unimportant channels in a large image classification model can be pruned, so that the parameter quantity of the classification model is reduced, the calculation efficiency of the classification model is improved, the influence of pruning on the network performance can be reduced, and the classification performance is still high.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of model compression, and particularly relates to an image classification method and device based on a pruning model, equipment and a storage medium. BACKGROUND

[0002] In recent years, deep neural networks have enabled the performance of many computer vision tasks to reach an unprecedented level. For example, image classification processing is based on deep neural networks.

[0003] The more complex the current image classification model structure is, the more parameters it has, and the more knowledge the network can learn, and the better the classification effect is. However, the high storage space and large amount of computing resource consumption make it difficult for the image classification large model to be widely applied to various hardware platforms. Therefore, the image classification model can be compressed by model pruning and the like.

[0004] However, when pruning the existing image classification model, the channels that still have an effect are often reduced, which can affect the classification performance of the network and reduce the image classification performance. SUMMARY

[0005] The embodiments of the present application provide an image classification method and device based on a pruning model, equipment and a storage medium. In order to have a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This part is not a general review, nor is it intended to determine the key / important elements or delineate the protection scope of these embodiments. The only purpose is to present some concepts in a simple form as a prelude to the detailed description that follows.

[0006] In a first aspect, the embodiments of the present application provide an image classification method based on a pruning model, comprising:

[0007] constructing an initial image classification model;

[0008] constructing a total loss function according to a loss function of the image classification model and a preset group sparsity constraint;

[0009] training the image classification model according to the preset training data set and the total loss function to obtain a trained initial image classification model;

[0010] pruning the trained initial image classification model according to the group sparsity constraint of each channel;

[0011] performing image classification processing according to the pruned image classification model.

[0012] In some optional embodiments, the total loss function is constructed according to the loss function of the image classification model and the preset group sparsity constraint, comprising:

[0013] Constructing a cross-entropy loss function of the image classification model;

[0014] Constructing group sparsity constraints according to the multipliers and offsets of the batch normalization layers of each channel in the image classification model;

[0015] Adding the group sparsity constraints to the cross-entropy loss function to obtain a total loss function.

[0016] In some optional embodiments, the total loss function is as shown in the following formula:

[0017]

[0018] wherein, ∑ i -p i logq i represents the cross-entropy loss function of the image classification model, p i represents the true label of the input picture belonging to the i-th class, q i represents the predicted probability value of the picture belonging to the i-th class obtained by the model, i represents the class index number, ∑ n λ‖Z n ‖ 1,2 represents the group sparsity constraints, Z n represents the multipliers and offset parameters of the batch normalization layer corresponding to the n-th channel, n is the channel index number, and λ represents the weight of the group sparsity constraints, represents the group sparsity constraints on the multipliers and offsets, γ is the multiplier, and β is the offset.

[0019] In some optional embodiments, the initial image classification model trained is pruned according to the group sparsity constraints of each channel, including:

[0020] Obtaining the group sparsity constraint value of the batch normalization layer of each channel in the initial image classification model;

[0021] When the value of the group sparsity constraint of the batch normalization layer of the channel is less than a preset threshold, the channel is deleted, and a pruned image classification model is obtained.

[0022] In some optional embodiments, the initial image classification model trained is pruned according to the group sparsity constraints of each channel, including:

[0023] Obtaining the group sparsity constraint value of the batch normalization layer of each channel in the initial image classification model;

[0024] The values of the group sparsity constraints of the batch normalization layers of each channel are sorted from small to large to generate pruning priorities, and a preset number of channels in front are pruned.

[0025] In some optional embodiments, after the pruned initial image classification model is pruned according to the group sparsity constraint of each channel, the method further includes:

[0026] determining whether there is an isolated channel in the remaining channels; the isolated channel is a channel without a connection relationship; if there is, the isolated channel is deleted;

[0027] determining whether there is an isolated node in the network model; the isolated node is a node without a channel; if there is, the isolated node is deleted.

[0028] In some optional embodiments, after the isolated node is deleted, the method further includes:

[0029] training the pruned image classification model according to the training data set and the cross-entropy loss function to obtain a trained image classification model.

[0030] In a second aspect, the embodiments of the present application provide an image classification device based on a pruning model, which includes:

[0031] a model construction module, configured to construct an initial image classification model;

[0032] a group sparsity constraint construction module, configured to construct a total loss function according to a loss function of the image classification model and a preset group sparsity constraint;

[0033] a training module, configured to train the image classification model according to a preset training data set and the total loss function to obtain a trained initial image classification model;

[0034] a pruning module, configured to prune the trained initial image classification model according to a group sparsity constraint of each channel;

[0035] an image classification module, configured to perform image classification processing according to the pruned image classification model.

[0036] In a third aspect, the embodiments of the present application provide an image classification device based on a pruning model, which includes a processor and a memory storing program instructions, and the processor is configured to execute the program instructions to perform the image classification method based on the pruning model provided by the above-mentioned embodiments.

[0037] In a fourth aspect, the embodiments of the present application provide a computer readable medium having computer readable instructions stored thereon, and the computer readable instructions are executed by a processor to implement the image classification method based on the pruning model provided by the above-mentioned embodiments.

[0038] The technical solutions provided by the embodiments of the present application can include the following beneficial effects:

[0039] The image classification method based on the pruning model provided in the embodiments of the present application can obtain a small classification model with high precision and fewer channels by pruning unimportant channels in the image classification model. The small classification model has fewer channels and less parameters, and runs fast, and thus can be conveniently deployed on various hardware platforms. The pruning method simultaneously performs group sparsity constraints on the multipliers and offset values of each channel, so that the multipliers and offset values of unimportant channels are both 0, thereby ensuring that the output of the channels is 0. The pruning method avoids deleting channels that still have effects, greatly reduces the influence of pruning on network performance, and through the image classification based on the model after pruning, the classification efficiency can be improved, and good classification performance can be maintained.

[0040] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF DRAWINGS

[0041] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.

[0042] Figure 1 FIG. 1 is a flowchart of an image classification method based on a pruning model according to an example embodiment;

[0043] Figure 2 FIG. 2 is a schematic diagram of an image classification method based on a pruning model according to an example embodiment;

[0044] Figure 3 FIG. 3 is a structural schematic diagram of an image classification device based on a pruning model according to an example embodiment;

[0045] Figure 4 FIG. 4 is a structural schematic diagram of an image classification device based on a pruning model according to an example embodiment;

[0046] Figure 5 FIG. 5 is a schematic diagram of a computer storage medium according to an example embodiment. DETAILED DESCRIPTION

[0047] The following description and drawings sufficiently illustrate specific embodiments of the present application to enable one of ordinary skill in the art to practice them.

[0048] It should be clear that the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0049] The following description refers to the accompanying drawings. Unless otherwise noted, reference to a given patent document in a description of one of the embodiments herein indicates that embodiment contains some combination of features from the referenced patent document and the described embodiment. No embodiment contained herein is to be construed as having any dependency upon one or more of the other embodiments herein described if those embodiments are not expressly recited in the given patent document.

[0050] At present, in the prior art, only the multipliers of the batch normalization layers in the image classification model are subjected to L1 sparse constraint, so that the multipliers of unimportant channels are 0, and the channels are subsequently deleted. However, the channel with the multiplier of 0 may have a large offset value added subsequently, which leads to a large output value of the channel and an important role of the channel in the network. If the channel is directly deleted, the classification performance of the network may be affected.

[0051] Based on this, the embodiment of the present application subjects the multipliers and offsets of each channel of the classification model to group sparse constraint, so that the multipliers and offsets of unimportant channels are 0 at the same time, thereby ensuring that the output of the channel is 0. Therefore, the image classification method proposed in the present application performs image classification based on the pruned classification model, which not only can maintain a high calculation rate, but also can maintain a high classification performance.

[0052] The image classification method based on the pruned model provided by the embodiment of the present application will be described in detail below with reference to the accompanying drawings. Referring to FIG. 1, the method comprises the following steps. Figure 1

[0053] S101, constructing an initial image classification model.

[0054] First, an initial neural network image classification model without pruning is constructed, such as an image classification model based on a ResNet101 neural network structure, in which most channels contain batch normalization layers.

[0055] S102, constructing a total loss function according to a loss function of the image classification model and a preset group sparse constraint, wherein the group sparse constraint is constructed by the multipliers and offsets of the batch normalization layers.

[0056] In some optional embodiments, constructing the total loss function according to the loss function of the image classification model and the preset group sparse constraint comprises: constructing a cross-entropy loss function of the image classification model; constructing a group sparse constraint according to the multipliers and offsets of the batch normalization layers of each channel in the model; and adding the group sparse constraint to the cross-entropy loss function to obtain the total loss function.

[0057] ​Specifically, the output of one channel is:

[0058] y i ←γx i +β

[0059] wherein x i is a channel feature value, y i is a feature channel value after multiplier scaling and offsetting x i , γ is a multiplier, and β is an offset.

[0060] The application utilizes group sparse constraint to constrain the multiplier and offset of the batch normalization layer to be 0 at the same time. The group sparse constraint is added to the cross entropy loss function of the image classification model to obtain the total loss function as follows:

[0061]

[0062] wherein ∑ i -p i logq i represents the cross entropy loss function of the image classification model, p i represents the real label of the input picture belonging to the i-th class, q i represents the prediction probability value of the picture belonging to the i-th class obtained by the model, i represents the class index number, ∑ n λ‖Z n ‖ 1,2 represents the group sparse constraint, Z n represents the multiplier and offset parameters of the batch normalization layer corresponding to the n-th channel, n is the channel index number, and λ represents the weight of the group sparse constraint, represents the group sparse constraint on the multiplier and offset, γ is the multiplier, and β is the offset.

[0063] S103 trains the image classification model according to the preset training data set and the total loss function to obtain the trained initial image classification model.

[0064] In a possible implementation, before the image classification model is trained according to the preset training data set and the total loss function, the method further includes: obtaining an image data set, for example, obtaining a large amount of image data set from the Internet or obtaining a large amount of image data set from a preset image database. The image data set is preprocessed, for example, images with abnormalities, blurring, etc. are deleted, and then the preprocessed images are classified and labeled to obtain an image data set containing classification labels, and the labeled image data set is used as the training data set.

[0065] Further, the image classification model is trained according to the training data set and the total loss function to obtain the trained initial image classification model.

[0066] Specifically, the image data in the training set is input into the initial image classification model in batches according to a preset batch size, and the output of the model is obtained. The loss is calculated by using the loss function L with the model output, the channel multiplier and the offset of the current model. The loss is optimized by using the stochastic gradient descent algorithm, so that the model gradually converges, and the trained initial image classification model is obtained.

[0067] S104 prunes the trained initial image classification model according to the group sparsity constraint of each channel.

[0068] In some optional embodiments, pruning the trained initial image classification model according to the group sparsity constraint of each channel includes: obtaining the value of the group sparsity constraint of the batch normalization layer of each channel of the trained initial image classification model; when the value of the group sparsity constraint of the batch normalization layer of the channel is less than a preset threshold, the channel is deleted, and a pruned image classification model is obtained.

[0069] Specifically, under the constructed group sparsity constraint, the multiplier and the offset of the unimportant channel will become 0 at the same time with the iterative convergence of network training, and therefore, the network can be pruned according to the values of the multiplier and the offset in the group sparsity constraint. The trained model channels are traversed, and when the multiplier and the offset of the batch normalization layer of a certain channel are less than a preset threshold at the same time, the channel is deleted. After the above processing is performed on all channels, a pruned model is obtained. The value of the preset threshold can be set according to actual conditions, and the embodiments of the present application do not make specific limitations. In an exemplary scenario, the preset threshold is 0.01, that is, when the values of the multiplier and the offset of the channel are both less than 0.01, it is indicated that the channel plays a smaller role in the model, and the channel is deleted.

[0070] By performing the group sparsity constraint on the multiplier γ and the offset β of each channel, the multiplier and the offset of the unimportant channel are both 0, which ensures that the output of the channel is 0, and the channel is pruned and deleted subsequently, thereby reducing the size of the model. Through the group sparsity constraint, the impact of pruning on the network performance can be greatly reduced.

[0071] Optionally, after obtaining the value of the group sparsity constraint of the multiplier γ and the offset β of each channel, the values of each channel can be sorted from small to large to generate a pruning priority, and a preset number of channels in the front are deleted. For example, the 5 channels with smaller values of the group sparsity constraint in the front are pruned. The network layer with the smallest influence can be pruned first, and the pruning is gradually performed from simple to difficult, so that the model accuracy loss in the pruning process is minimized.

[0072] In some optional embodiments, after the pruned initial image classification model is trained, the method further comprises: determining whether there is an isolated channel in the remaining channels; wherein the isolated channel is a channel without a connection relationship; if there is, deleting the isolated channel; determining whether there is an isolated node in the network model; wherein the isolated node is a node without a channel; if there is, deleting the isolated node.

[0073] Further, it is determined whether the training accuracy of the model after deleting the isolated channel or the isolated node decreases, and if the decrease rate is large, the deleted isolated channel or the isolated node is connected to the model structure again, and the pruned model structure is integrated.

[0074] Further, after the model is pruned, the pruned image classification model is trained again according to the training data set and the cross-entropy loss function, and a trained image classification model is obtained.

[0075] Specifically, the training data set is used for fine-tuning classification training. A smaller learning rate for model updating is set by using the cross-entropy loss function and the training data set, and the model is fine-tuned for classification training. A final pruned image classification model is obtained.

[0076] S105 performs image classification processing according to the pruned image classification model.

[0077] The image data to be processed is input into the pruned image classification model, the image is classified, and an image classification result is obtained.

[0078] According to the pruned image classification model, the image classification is performed, not only the parameter amount of the model is greatly reduced, but also the good image classification performance is maintained.

[0079] As shown in the following table:

[0080] Initial image classification model (unpruned) Pruned image classification model Model parameter amount 20M 3M Classification accuracy 93.0% 92.8%

[0081] The present application embodiment tests a large number of data sets, and it can be seen that the parameter amount of the initial image classification model without pruning is significantly lower than that of the pruned image classification model, but the classification effects of the two are basically the same. Therefore, according to the pruned image classification model, the image classification is performed, not only the calculation amount is low, but also the good image classification performance is maintained.

[0082] Optionally, according to the model pruning method provided in the present application embodiment, it can be applied to various computer vision tasks, not limited to image classification, but also can be applied to target detection, image segmentation, etc.

[0083] In order to facilitate understanding of the image classification method based on the pruned model provided in the present application embodiment, the following will be described in combination with the accompanying drawings. Figure 2 illustrated.Figure 2 As shown, the method comprises the following steps.

[0084] S201 constructing an initial image classification model.

[0085] S202 constructing a cross-entropy loss function of the image classification model, and constructing a group sparsity constraint according to the multipliers and offsets of the batch normalization layers of each channel in the model.

[0086] S203 adding the group sparsity constraint to the cross-entropy loss function to obtain a total loss function.

[0087] The application utilizes a group sparsity constraint to constrain the multipliers and offsets of the batch normalization layers to be 0 at the same time. The group sparsity constraint is added to the cross-entropy loss function of the image classification model to obtain a total loss function as follows:

[0088]

[0089] wherein ∑ i -p i logq i represents the cross-entropy loss function of the image classification model, p i represents the true label of the input picture belonging to the i-th class, q i represents the predicted probability value of the picture obtained by the model belonging to the i-th class, i represents the class index number, ∑ n λ‖Z n ‖ 1,2 represents the group sparsity constraint, Z n represents the multiplier and offset parameters of the batch normalization layer corresponding to the n-th channel, n is the channel index number, and λ represents the weight of the group sparsity constraint, represents the group sparsity constraint on the multipliers and offsets, γ is the multiplier, and β is the offset.

[0090] S204 training the image classification model according to a preset training data set and the total loss function.

[0091] Specifically, the image data in the training set is input into the model in batches according to a preset batch size to obtain the output of the model. The model output, the channel multipliers and offsets of the current model, and the loss are calculated by using the loss function L. The loss is optimized by using a stochastic gradient descent algorithm, so that the model gradually converges to obtain a trained model.

[0092] S205 obtaining the value of the group sparsity constraint of the batch normalization layer of each channel of the trained initial image classification model.

[0093] S206 deleting the channel when the value of the group sparsity constraint of the batch normalization layer of the channel is less than a preset threshold to obtain a pruned image classification model.

[0094] With the iteration convergence of the network training under the constructed group sparse constraint, the multiplier and the offset of the unimportant channel will become 0 at the same time, and therefore, the network can be pruned according to the values of the multiplier and the offset in the group sparse constraint. When the multiplier and the offset of a certain channel batch normalization layer are both less than a preset threshold, the channel is deleted.

[0095] S207 training the pruned image classification model according to the training data set and the cross-entropy loss function to obtain a trained image classification model.

[0096] The pruned model is fine-tuned for classification training again using the training data set. Specifically, the cross-entropy loss function and the training data set are used to set a smaller learning rate for model updating, and the model is fine-tuned for classification training. A final pruned classification model is obtained.

[0097] S208 performing image classification processing according to the pruned image classification model.

[0098] The image classification method provided by the embodiments of the present application can obtain a small classification model with high precision and fewer channels by pruning the unimportant channels in the classification model. Since the small classification model has fewer channels and fewer parameters, it runs faster and can be easily deployed on various hardware platforms. The pruning method simultaneously performs group sparse constraint on the multiplier and the offset of each channel, so that the multiplier and the offset of the unimportant channel are both 0, thereby ensuring that the output of the channel is 0. This avoids deleting channels that still have an effect and greatly reduces the impact of pruning on the performance of the classification network.

[0099] The embodiments of the present application also provide an image classification device based on a pruned model. The device is used to execute the image classification method based on the pruned model of the above embodiments, as shown in Figure 3 The device comprises:

[0100] A model construction module 301 is configured to construct an initial image classification model.

[0101] A group sparse constraint construction module 302 is configured to construct a total loss function according to a loss function of the image classification model and a preset group sparse constraint. The group sparse constraint is constructed by a multiplier and an offset in a batch normalization layer.

[0102] A training module 303 is configured to train the image classification model according to a preset training data set and the total loss function to obtain a trained initial image classification model.

[0103] A pruning module 304 is configured to prune the trained initial image classification model according to the group sparse constraint of each channel.

[0104] The image classification module 305 is configured to perform image classification processing according to the pruned image classification model.

[0105] It should be noted that the image classification apparatus based on the pruning model provided in the above embodiments is used to execute the image classification method based on the pruning model, and the above-mentioned division of the functional modules is only used as an example. In actual applications, the above-mentioned functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above-described functions. In addition, the image classification apparatus based on the pruning model provided in the above embodiments and the image classification method based on the pruning model belong to the same concept, and the implementation process is detailed in the method embodiments. Therefore, the above-mentioned implementation process will not be repeated here.

[0106] The embodiments of the present application also provide an electronic device corresponding to the image classification method based on the pruning model provided in the above embodiments, so as to execute the above-mentioned image classification method based on the pruning model.

[0107] Please refer to Figure 4 , which shows a schematic diagram of an electronic device provided by some embodiments of the present application. As Figure 4 shown, the electronic device includes a processor 400, a memory 401, a bus 402 and a communication interface 403, the processor 400, the communication interface 403 and the memory 401 are connected through the bus 402; the memory 401 stores a computer program which can run on the processor 400, and the processor 400 executes the computer program to perform the image classification method based on the pruning model provided in any one of the preceding embodiments of the present application.

[0108] The memory 401 can include a high-speed random access memory (RAM: Random Access Memory) and can also include a non-volatile memory such as at least one disk memory. The communication between the system network element and at least one other network element is realized through at least one communication interface 403 (which can be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. can be used.

[0109] The bus 402 can be an ISA bus, a PCI bus or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 401 is used to store programs, and the processor 400 executes the programs after receiving execution instructions. The image classification method based on the pruning model disclosed in any one of the preceding embodiments of the present application can be applied to the processor 400 or realized by the processor 400.

[0110] The processor 400 can be an integrated circuit chip with signal processing capability. In implementation, each step of the above method can be completed by integrated logic circuits or instructions in the form of software in the processor 400. The processor 400 described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a ready-to-program gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware coding processor for execution, or a combination of hardware and software modules in the coding processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium in the art. The storage medium is located in the memory 401, and the processor 400 reads the information in the memory 401, and combines the hardware to complete the steps of the above method.

[0111] The electronic device provided by the embodiments of the present application and the image classification method based on the pruning model provided by the embodiments of the present application have the same beneficial effects as the method they adopt, run or implement.

[0112] The embodiments of the present application also provide a computer readable storage medium corresponding to the image classification method based on the pruning model provided by the preceding embodiments. Please refer to Figure 5 The computer readable storage medium shown is an optical disc 500, and a computer program (i.e. program product) is stored on the optical disc 500. When the computer program is run by the processor, the image classification method based on the pruning model provided by any of the preceding embodiments will be executed.

[0113] It should be noted that examples of computer readable storage media can also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical, magnetic storage media, which will not be described one by one here.

[0114] The computer readable storage medium provided by the above embodiments of the present application has the same beneficial effects as the method adopted, run or implemented by the application program stored therein.

[0115] The technical features of the above embodiments can be combined in any manner. To make the description concise, all possible combinations of the technical features in the above embodiments are not described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present disclosure.

[0116] The above embodiments only express several implementation manners of the present application, and the description is specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present application patent should be subject to the appended claims.

Claims

1. A method of image classification based on a pruned model, characterized in that , comprising: constructing an initial image classification model; constructing a total loss function according to a loss function of the image classification model and a preset group sparsity constraint; including: constructing a cross-entropy loss function of the image classification model; constructing a group sparsity constraint according to a multiplier and an offset of a batch normalization layer of each channel in the image classification model; adding the group sparsity constraint to the cross-entropy loss function to obtain the total loss function; training the image classification model according to a preset training data set and the total loss function to obtain a trained initial image classification model; pruning the trained initial image classification model according to the group sparsity constraint of each channel; including: obtaining a group sparsity constraint value of a batch normalization layer of each channel in the initial image classification model; when the group sparsity constraint value of the batch normalization layer of the channel is less than a preset threshold, deleting the channel to obtain a pruned image classification model; or, obtaining a group sparsity constraint value of a batch normalization layer of each channel in the initial image classification model; sorting the group sparsity constraint values of the batch normalization layers of each channel from small to large to generate pruning priorities, and pruning a preset number of channels in front; performing image classification processing according to the pruned image classification model.

2. The method of claim 1, wherein, The total loss function is shown in the following formula: wherein, ∑ i -p i logq i denotes the cross-entropy loss function of the image classification model, p i denotes the true label of the input picture belonging to the i-th class, q i denotes the predicted probability value of the picture belonging to the i-th class obtained by the model, i denotes the class index number, ∑ n λ||Z n || 1,2 denotes the group sparsity constraint, Z n denotes the multiplier and offset parameters of the batch normalization layer corresponding to the n-th channel, n is the channel index number, λ denotes the weight of the group sparsity constraint, denotes the group sparsity constraint on the multiplier and offset, γ is the multiplier, and β is the offset.

3. The method according to any of claims 1-2, characterized in that, After pruning the trained initial image classification model according to the group sparsity constraint of each channel, further comprising: determining whether there is an isolated channel in the remaining channels; wherein the isolated channel is a channel without connection; if there is, deleting the isolated channel; determining whether there is an isolated node in the network model; wherein the isolated node is a node without a channel; if there is, deleting the isolated node.

4. The method of claim 3, wherein, After deleting the isolated node, further comprising: training the pruned image classification model according to the training data set and the cross-entropy loss function to obtain a trained image classification model.

5. An image classification apparatus based on a pruning model, characterized by , comprising: a model construction module configured to construct an initial image classification model; a group sparsity constraint construction module configured to construct a total loss function according to a loss function of the image classification model and a preset group sparsity constraint; including: constructing a cross-entropy loss function of the image classification model; constructing a group sparsity constraint according to a multiplier and an offset of a batch normalization layer of each channel in the image classification model; adding the group sparsity constraint to the cross-entropy loss function to obtain the total loss function; a training module configured to train the image classification model according to a preset training data set and the total loss function to obtain a trained initial image classification model; The pruning module is configured to prune the trained initial image classification model according to the group sparsity constraint of each channel; the pruning module comprises: obtaining a group sparsity constraint value of a batch normalization layer of each channel in the initial image classification model; when the group sparsity constraint value of the batch normalization layer of the channel is less than a preset threshold, the channel is deleted to obtain a pruned image classification model; or, obtaining a group sparsity constraint value of a batch normalization layer of each channel in the initial image classification model; sorting the group sparsity constraint values of the batch normalization layers of each channel from small to large to generate pruning priorities, and pruning a preset number of channels in the front; The image classification module is configured to perform image classification processing according to the pruned image classification model.

6. An image classification apparatus based on a pruned model, characterized by, The image classification method based on the pruning model comprises a processor and a memory storing program instructions, wherein the processor is configured to execute the program instructions to perform the image classification method based on the pruning model according to any one of claims 1 to 4.

7. A computer readable medium characterized by A computer readable instruction is stored on the memory, and the computer readable instruction is executed by the processor to implement the image classification method based on the pruning model according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Image classification method and device, equipment and medium

    CN113537286A

  • Pruning method, training method and related device of network model

    CN113919496A

  • Image classification network layer pruning method based on Taylor expansion

    CN114037858A