A lightweight image classification method for terminal devices and the terminal device thereof.

By optimizing channel pruning and adaptive batch normalization of deep network models using the Grey Wolf algorithm, the resource and energy consumption problems of deep learning systems on small mobile devices are solved, and efficient operation of lightweight image classification is achieved.

CN116129178BActive Publication Date: 2025-12-02NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211647471.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-21
Publication Date
2025-12-02
Estimated Expiration
2042-12-21

AI Technical Summary

Technical Problem

Existing deep learning systems are difficult to embed effectively on small mobile devices, mainly due to the excessive size of the models, computational load, and energy consumption, which cannot meet the needs of limited resources.

Method used

A lightweight image classification method is adopted, which uses the Grey Wolf algorithm for channel pruning and adaptive batch normalization, prunes the deep network model, and optimizes the network structure to reduce the number of parameters and computational complexity.

Benefits of technology

It reduces model resource consumption, computational load, and energy consumption, making it suitable for embedded devices and improving the efficiency and accuracy of image classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116129178B_ABST
    Figure CN116129178B_ABST
Patent Text Reader

Abstract

This invention discloses a lightweight image classification method and terminal device for use in terminal devices. The method involves extracting multiple frames of sample images; training a lightweight network model using these frames to obtain an image classification model; and acquiring the lightweight network model through a process that includes: randomly initializing channel clipping for each layer of a deep network model within a specified clipping parameter space according to a predetermined ratio, fixing the parameters of the clipped deep network model; using the inference accuracy of the deep network model as input to the Grey Wolf algorithm to update the channel clipping ratio coefficients of each layer of the deep network model, thus obtaining the clipped deep network model, i.e., the lightweight network model. This invention's model consumes fewer resources, solving the problem in existing technologies where small devices cannot handle large loads and therefore cannot be integrated into image processing algorithms. Therefore, this method is applicable to embedded devices or other small mobile carriers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and in particular to a lightweight image classification method and terminal device for use in terminal devices. Background Technology

[0002] Existing deep learning systems are playing an increasingly important role in common applications such as scene monitoring, smart factories, unmanned systems, and medical diagnosis. The rise in the performance of deep learning systems is mainly due to the success of deep learning networks, especially the rapid development of convolutional neural networks, which have provided advanced performance support for many practical applications. In the current era of big data, massive amounts of data provide a large training dataset for deep learning networks, and complex deep network models greatly enhance the data fitting ability, enabling deep learning methods to achieve results that traditional methods cannot match in certain applications. These achievements rely on complex deep network models and hundreds of millions of model parameters, with high-performance computing GPUs and TPUs playing a crucial role. As application tasks become increasingly sophisticated, the required network structures are also becoming more complex, introducing more network layers. This leads to an exponential increase in model size, computational complexity, and runtime, as well as significant memory consumption and energy demands during training and inference. However, in recent years, real-time applications and small mobile devices have been widely adopted, making the successful porting of the superior application performance of deep networks to mobile devices a major challenge. We considered how to effectively embed the performance of these deep network models on devices with limited resources (memory, CPU, bandwidth, and power consumption), and found that there are several main challenges:

[0003] (i) Large model size. Commonly used deep models consume a lot of memory resources. For example, the GoogleNet model is 50MB in size, the ResNet-101 model is 200M in size, and the VGG-16 model is more than 500M in size. Small mobile devices cannot bear the load of such a large size.

[0004] (ii) Large computational load: Currently commonly used deep network models have tens of millions or even hundreds of millions of parameters, and each training and inference requires a large number of floating-point multiplication operations.

[0005] (iii) High energy consumption: Frequent and large-scale memory accesses and the consumption of accelerated computing resources such as GPUs require a large amount of electricity. Therefore, we need to consider compressing and accelerating the model without affecting its performance. Effective compression methods will inevitably have a significant impact on AI-related distributed systems, embedded devices, or mobile carriers. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to provide a lightweight image classification method and terminal device for use in terminal devices, thereby reducing the computational load of the image classification process, in order to address the shortcomings of the existing technology.

