Pruning method, classification method, device and storage medium of image classification model
Patent Information
- Application Number
- CN202611039957.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2046-07-14
AI Technical Summary
[0005]针对现有技术的以上缺陷或改进需求,本发明提供了一种图像分类模型的剪枝方法、分类方法、设备及存储介质,用以解决现有技术对基于脉冲神经网络的图像分类模型剪枝后导致图像分类准确性降低的技术问题
1、本发明提供了一种图像分类模型的剪枝方法,其中,图像分类模型为脉冲神经网络;将待剪枝的图像分类模型SNN每一层中的每个权重参数与对应通道的当前整体重要性评分相乘,并将相乘后小于预设阈值的权重参数置为0,以实现剪枝;其中,整体重要性评分基于时序重要性评分和通道重要性评分来确定;时序重要性评分从时空特征的角度对通道的重要性进行评估,时空特征越明显,时序重要性评分越高,时序感知度较高;通道重要性评分从通道相关性角度对通道的重要性进行评估,通道相关性越高,通道重要性评分越高,显式地捕获了通道间的预测依赖关系,避免了剪除高影响通道导致的信息瓶颈。基于上述设计,本发明准确地评估SNN中每个通道的重要程度,能够在降低存储与计算开销的前提下,避免剪枝后模型图像分类的准确性降低的技术问题。
Smart Images