[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a lightweight image classification method applied to terminal devices, comprising the following steps:

[0008] S1. Extract multiple frame sample images;

[0009] S2. Train a lightweight network model using the multi-frame sample images to obtain an image classification model;

[0010] The lightweight network model acquisition process includes:

[0011] S2.1. Within the specified pruning parameter space, randomly initialize the channels of each layer of the deep network model according to a predetermined ratio, and fix the parameters of the pruned deep network model.

[0012] S2.2. Using the inference accuracy of the deep network model as the input of the Grey Wolf algorithm, update the channel pruning ratio coefficient of each layer of the deep network model to obtain the pruned deep network model, i.e., the lightweight network model.

[0013] In this invention, inference accuracy refers to the test accuracy obtained by using a pruned deep network model to perform classification tests on a standardized dataset.

[0014] This invention first restricts the proportion of retained channels in each convolutional layer within a specified space, thereby significantly reducing the number of searches required. Then, the search problem for the optimal pruned structure is transformed into an optimization problem to reduce human interference. Finally, combining the Grey Wolf algorithm and the inference accuracy of the pruned sub-models as judgment criteria, the optimal model structure is automatically obtained. This invention greatly reduces the computational load and complexity of image classification, shortens the allowable time, and is suitable for embedded devices.

[0015] In this invention, the specific implementation process of step S2.2 includes:

[0016] A) Randomly generate a gray wolf population X to participate in the search. i,j :X i,j ~U(lb,ub), where i is the number of gray wolves in the population and i∈{1,2…N}, N is the total population size, j is the population dimension (i.e., the number of network layers), U is a random function, and lb and ub are the upper and lower bounds of the search interval; initialize the gray wolf population X participating in the search. i,j The position of each gray wolf in the network; the fitness of each gray wolf is specified as the inference accuracy of the fixed-pruned deep network model;

[0017] B) Use the following formula to search for the position X(t) of the candidate gray wolf: X(t+1)=X p (t)-A·D,D=|C·X p (t)-X(t)|;where D represents the distance between the candidate gray wolf and the prey, t is the current iteration number, and X p (t) represents the prey's location, and A and C are adjustment coefficients;

[0018] C) Determine if the iteration termination condition is met. If yes, output the optimal individual and its fitness value, and end the iteration. Otherwise, calculate the fitness of the candidate gray wolves and proceed to step D).

[0019] D) When fitness increases, update the candidate gray wolf positions using the following formula: X(t+1)=(1 / 3)((X W -A1DW)+(XY-A2DY)+(XZ-A3DZ)1-t / T+(XW-A1DW)·(t / T); where X(t) represents the current candidate gray wolf position, X(t+1) represents the candidate gray wolf position at the next time step, X W X Y and X Z The current positions of wolves W, Y, and Z are represented by A1, A2, A3, and C1, C2, C3, respectively. These are random variables. W D Y D Z D represents the distances moved between candidate gray wolves and gray wolves at W, Y, and Z, respectively. W =|C1·X W -X(t)|,d Y =|C2·X Y -X(t)|,D Z =|C3·X Z -X(t)|; The W wolf, Y wolf, and Z wolf correspond to the best individual, the good individual, and the second best individual, respectively; the position of the gray wolf corresponds to the pruning rate of the network layer in the deep network model; T is the set maximum number of iterations;

[0020] E) Update the fitness value of the candidate gray wolf and return to step C);

[0021] F) Calculate the L1 norm of each channel in each network layer. Prune channels in each layer whose L1 norm is lower than the pruning rate of the network layer. Update the batch-normalized layers of the pruned deep network model using the adaptive batch normalization method to obtain a lightweight network model.

[0022] A = 2a·r1 - a, where r1 is a random vector between 0 and 1, and a = 2e -t / T T is the maximum number of iterations set.

[0023] C = 2·r², where r² is a random vector between 0 and 1.

[0024] In this invention, the deep network model is a model obtained by adding an L1 norm to the loss function during training; wherein, the expression of the loss function after adding the L1 norm is: Loss* is the standard loss function for deep networks, K is the set of network weights, ||·||1 is the L1 norm, and γ is the penalty factor.

[0025] In this invention, after step S2, in order to further improve the model accuracy, the following steps are also included:

[0026] S3. Adjust the parameters of the lightweight network model obtained in step S2.2 to obtain the final lightweight network model.

[0027] In this invention, after step S2, in order to further improve the model accuracy, the method further includes: using the test set data as input to the network classification model, and determining whether the network classification model meets the accuracy requirements.

[0028] After step S2, the method further includes: inputting the image into the network classification model to obtain the image category.

[0029] As an inventive concept, the present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory; the processor executes the computer program to implement the steps of the method described above.

[0030] As an inventive concept, the present invention also provides a computer-readable storage medium having a computer program / instructions stored thereon; when the computer program / instructions are executed by a processor, they implement the steps of the method described above.

[0031] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0032] 1. The model of this invention consumes few resources, which solves the problem that small devices in the prior art cannot bear a large load and cannot be added to image processing algorithms. Therefore, the method of this invention is applicable to embedded devices or other small mobile carriers.

[0033] 2. This invention has low computational cost. Due to the pruning operation on the network, the number of network parameters is greatly reduced. Therefore, a large number of floating-point multiplication operations are not required during training and prediction.

[0034] 3. The present invention has low energy consumption. Because the model of the present invention occupies fewer resources and has a smaller computational load, it solves the problem of frequent and large-scale memory access and GPU acceleration computing resource consumption in the prior art, which require a large amount of electricity to support it. Attached Figure Description

[0035] Figure 1 This is an example of CIFAR-10 data, which contains 10 categories;

[0036] Figure 2 This is a schematic diagram of the method in Embodiment 1 of the present invention;

[0037] Figure 3 This is a schematic diagram illustrating the implementation principle of the Grey Wolf algorithm in Embodiment 1 of the present invention.

[0038] Figure 4 This is a flowchart of the search process in Embodiment 1 of the present invention;

[0039] Figure 5 This is a framework diagram of the method in Embodiment 1 of the present invention. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0041] In this document, the terms "first," "second," and other similar words are not intended to imply any order, quantity, or importance, but are merely used to distinguish different elements. The terms "one," "a," and other similar words are not intended to indicate the existence of only one of the stated things, but rather that the description pertains to only one of the two stated things, which may include one or more. The terms "comprising," "including," and other similar words are intended to indicate a logical relationship, not a spatial relationship. For example, "A includes B" means that logically B belongs to A, not that spatially B is located inside A. Furthermore, the meanings of the terms "comprising," "including," and other similar words should be considered open-ended, not closed. For example, "A includes B" means that B belongs to A, but B does not necessarily constitute all of A; A may also include other elements such as C, D, and E.

[0042] Example 1

[0043] The method proposed in this embodiment targets deep image classification and recognition networks, with validation datasets primarily consisting of CIFAR10, CIFAR100, and ImageNet. Deep network models significantly enhance the machine's automatic image recognition capabilities; however, as the performance of complex deep networks continues to improve, the model size inevitably increases, leading to exponential growth in computational complexity and runtime, which is highly unfriendly to embedded devices. The method proposed in this embodiment compresses such networks (channel pruning) to adapt them (model size, computational cost, and energy consumption) for embedded devices.

[0044] Currently, lightweight methods for deep networks can be broadly categorized as follows (as shown in the table below): parameter pruning and sharing, low-rank approximation decomposition, low-bit quantization methods, special accelerated network structure design, and knowledge distillation, etc.

[0045] Table 1 Summary of methods related to compression and acceleration of deep learning network models

[0046]

[0047] This embodiment employs a method belonging to the first type of "parameter pruning," which prunes channels at each convolutional layer. Typically, existing pruning methods largely focus on selecting channels to be pruned by measuring importance or using sparsity regularization as a penalty term in the loss function, which is a drawback of suboptimal pruning. This embodiment proposes a novel channel pruning method based on an improved Grey Wolf algorithm. Its aim is to effectively find the optimal pruned network structure, i.e., the number of channels per layer, rather than simply selecting "important" or "non-sparse" channels as before. The improved Grey Wolf algorithm is essentially an optimization search algorithm.

[0048] Traditional search algorithms are obviously very time-consuming. This is especially true for increasingly deep network models, often with dozens or even hundreds of layers. Searching and pruning the network layer by layer within a real-valued pruning rate space is extremely time-consuming and labor-intensive. To address the problem of handling massive pruning structure combinations in deep networks, we first constrain the proportion of retained channels in each convolutional layer within a specified space, thus significantly reducing the number of searches required. Then, the search problem for the optimal pruning structure is transformed into an optimization problem to reduce human interference. Finally, combining the improved Grey Wolf algorithm and the inference accuracy of the pruned sub-model as criteria, we automatically solve for the optimal sub-model structure and fine-tune it to achieve the best accuracy.