Figure CN122551079B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of model compression technology, and more specifically, relates to a pruning method, classification method, device and storage medium for an image classification model. Background Technology
[0002] Image classification is a fundamental task in computer vision, widely used in security monitoring, autonomous driving, medical image diagnosis, and industrial quality inspection. However, high-performance image classification models are typically complex in structure and have a large number of parameters, posing significant deployment challenges. While high-performance GPUs can meet inference requirements on cloud servers, on resource-constrained edge devices (such as neuromorphic chips, smartphones, embedded cameras, drones, and in-vehicle computing platforms), the large model size and parameters require substantial memory and computational resources, easily leading to memory overflows or performance lag, making real-time image classification difficult. Therefore, researching a pruning method for image classification models to compress them is of great significance.
[0003] Spiking Neural Networks (SNNs), as a third-generation neural network, transmit information through discrete spike events. This allows for orders of magnitude reduction in energy consumption on event-driven neuromorphic hardware, making them a core paradigm for edge intelligence and neuromorphic computing, and widely applied in computer vision fields such as image classification. However, image classification models based on spiking neural networks still face problems in practical deployment, such as severe parameter redundancy and large model size, making them difficult to directly map to resource-constrained edge devices (such as neuromorphic chips, smartphones, embedded cameras, drones, and in-vehicle computing platforms).
[0004] Existing pruning methods primarily focus on image classification models based on artificial neural networks. For example, weight-based pruning algorithms remove redundant parameters by comparing the absolute values of weights; the Wanda pruning algorithm uses the product of weights and activations as an importance indicator, achieving rapid pruning without fine-tuning on a small amount of calibration data. However, unlike artificial neural networks, which input continuous real-valued activations, spiking neural networks (SNNs) input binary spikes without magnitude. When using the aforementioned pruning methods, because the activations of SNNs are discrete binary pulses (0 or 1) without continuous amplitude, the product of weights and the corresponding pulse activations of image samples cannot reflect the true feature contribution. Furthermore, SNNs rely on pulse sequences in the time dimension to transmit information, and the aforementioned pruning methods do not consider temporal dynamics and the pulse dependencies between channels, leading to the incorrect pruning of key spatiotemporal feature channels. This significantly reduces the accuracy of image classification models after pruning. Summary of the Invention
[0005] In view of the above-mentioned defects or improvement needs of the prior art, the present invention provides a pruning method, classification method, device and storage medium for image classification models, so as to solve the technical problem that the image classification accuracy is reduced after pruning the image classification model based on spiking neural network in the prior art.
[0006] To achieve the above objectives, in a first aspect, the present invention provides a pruning method for an image classification model, wherein the image classification model is a spiking neural network; the pruning method includes: acquiring a sample set; the samples in the sample set are pulse-coded sequences of image samples after pulse coding; The sample set is input into the image classification model SNN to be pruned, and the current overall importance score of each channel in the SNN layer is calculated based on the input of each layer of the SNN. Each weight parameter in each layer of the SNN is multiplied by the corresponding current overall importance score, and the weight parameter whose multiplication result is less than a preset threshold is set to 0 to achieve pruning. Wherein, the c-th channel in the j-th layer of the SNN Current overall importance score It is calculated in the following way: Calculation Channel Current time series importance score ; The number of samples in the sample set; The preset number of time steps; The preset weights are the weights corresponding to the j-th layer of the SNN at the t-th time step; To select the nth sample in the sample set When input into the SNN, channels The average pulse firing rate at the t-th time step is specifically... When input into an SNN, it is the input of the j-th layer of the SNN. The pulse tensor at the t-th time step The pulse ratio of the c-th channel; ; The number of layers in the SNN; ; For the j-th layer of SNN and The number of channels; Starting from the second layer of the SNN, the input to each layer is the pulse tensor sequence output by the previous layer. Calculate the channels separately Current channel distribution density Current impact and current time stability ;right , and Perform a weighted summation to obtain the channel. Current channel importance score ;wherein, the c-th channel in the j-th layer of the SNN is related to the c-th channel. Channel correlation between channels ; for The c-th channel in The first in Correlation between channels; ; ; The maximum preset interval step size; ; For channel The coefficient of variation of all corresponding average pulse firing rates; Based on ratings and The channel was calculated. Current overall importance score .
[0007] More preferably, the weight It can be obtained through the following methods: Normalized time step vector The input is fed into the weight allocation model corresponding to the j-th layer of the SNN. In the process, a T-dimensional weight vector is obtained, and then normalized to obtain a normalized weight vector. .
[0008] More preferably, the weight allocation model corresponding to the j-th layer of the SNN It was obtained through training in the following manner: Obtain the training set; the training samples in the training set have the same type and dimension as the samples in the sample set. By minimizing the variance of the current temporal importance score of each channel in the j-th layer of the SNN when the training set is input into the SNN, and the variance of the vector... Input to weight allocation model The weighted sum of the impulse entropy of the normalized weight vector obtained at that time is used for the weight allocation model. Perform iterative training; In each iteration iter, the c-th channel in the j-th layer of the SNN The current time series importance score is ; This represents the number of training samples in the training set. In iteration Next, the vector Input to weight allocation model The t-th weight in the normalized weight vector obtained at that time; To use the k-th training sample in the training set When input into the SNN, channels The average pulse firing rate at the t-th time step is specifically... When input into the SNN, the proportion of pulses in the c-th channel of the pulse tensor at the t-th time step in the input of the j-th layer of the SNN; .
[0009] More preferably, the weight for: ; in, This is the preset attenuation coefficient.
[0010] More preferably, the channel Current overall importance score .
[0011] More preferably, the coefficient of variation for: ; and These are the channels corresponding to each sample in the sample set. The mean and variance of the average pulse firing rate at the t-th time step; This is a preset constant.
[0012] More preferably, the average pulse firing rate for: ; in, and They are respectively The height and width.
[0013] Secondly, the present invention provides an image classification method, comprising: performing pulse coding on an image to be classified, and then inputting it into an image classification model to obtain an image classification result; The image classification model is a spiking neural network pruned using the pruning method provided in the first aspect of this invention; the samples used in the pruning method are pulse-coded sequences of image samples after pulse coding.
[0014] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform either the pruning method of the image classification model provided in the first aspect of the present invention or the image classification method provided in the second aspect of the present invention.
[0015] Fourthly, the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed by a processor, it controls the device where the storage medium is located to execute the pruning method of the image classification model provided in the first aspect of the present invention or the image classification method provided in the second aspect of the present invention.
[0016] In summary, the above-described technical solutions conceived in this invention can achieve the following beneficial effects: 1. This invention provides a pruning method for an image classification model, wherein the image classification model is a spiking neural network (SNN). Each weight parameter in each layer of the SNN to be pruned is multiplied by the current overall importance score of the corresponding channel, and weight parameters whose multiplication result is less than a preset threshold are set to 0 to achieve pruning. The overall importance score is determined based on temporal importance score and channel importance score. The temporal importance score evaluates the importance of channels from the perspective of spatiotemporal features; the more pronounced the spatiotemporal features, the higher the temporal importance score, indicating higher temporal awareness. The channel importance score evaluates the importance of channels from the perspective of channel correlation; the higher the channel correlation, the higher the channel importance score, explicitly capturing the predictive dependencies between channels and avoiding the information bottleneck caused by pruning high-impact channels. Based on the above design, this invention accurately evaluates the importance of each channel in the SNN, and can avoid the technical problem of reduced image classification accuracy after pruning while reducing storage and computational overhead.
[0017] 2. The pruning method for the image classification model provided by this invention relies solely on the sample set for the entire reshaping process, without requiring backpropagation fine-tuning of the image classification model SNN, making it suitable for rapid deployment and online compression scenarios.
[0018] 3. Furthermore, in the pruning method of the image classification model provided by this invention, the weights used when calculating the temporal importance score are... By normalizing the time step vector The input is fed into the weight allocation model corresponding to the j-th layer of the SNN. The results show that this method can adaptively identify the information contribution at different time steps, overcoming the shortcomings of traditional methods that uniformly aggregate information at each time step. This can further improve the accuracy of temporal importance scoring, thereby further improving pruning performance and better ensuring the accuracy of model image classification.
[0019] 4. Furthermore, in the pruning method of the image classification model provided by this invention, the weight allocation model... By minimizing the variance of the current temporal importance score of each channel in the j-th layer of the SNN when the training set is input into the image classification model SNN, the vector... Input to weight allocation model The weights are obtained by training with a weighted sum of the impulse entropy of the normalized weight vector. This design constrains the weight allocation from two complementary dimensions: minimizing the variance of the temporal importance scores of each channel to ensure that the weight allocation of different channels tends to be balanced and to avoid individual channels being mistakenly pruned due to excessive weight skew; at the same time, maximizing the impulse entropy of the weight vector to make the weight distribution more dispersed, so that the model can make full use of the information of multiple time steps rather than being overly concentrated in a few time steps, thereby improving the robustness and generalization ability of temporal importance assessment, and thus better ensuring the accuracy of the model's image classification.
[0020] 5. Furthermore, in the pruning method of the image classification model provided by this invention, the weights... This exponential decay form simulates the synaptic time constant characteristics of biological neural systems, assigning higher weights to earlier time steps, which aligns with the gradual accumulation of information over time in SNNs and the encoding of key contour information by early pulses. Simultaneously, the normalization operation ensures that the sum of the weights at each time step is 1, making the weight allocation interpretable and requiring only adjustment of a single hyperparameter. It can adapt to networks with different time steps, simplifying the deployment and optimization process. Attached Figure Description
[0021] Figure 1 A flowchart illustrating the pruning method for an image classification model provided in an embodiment of the present invention.
[0022] Figure 2 Accuracy curves at different sparsities on the CIFAR-10 dataset provided in this embodiment of the invention.
[0023] Figure 3 Accuracy curves at different sparsities on the DVS-CIFAR10 dataset provided in this embodiment of the invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0025] To achieve the above objectives, in a first aspect, the present invention provides a pruning method for an image classification model, wherein the image classification model is a spiking neural network; such as Figure 1 As shown, the above pruning methods include: Obtain the sample set The sample is a pulse-coded sequence of an image sample after pulse coding. It is the nth sample in the sample set; for The pulse tensor (i.e., the pulse activation graph) at the t-th time step. ; The number of samples in the sample set; ; The preset number of time steps; The sample set is input into the image classification model SNN to be pruned, and the current overall importance score of each channel in the SNN layer is calculated based on the input of each layer of the SNN. Each weight parameter in each layer of the SNN is multiplied by the corresponding current overall importance score, and the weight parameter whose multiplication result is less than a preset threshold is set to 0 to achieve pruning. Wherein, the c-th channel in the j-th layer of the SNN Current overall importance score It is calculated in the following way: Get the samples respectively When input into the SNN, the input impulse tensor sequence of the j-th layer of the SNN ;sequence This is the output of the (i-1)th layer of the SNN; This is the pulse tensor (i.e., pulse activation map) of the output of the (i-1)th layer of the SNN (the input of the i-th layer of the SNN) at the t-th time step. L represents the number of layers in the SNN. for ; based on ,calculate Corresponding channel Average pulse firing rate at time step t ; Calculation channel Current time series importance score ; The preset weights are the weights corresponding to the j-th layer of the SNN at the t-th time step; ; The number of layers in the SNN; ; For the j-th layer of SNN and The number of channels; Calculation Channel Current channel distribution density ; calculate The c-th channel in The Middle Correlation between channels ; ; ; The maximum preset interval step size; ; Calculate the relationship between the c-th channel and the j-th channel in the j-th layer of the SNN. Channel correlation between channels The channel is then calculated. Current impact ; Calculation Channel Coefficient of variation of all corresponding average pulse firing rates The channel is then calculated. Current time stability ; right , and Perform a weighted summation to obtain the channel. Current channel importance score ; Based on ratings and rating The channel was calculated. Current overall importance score .
[0026] It should be noted that the rating and rating The higher the score The larger. Based on rating and rating Calculation channel Current overall importance score There are many methods, such as using scoring and rating Add them together to get the current overall importance score. Or by rating and rating Multiply by each product to obtain the current overall importance score. Preferably, in one optional implementation, the channel Overall Importance Score .
[0027] In one alternative implementation, the average pulse firing rate for: ; in, and They are respectively The height and width.
[0028] It should be noted that the above method obtains the preset weights corresponding to the j-th layer of the SNN at time step t. There are several ways to do this, such as through experience-based settings. Two preferred implementation methods are provided below: In one alternative implementation, the weight It can be obtained through the following methods: Normalized time step vector The input is fed into the weight allocation model corresponding to the j-th layer of the SNN. In the process, a T-dimensional weight vector is obtained, and then normalized to obtain a normalized weight vector. .
[0029] It should be noted that the above weight allocation model can be any machine learning model, preferably a deep learning model, such as a multilayer perceptron, artificial neural network, CNN, etc., but there is no limitation here.
[0030] Preferably, in one optional implementation, the weight allocation model corresponding to the j-th layer of the SNN It was obtained through training in the following manner: Obtain the training set; the training samples in the training set have the same type and dimension as the samples in the sample set. By minimizing the variance of the current temporal importance score of each channel in the j-th layer of the SNN when the training set is input into the SNN, and the variance of the vector... Input to weight allocation model The weighted sum of the impulse entropy of the normalized weight vector obtained at that time is used for the weight allocation model. Perform iterative training; In each iteration iter, the c-th channel in the j-th layer of the SNN The current time series importance score is ; This represents the number of training samples in the training set. In iteration Next, the vector Input to weight allocation model The t-th weight in the normalized weight vector obtained at that time; For based on The kth training sample in the calculated training set Corresponding channel The average pulse firing rate at the t-th time step is specifically... When input into the SNN, the proportion of pulses in the c-th channel of the pulse tensor at the t-th time step in the input of the j-th layer of the SNN; ; for The pulse tensor at the t-th time step; To be When input into the SNN, the pulse tensor at the t-th time step of the output of the (i-1)th layer of the SNN; ; In each iteration of iter, the impulse entropy of the normalized weight vector is: .
[0031] In one alternative implementation, the average pulse firing rate for: ; in, and They are respectively The height and width.
[0032] In an alternative implementation method two, the weights for: ; in, This is the preset attenuation coefficient.
[0033] In one alternative implementation, the coefficient of variation for: ; and These are the channels corresponding to each sample in the sample set. The average pulse at the t-th time step.
[0034] To further illustrate the pruning method of the image classification model provided by this invention, a specific embodiment is described in detail below: The overall process of the pruning method for the image classification model SNN provided in this embodiment includes: 1) Obtain pre-trained SNN and calibration data: This embodiment uses a spiking ResNet-19-based neural network as the image classification model, with Leaky Integrate-and-Fire (LIF) neurons. Membrane potential updates and pulse firing follow the formula: ; ; in, The membrane time constant; For the first Convolutional weights of the layers; For Heaviside step function, The threshold for distribution is set. Regarding calibration data, 128–256 unlabeled samples are randomly selected from the training set as the calibration set, and the input pulse volumes of all layers can be collected through a single forward propagation.
[0035] For the The layer will take the nth sample from the sample set (in this embodiment, a small amount of unlabeled calibration data). When input into the SNN, the input impulse tensor sequence of the j-th layer of the SNN ; for The pulse tensor at the t-th time step; Where T is the preset time step (20 in this embodiment). This represents the number of samples in the sample set (in this example, the value is 128). For the j-th layer of SNN and The number of channels, where H and W are spatial dimensions.
[0036] 2) Calculate the time series importance score; Calculate the nth sample in the sample set When input into an SNN, the c-th channel in the j-th layer of the SNN Average pulse firing rate at time step t for: ; in, and They are respectively The height and width.
[0037] Normalized time step vector The input is fed into the weight allocation model corresponding to the j-th layer of the SNN. In the process, a T-dimensional weight vector is obtained, and then normalized using softmax to obtain a normalized weight vector. .
[0038] In this embodiment, the weight allocation model is a lightweight multilayer perceptron (the hidden layer dimension is 16, and each layer has only 49 parameters).
[0039] Calculation Channel Current time series importance score ;in, The preset weights are the weights corresponding to the j-th layer of the SNN at the t-th time step.
[0040] The weighting model automatically identifies key time steps through a data-driven approach. For example, in CIFAR-10 frame input, early time steps often encode contour information, while later time steps refine texture details. The learnable weights can adaptively balance the contributions of both.
[0041] 3) Calculate the channel importance score; Calculation Channel Current channel issuance density ; For the lag step size (In this embodiment, ), calculate standardized lag correlation, specifically, for The c-th channel in The first in The correlation between the channels is measured using Pearson correlation in this embodiment. Specifically, ;in, for The slice under the c-th channel; for The first in Slices under each channel; As a preset constant, the value in this embodiment is [value]. ; Represents covariance; It represents the standard deviation.
[0042] Calculate the relationship between the c-th channel and the j-th channel in the j-th layer of the SNN. Channel correlation between channels The channel is then calculated. Current impact ; Calculation Channel Coefficient of variation of all corresponding average pulse firing rates The channel is then calculated. Current time stability ;in, and These are the channels corresponding to each sample in the sample set. The mean and variance of the average pulse firing rate at the t-th time step; As a preset constant, the value in this embodiment is [value]. This is to ensure numerical stability.
[0043] right , and Perform a weighted summation to obtain the channel. Current channel importance score ;Specifically, ;in, and These are all hyperparameters, and in this embodiment, they are set to 0.1 and 0.05 respectively.
[0044] Channel importance score It also takes into account the collective predictive influence, activity level, and distribution stability of the channels, effectively avoiding the problem of mistakenly deleting active but low-correlation channels by relying solely on cross-correlation.
[0045] 4) Geometrically fuse the temporal importance score and the channel importance score to generate an overall importance score, unify the importance tensor, and perform pruning.
[0046] Specifically, the c-th channel in the j-th layer of the SNN Current overall importance score .
[0047] Each weight parameter in each layer of the SNN is multiplied by its corresponding current overall importance score, and weight parameters whose multiplication result is less than a preset threshold are set to 0 to achieve pruning.
[0048] In this embodiment, the preset threshold is 50%.
[0049] Furthermore, in this embodiment, after pruning, the retained weights in the SNN can be adaptively quantized with low bits, thereby deploying the pruned SNN into a heterogeneous fusion neuromorphic chip.
[0050] Specifically, after pruning, the retained weights of each layer undergo adaptive low-bit quantization. Specifically, the minimum value of the retained weights for that layer is calculated. With the maximum value Calculate the quantization step size and zeros based on the target bit width b (e.g., b=8): ; ; Map floating-point weights to integer quantized values: ; During the inference phase, approximate weights are recovered through dequantization: ; This adaptive strategy dynamically adjusts the quantization grid based on the actual weight distribution of each layer, avoiding the accuracy loss caused by globally uniform quantization. When deploying heterogeneous fusion neuromorphic chips, the quantized integer values can be directly stored in on-chip SRAM and directly mapped to the heterogeneous fusion neuromorphic chip. Fast dequantization is achieved through a lookup table, significantly reducing storage bandwidth.
[0051] On heterogeneous fusion neuromorphic chips (such as hybrid architectures integrating digital neuron arrays and analog synaptic arrays), the sparse weight matrix of the pruned and quantized spiking neural network can be stored in coordinate list (COO) or compressed sparse row (CSR) format, and the quantized integer values are efficiently dequantized using an on-chip lookup table. Because the number of model parameters and the bit width are significantly reduced after reshaping, the on-chip SRAM usage is significantly decreased. At the same time, event-driven sparse computation further reduces dynamic power consumption, enabling complex SNN models to perform real-time inference at the edge, fully leveraging the event-driven and low-power advantages of neuromorphic hardware.
[0052] To further illustrate the pruning method of the image classification model provided by this invention, a detailed explanation is given below with reference to an experimental example: To verify the effectiveness of the pruning method for the image classification model provided in this invention, image classification experiments were conducted on the CIFAR-10 and DVS-CIFAR10 datasets. The baseline model was the uncompressed Spiking ResNet-19, achieving a baseline accuracy of 90.70% on CIFAR-10 and 82.30% on DVS-CIFAR10. Comparison methods included the traditional Magnitude Pruning algorithm, the Wanda pruning algorithm, and the pruning method for the image classification model provided in this invention (denoted as TDAP-Q).
[0053] Table 1 shows the accuracy (%) of each method on CIFAR-10: Table 1
[0054] At 70% sparsity, the pruning method for the image classification model provided by this invention improves the accuracy by 1.49% compared to the traditional amplitude pruning algorithm and by 2.27% compared to the Wanda pruning algorithm, with performance loss controlled within 4%.
[0055] Table 2 shows the accuracy (%) of each method on DVS-CIFAR10: Table 2
[0056] At 70% sparsity, the pruning method for the image classification model provided by this invention improves the accuracy by 6.40% compared to the traditional amplitude pruning algorithm and by 13.30% compared to the Wanda pruning algorithm.
[0057] Furthermore, by performing 8-bit quantization (TDAP-Q-8bit) on the retained weights based on 70% sparsity, the accuracy on CIFAR-10 is 86.58%, only 0.17 percentage points lower than that of pruning only (TDAP-Geo 86.75%); the accuracy on DVS-CIFAR10 is 36.82%, only 0.18 percentage points lower than that of pruning only (TDAP-Geo 37.00%). Experimental results show that the pruning method of the image classification model provided in this invention can control the performance loss to within 1% under extremely high compression ratios, significantly reducing storage and computational overhead, and fully verifying the effectiveness of the pruning method of the image classification model provided in this invention.
[0058] Figure 2 and Figure 3 Accuracy curves for different sparsities on CIFAR-10 and DVS-CIFAR10 are presented respectively. It can be observed that as the sparsity increases, the descent slope of the spiking neural network pruning method (TDAP-Q) provided in this invention is significantly slower than that of the baseline method, especially after the sparsity exceeds 50%, which shows that the joint modeling of time-aware and dependency-aware methods is crucial for aggressive compression.
[0059] Secondly, the present invention provides an image classification method, comprising: performing pulse coding on an image to be classified, and then inputting it into an image classification model to obtain an image classification result; The image classification model is a spiking neural network pruned using the pruning method provided in the first aspect of this invention; the samples used in the pruning method are pulse-coded sequences of image samples after pulse coding.
[0060] The relevant technical solutions are the same as the pruning method provided in the first aspect of this invention, and will not be described in detail here.
[0061] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform either the spiking neural network pruning method provided in the first aspect of the present invention or the image classification method provided in the second aspect of the present invention.
[0062] The related technical solutions are the same as the pruning method provided in the first aspect and the image classification method provided in the second aspect of this invention, and will not be described in detail here.
[0063] Fourthly, the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed by a processor, it controls the device where the storage medium is located to execute the pruning method of the image classification model provided in the first aspect of the present invention or the image classification method provided in the second aspect of the present invention.
[0064] The related technical solutions are the same as the pruning method provided in the first aspect and the image classification method provided in the second aspect of this invention, and will not be described in detail here.
[0065] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A pruning method for an image classification model, characterized in that, The image classification model is a spiking neural network (SNN); the pruning method includes: acquiring a sample set; the samples in the sample set are pulse-coded sequences of image samples after pulse coding; inputting the sample set into the image classification model SNN to be pruned, and calculating the current overall importance score of each channel in that layer of the SNN based on the input of each layer; multiplying each weight parameter in each layer of the SNN by the corresponding current overall importance score, and setting weight parameters whose multiplication result is less than a preset threshold to 0, thereby achieving pruning; wherein, the c-th channel in the j-th layer of the SNN Current overall importance score It is calculated in the following way: Calculation Channel Current time series importance score ; The number of samples in the sample set; The preset number of time steps; The preset weights are the weights corresponding to the j-th layer of the SNN at the t-th time step. To select the nth sample in the sample set When input into the SNN, channels The average pulse firing rate at the t-th time step is specifically... When input into an SNN, it is the input of the j-th layer of the SNN. The pulse tensor at the t-th time step The pulse ratio of the c-th channel; ; The number of layers in the SNN; ; For the j-th layer of SNN and The number of channels; Starting from the second layer of the SNN, the input to each layer is the pulse tensor sequence output by the previous layer. Calculate the channels separately Current channel issuance density Current impact and current time stability ;right , and Perform a weighted summation to obtain the channel. Current channel importance score ;wherein, the c-th channel in the j-th layer of the SNN is related to the c-th channel. Channel correlation between channels ; for The c-th channel in The first in Correlation between channels; ; ; The maximum preset interval step size; ; For channel The coefficient of variation of all corresponding average pulse firing rates; Based on ratings and The channel was calculated. Current overall importance score .
2. The pruning method for the image classification model according to claim 1, characterized in that, Weight It can be obtained through the following methods: Normalized time step vector The input is fed into the weight allocation model corresponding to the j-th layer of the SNN. In the process, a T-dimensional weight vector is obtained, and then normalized to obtain a normalized weight vector. .
3. The pruning method for the image classification model according to claim 2, characterized in that, Weight allocation model corresponding to the j-th layer of SNN It was obtained through training in the following manner: Obtain the training set; the training samples in the training set have the same type and dimension as the samples in the sample set. By minimizing the variance of the current temporal importance score of each channel in the j-th layer of the SNN when the training set is input into the SNN, and the variance of the vector... Input to weight allocation model The weighted sum of the impulse entropy of the normalized weight vector obtained at that time is used for the weight allocation model. Perform iterative training; In each iteration iter, the c-th channel in the j-th layer of the SNN The current time series importance score is ; This represents the number of training samples in the training set. In iteration Next, the vector Input to weight allocation model The t-th weight in the normalized weight vector obtained at that time; To use the k-th training sample in the training set When input into the SNN, channels The average pulse firing rate at the t-th time step is specifically... When input into the SNN, the proportion of pulses in the c-th channel of the pulse tensor at the t-th time step in the input of the j-th layer of the SNN; .
4. The pruning method for the image classification model according to claim 1, characterized in that, Weight for: ; in, This is the preset attenuation coefficient.
5. The pruning method for the image classification model according to any one of claims 1-4, characterized in that, aisle Current overall importance score .
6. The pruning method for the image classification model according to any one of claims 1-4, characterized in that, coefficient of variation for: ; and These are the channels corresponding to each sample in the sample set. The mean and variance of the average pulse firing rate at the t-th time step; This is a preset constant.
7. The pruning method for the image classification model according to any one of claims 1-4, characterized in that, Average pulse firing rate for: ; in, and They are respectively The height and width.
8. An image classification method, characterized in that, include: After pulse coding is performed on the image to be classified, it is input into the image classification model to obtain the image classification result; Wherein, the image classification model is a spiking neural network pruned using the pruning method of the image classification model according to any one of claims 1-7; the samples used in the sample set in the pruning method are pulse-coded sequences of image samples after pulse coding.
9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the pruning method of the image classification model according to any one of claims 1-7 or the image classification method according to claim 8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein when the computer program is run by a processor, it controls the device where the storage medium is located to perform the pruning method of the image classification model according to any one of claims 1-7 or the image classification method according to claim 8.
Citation Information
Patent Citations
Lightweight image classification method, system and device based on model pruning
CN112668630A
Rapid scoring pulse neural network architecture optimization method and system
CN119378617A