[0049] This embodiment primarily addresses image classification problems (and can also be used for object detection networks), evaluating the proposed algorithm on the CIFAR-10, CIFAR-100, and ImageNet datasets. The CIFAR-10 dataset consists of 60,000 32*32 images covering 10 classes, including 50,000 training images and 10,000 test images. The entire dataset is divided into five training batches and one test batch, with each batch containing 10,000 images. Figure 1 The dataset consists of classes and 10 random images from each class. CIFAR-100 is similar to CIFAR-10, but it has 100 more classes, but each class contains only 600 images. Each class has only 500 training images and 100 test images, far fewer than CIFAR-10. Therefore, CIFAR-100 is more difficult to train and has lower test accuracy compared to CIFAR-10.

[0050] Figure 1 In the CIFAR-10 dataset, there are 10 categories. The classes are completely mutually exclusive; for example, there is no overlap between "car" and "truck". Compared to CIFAR-10, the ImageNet dataset has a larger number of images, higher resolution, and more categories (up to thousands of image categories). The images also contain more irrelevant noise and variations, making it much more difficult to classify objects than CIFAR-10. Classification experiments typically use a subset of this dataset, containing 1000 target classes.

[0051] like Figure 2 As shown, the implementation process of this embodiment can be summarized as follows: For the trained deep network model, the channels of each layer of the network are randomly initialized and pruned according to a predetermined ratio within a specified pruning parameter space. The model parameters after pruning are fixed, and adaptive batch normalization is used. The inference accuracy of this model is used as the fitness A of the improved gray wolf individual. Then, the channel pruning ratio parameter of each layer is iteratively updated according to the improved gray wolf algorithm. Finally, the final fitness A is obtained. * The network's layer pruning rates were determined, and finally, the pruned network was fine-tuned to obtain the optimal lightweight network model.

[0052] For any deep convolutional network S containing n layers, its original structure can be represented as S = [c1, c2, ..., c n ], where c i (i = 1…n) represents the number of channels in the nth layer of the network. The network structure obtained after each pruning is denoted as S′ = [c1′, c2′, …, c n The pruning rate of each layer of the network is set as r = [r1, r2, ..., r]. nThe optimization problem is to find the optimal pruning rate r while achieving the best network inference accuracy, given the test and training sets. Therefore, this problem can be summarized as follows:

[0053] r * =arg r max acc(S′(r))

[0054] Where acc(S′(r)) represents the pruning rate r of the model at each layer. i After pruning and adaptive batch normalization, the inference accuracy of the model is simplified. Furthermore, to reduce the computational cost of the search, the method in this embodiment uses a pruning rate r... i The constraint is within the set {10%, 20%, ... 100%}, which transforms the above problem into a search for the optimal combination problem. This constraint can greatly reduce the number of combinations of pruned structures.

[0055] Next, the improved Grey Wolf algorithm is used to search for the optimal pruning ratio of each convolutional layer. The search process in this embodiment is described in [link to example]. Figure 4 .

[0056] (I) Search Algorithm

[0057] (1) Search initialization

[0058] Due to the Grey Wolf algorithm (such as Figure 3 (As shown) Since the initial value has little impact, we use a method of randomly generating the population:

[0059] X i,j ~U(lb,ub)

[0060] Among them, X i,j Let i represent the gray wolf population participating in the search, where i is the number of gray wolves and ∈ {1,2…N}, j is the population dimension (representing the number of network layers), U is a random function, and lb and ub are the upper and lower bounds of the search interval (the search space is {10%,20%...100%}).

[0061] (2) Search process

[0062] All gray wolves approach their prey, thus tending towards the optimal solution, through the following methods:

[0063] D = |C·X p (t)-X(t)|

[0064] X(t+1)=X p (t)-A·D

[0065] Where D represents the distance between the gray wolf and its prey, t is the current iteration number, and X... pX(t) and X(t) represent the prey's position and the gray wolf's position, respectively, and A and C are adjustment coefficients, calculated as follows:

[0066] A = 2a·r1-a

[0067] C = 2·r²

[0068] Where r1 and r2 are random vectors between 0 and 1, and a = 2e -t / T T is the maximum number of iterations set for the algorithm.

[0069] (3) Update process

[0070] By calculating the L1 norm of each channel in each layer based on the pruning rate of the network layer corresponding to the obtained gray wolf position vectors, the channels with lower L1 norm values ​​in each layer of the network are pruned. Then, the batch normalization layer is updated using the adaptive batch normalization method on the pruning model. The obtained inference accuracy is used as the fitness of the gray wolf individual, where the best individual is denoted as W, the good individual as Y, the second best individual as Z, and the rest as V.

[0071] During the update, due to the "optimal tendency" of individuals, candidate gray wolves calculate the movement distance D between themselves and gray wolves W, Y, and Z. W D Y D Z To update its position, the relevant calculation formula is as follows:

[0072] D W =|C1·X W -X(t)|

[0073] D Y =|C2·X Y -X(t)|

[0074] D Z =|C3·X Z -X(t)|

[0075] X(t+1)=(1 / 3)((X W -A1D W )+(X Y -A2D Y )+(X Z -A3D Z ))(1-t / T)+(X W -A1D W (t / T)

[0076] Where X(t) represents the current position of the candidate gray wolf, and X(t+1) represents the position of the candidate gray wolf at the next moment. W X Y and X ZThese represent the current positions of wolves W, Y, and Z, respectively; A1, A2, A3, and C1, C2, C3 are random variables, just like A and C in the search process.

[0077] Adding an L1 norm to the loss function constrains the weights. From the perspective of objective function optimization, the L1 norm can make most of the weights zero, resulting in sparsity of weights within a channel, thus allowing relevant channels to be pruned. The objective function is:

[0078]

[0079] Where Loss is the standard loss function for deep networks, K is the set of network weights, w is an element in the set, ||·||1 is the L1 norm, and γ is the penalty factor.

[0080] The original pre-trained model used in this embodiment before pruning is the model obtained after training with an L1 norm added to the loss function.

[0081] Assume the weight tensor of a certain layer in a deep network is Among them (c out c in , s, s) represent the number of output channels, the number of input channels, and the kernel size of the four-dimensional weight tensor of the network, respectively. In the network's convolutional layers, to facilitate the use of quantization functions, the dimension of the four-dimensional weights must first be changed, transforming them into a two-dimensional matrix, i.e.

[0082] Considering the complexity of the algorithm, this embodiment adopts a simple pruning method, namely, solving the L1 norm of each channel weight, sorting them from largest to smallest, and pruning the corresponding channels whose L1 norm values ​​are less than the pruning rate according to the pruning rate.

[0083] After obtaining the pruned network model, it is necessary to fine-tune the network to obtain the final inference model and its accuracy.

[0084] This embodiment provides a lightweight method for deep network models applied to image processing, primarily applicable to embedded GPU platforms. The image classification processing implementation process is as follows: Figure 5 As shown, it includes:

[0085] The data extraction module is used to extract multi-frame sample images (CIFAR10, CIFAR100, ImageNet) from the training dataset.

[0086] The training module uses the data to train common deep network models (VGG, ResNet, DenseNet, etc.) based on the above search algorithm to obtain a lightweight network model with channel pruning.

[0087] The inference module uses the test dataset to conduct image classification experiments on a lightweight network model to obtain the model accuracy.

[0088] Example 2

[0089] Embodiment 2 of the present invention provides a terminal device corresponding to Embodiment 1 above. The terminal device can be a processing device for a client, such as a mobile phone, a laptop, a tablet computer, a desktop computer, etc., to execute the method of the above embodiments.

[0090] The terminal device in this embodiment includes a memory, a processor, and a computer program stored in the memory; the processor executes the computer program in the memory to implement the steps of the method in Embodiment 1 described above.

[0091] In some implementations, the memory may be high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk storage device.

[0092] In other implementations, the processor can be any type of general-purpose processor, such as a central processing unit (CPU) or a digital signal processor (DSP), and there is no limitation here.

[0093] Example 3

[0094] Embodiment 3 of the present invention provides a computer-readable storage medium corresponding to Embodiment 1 above, on which a computer program / instructions are stored. When the computer program / instructions are executed by a processor, they implement the steps of the method of Embodiment 1 above.

[0095] A computer-readable storage medium can be a tangible device that holds and stores instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination thereof.

[0096] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0097] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0098] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0099] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0100] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A lightweight image classification method for use in terminal devices, characterized in that, Includes the following steps: S1. Extract multiple frame sample images; S2. Train a lightweight network model using the multi-frame sample images to obtain an image classification model; The lightweight network model acquisition process includes: S2.

1. Within the specified clipping parameter space, randomly initialize the channels of each layer of the deep network model according to a predetermined ratio to obtain a deep network model with fixed clipping. S2.

2. Use the inference accuracy of the fixed-clipping deep network model as the input of the Grey Wolf algorithm to update the channel pruning ratio coefficient of each layer of the deep network model, and obtain the pruned deep network model, i.e., the lightweight network model. The specific implementation process of step S2.2 includes: A) Randomly generate a gray wolf population X to participate in the search. i,j :X i,j ~U(lb,ub), where i is the number of gray wolves in the population and i∈{1,2…N}, N is the total population size, j is the population dimension (i.e., the number of network layers), U is a random function, and lb and ub are the upper and lower bounds of the search interval; initialize the gray wolf population X participating in the search. i,j The position of each gray wolf in the network; the fitness of each gray wolf is specified as the inference accuracy of the fixed-pruned deep network model; B) Use the following formula to search for the position X(t) of the candidate gray wolf: X(t+1)=X p (t)-A·D,D=|C·X p (t)-X(t)|;where D represents the distance between the candidate gray wolf and the prey, t is the current iteration number, and X p (t) represents the prey's location, and A and C are adjustment coefficients; C) Determine if the iteration termination condition is met. If yes, output the optimal individual and its fitness value, and end the iteration. Otherwise, calculate the fitness of the candidate gray wolves and proceed to step D). D) When fitness increases, update the candidate gray wolf positions using the following formula: X(t+1)=(1 / 3)((X W -A1D W )+(X Y -A2D Y )+(X Z -A3D Z ))(1-t / T)+(X W -A1D W )·(t / T); where X(t) represents the current candidate gray wolf position, X(t+1) represents the candidate gray wolf position at the next time step, X W X Y and x Z The current positions of wolves W, Y, and Z are represented by A1, A2, A3, and C1, C2, C3, respectively. These are random variables. W D Y D Z D represents the distances moved between candidate gray wolves and gray wolves at W, Y, and Z, respectively. W =|C1·X W -X(t)|,D Y =|C2·X Y -X(t)|,D Z =|C3·X Z -X(t)|; The W wolf, Y wolf, and Z wolf correspond to the best individual, the good individual, and the second best individual, respectively; the position of the gray wolf corresponds to the pruning rate of the network layer in the deep network model; T is the set maximum number of iterations; E) Update the fitness value of the candidate gray wolf and return to step C); F) Calculate the L1 norm of each channel in each network layer. Prune the channels in each network layer whose parameter values ​​have an L1 norm lower than the pruning rate of the network layer. Update the batch normalized layer of the pruned deep network model using the adaptive batch normalization method to obtain a lightweight network model.

2. The lightweight image classification method for terminal devices according to claim 1, characterized in that, A = 2a·r1 - a, where r1 is a random vector between 0 and 1, and a = 2e -t / T T is the maximum number of iterations set.

3. The lightweight image classification method for terminal devices according to claim 1, characterized in that, C = 2·r², where r² is a random vector between 0 and 1.

4. The lightweight image classification method for terminal devices according to claim 1, characterized in that, The deep network model is obtained by adding an L1 norm to the loss function during training; the expression for the loss function after adding the L1 norm is: Loss* is the standard loss function for deep networks, K is the set of network weights, ||·||1 is the L1 norm, and γ is the penalty factor.

5. The lightweight image classification method for terminal devices according to claim 1, characterized in that, After step S2, the following is also included: S3. Adjust the parameters of the lightweight network model obtained in step S2.2 to obtain the final lightweight network model.

6. The lightweight image classification method for terminal devices according to claim 1, characterized in that, After step S2, the method further includes: using the test set data as input to the network classification model, and determining whether the network classification model meets the accuracy requirements.

7. The lightweight image classification method for terminal devices according to claim 1, characterized in that, After step S2, the method further includes: inputting the image into the network classification model to obtain the image category.

8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory; characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program / instructions stored thereon; characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Lightweight image classification method, system and device based on model pruning

    CN112668630A

  • Deep network model lightweight method and system applied to image processing

    CN115186805A