Pruning method and device of pulse neural network and electronic equipment

By pruning spiking neural networks and optimizing them using soft thresholding and gradient descent algorithms, the resource limitations of deploying deep spiking neural networks on neuromorphic computing chips are overcome, achieving the effect of maintaining expressive power and saving computational resources in sparse networks.

CN115423087BActive Publication Date: 2026-07-03PEKING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PEKING UNIV
Filing Date
2022-07-22
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing neuromorphic computing chips cannot effectively deploy deep spiking neural networks, mainly due to limited computing resources, which make it difficult to accommodate a large number of synaptic connections.

Method used

By employing a pruning method for spiking neural networks, the weight vectors of the synaptic connection layers are initialized, and then trained using a soft thresholding function and gradient descent algorithm. Unnecessary hidden parameters are removed to obtain sparse weight vectors, which can adapt to the resource constraints of neuromorphic computing chips.

Benefits of technology

By controlling the sparsity of weights during training, gradient vanishing can be avoided, ensuring the expressive power of the network and saving hardware computing resources. It is applicable to various gradient-based spiking neural networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115423087B_ABST
    Figure CN115423087B_ABST
Patent Text Reader

Abstract

This invention discloses a pruning method, apparatus, and electronic device for spiking neural networks. The method includes: initializing an initial vector composed of the weights of each connection in the synaptic connection layer to obtain a weight vector; when pruning the spiking neural network using a backpropagation-based algorithm, calculating the gradient of each loss function value with respect to the hidden parameter vector using a predefined derivative function; updating the gradient of the hidden parameter vector using gradient descent, and calculating a target threshold for subsequent gradient updates using a preset incrementing function; based on the target threshold, mapping the hidden parameter vector back to the weight vector using the soft threshold function; and obtaining a trained spiking neural network model when the number of pruning training rounds reaches a preset number. This invention solves the technical problem of effectively deploying spiking neural networks on neuromorphic computing chips in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of brain-like intelligence technology, and more specifically, to a pruning method, apparatus, and electronic device for spiking neural networks. Background Technology

[0002] Spiking Neural Networks (SNNs) are important learning models in the field of brain-inspired intelligence. Compared to traditional artificial intelligence networks, SNNs further simulate the computational patterns in the brain. Neurons in SNNs fire discrete events, also known as "spiking signals," and communicate with other neurons through synaptic connections. The human brain, using spiking communication, can often complete numerous complex tasks, including facial recognition, consuming only about 20 watts of power, demonstrating high energy efficiency. Similarly, SNNs can run on neuromorphic computing chips and exhibit significantly higher energy efficiency during inference than traditional general-purpose computing devices such as GPUs. Currently, SNNs have achieved certain performance results in tasks such as spatiotemporal data classification, detection, segmentation, and tracking.

[0003] To deploy practical spiking neural networks on the aforementioned neuromorphic computing chips, these networks typically need to be quite large. These networks often have deep structures and are known as deep spiking neural networks. A deep spiking neural network, such as Spiking ResNet or Spiking GoogleNet, often has 50 or more layers, containing a large number of synapses. However, the computational resources on neuromorphic computing chips are often very limited. For example, a 48-node SpiNNaker computing board can only simulate a maximum of 250,000 neurons and 80 million synaptic connections, which is insufficient even to deploy a single deep spiking neural network. Therefore, pruning deep spiking neural networks is crucial for their practical deployment.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This invention provides a pruning method, apparatus, and electronic device for spiking neural networks, which at least solves the technical problem in the related art that spiking neural networks cannot be effectively deployed on neuromorphic computing chips.

[0006] According to one aspect of the present invention, a pruning method for a spiking neural network is provided, comprising: initializing an initial vector composed of each connection weight in a synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein the synaptic connection layer is located in a spiking neural network model to be pruned, optimized, and retrained; substituting each element of the hidden parameter vector into a soft thresholding function to obtain a weight vector; inputting training data into the spiking neural network model, and calculating a loss function value corresponding to each task type; wherein the training data includes visual information, and the task type includes classification, detection, and tracking of target objects contained in the visual information; when the algorithm is based on backpropagation... When pruning the spiking neural network, the gradient of each loss function value with respect to the hidden parameter vector is calculated using a predefined derivative function; wherein the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function; the gradient of the hidden parameter vector is updated by gradient descent, and a target threshold is calculated using a preset incrementing function for the soft thresholding function to update the gradient again; based on the target threshold, the hidden parameter vector is mapped to the weight vector again using the soft thresholding function; when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, the hidden parameter vector is deleted, resulting in a pruned spiking neural network model.

[0007] According to another aspect of the present invention, a pruning device for a spiking neural network is also provided, comprising: an initialization unit, configured to initialize an initial vector composed of each connection weight in a synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein the synaptic connection layer is located in a spiking neural network model to be pruned, optimized, and retrained; a first calculation unit, configured to substitute each element of the hidden parameter vector into a soft thresholding function to obtain a weight vector; a second calculation unit, configured to input training data into the spiking neural network model and calculate a loss function value corresponding to each task type; wherein the training data includes visual information, and the task type includes classification, detection, and tracking of target objects contained in the visual information; and a third calculation unit, configured to initialize an initialization ... When the backpropagation algorithm prunes the spiking neural network, it calculates the gradient of each loss function value with respect to the hidden parameter vector using a predefined derivative function; wherein the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function; a gradient update unit is used to update the gradient of the hidden parameter vector by gradient descent, and to calculate the target threshold used when updating the gradient of the soft thresholding function again using a preset incrementing function; a mapping unit is used to map the hidden parameter vector to the weight vector again using the soft thresholding function based on the target threshold; and a determination unit is used to delete the hidden parameter vector when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, thereby obtaining the pruned spiking neural network model.

[0008] According to another aspect of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to execute the above-described pruning method for a spiking neural network through the computer program.

[0009] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, wherein the computer program is configured to execute the above-described pruning method for a spiking neural network at runtime.

[0010] In this embodiment of the invention, an initial vector composed of each connection weight in the synaptic connection layer is used for initialization to obtain a hidden parameter vector with the same elements as the initial vector; wherein the synaptic connection layer is located in the spiking neural network model to be pruned, optimized, and retrained; each element of the hidden parameter vector is substituted into a soft thresholding function to obtain a weight vector; training data is input into the spiking neural network model, and the loss function value corresponding to each task type is calculated; wherein the training data includes visual information, and the task types include classification, detection, and tracking of target objects contained in the visual information; when the spiking neural network is pruned and trained based on the backpropagation algorithm, the loss function value of each hidden parameter vector is calculated using a predefined derivative function. The method involves calculating the gradient of a hidden parameter vector, where the predefined derivative is a modified derivative of the soft thresholding function; updating the gradient of the hidden parameter vector using gradient descent, and calculating the target threshold used for further gradient updates using a preset incrementing function; mapping the hidden parameter vector to the weight vector again using the soft thresholding function based on the target threshold; and deleting the hidden parameter vector when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds to obtain a pruned spiking neural network model. In this method, the application first encodes the weights of the spiking neural network using hidden parameters of the same size using a soft thresholding function, thereby initially obtaining the possibility of the weights entering a pruning state. During training, the gradient of the soft thresholding function is modified so that the pruned weights can obtain non-zero gradients to avoid gradient vanishing and the resulting decrease in network expressive power. By controlling the speed of network weight sparsity at different training stages through a threshold growth function, a balance can be achieved between the goals of learning and sparsity. The resulting network can directly discard hidden parameters and use sparse weights for inference to save hardware computing resources. It is suitable for various gradient-based spiking neural networks, thus solving the technical problem of not being able to effectively deploy spiking neural networks on neuromorphic computing chips in related technologies. Attached Figure Description

[0011] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0012] Figure 1 This is a schematic diagram of an application environment for an optional spiking neural network pruning method according to an embodiment of the present invention;

[0013] Figure 2 This is a schematic diagram of the application environment of another optional pruning method for a spiking neural network according to an embodiment of the present invention;

[0014] Figure 3 This is a flowchart illustrating an optional pruning method for a spiking neural network according to an embodiment of the present invention.

[0015] Figure 4 This is a schematic diagram of the threshold increment function for an optional spiking neural network pruning method in related technologies;

[0016] Figure 5 This is a flowchart illustrating another optional pruning method for a spiking neural network according to an embodiment of the present invention.

[0017] Figure 6 This is a schematic diagram comparing the sparsity and accuracy of another optional pruning method for a spiking neural network according to an embodiment of the present invention.

[0018] Figure 7 This is a schematic diagram of an optional pruning device for a spiking neural network according to an embodiment of the present invention;

[0019] Figure 8 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present invention. Detailed Implementation

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

[0021] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0022] According to one aspect of the present invention, a pruning method for a spiking neural network is provided. Optionally, as an alternative implementation, the above-described pruning method for a spiking neural network can be applied, but is not limited to, to applications such as... Figure 1 The application environment shown includes: a terminal device 102 for human-computer interaction, a network 104, and a server 106. User 108 can interact with terminal device 102, which runs a pruning application for a spiking neural network. Terminal device 102 includes a human-computer interaction screen 1022, a processor 1024, and a memory 1026. The human-computer interaction screen 1022 displays different types of visual information; the processor 1024 acquires weight vectors and visual information; and the memory 1026 stores the weight vectors and visual information.

[0023] Furthermore, server 106 includes database 1062 and processing engine 1064. Database 1062 stores weight vectors to be displayed and visual information. Processing engine 1064 initializes the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein the synaptic connection layer is located in the spiking neural network model to be pruned, optimized, and retrained; each element of the hidden parameter vector is substituted into a soft thresholding function to obtain a weight vector; training data is input into the spiking neural network model to calculate the loss function value corresponding to each task type; wherein the training data includes visual information, and the task types include classification, detection, and tracking of target objects contained in the visual information; when the spiking neural network is pruned and trained based on the backpropagation algorithm, the loss function value for each task type is calculated using a predefined derivative function. The gradient of the loss function value with respect to the hidden parameter vector is calculated; wherein the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function; the gradient of the hidden parameter vector is updated by gradient descent, and the target threshold used for the soft thresholding function to update the gradient again is calculated using a preset incrementing function; based on the target threshold, the hidden parameter vector is mapped to the weight vector again using the soft thresholding function; when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, the hidden parameter vector is deleted to obtain a trained spiking neural network model; the target visual information is input into the pruned and trained spiking neural network model to obtain the visual information processing result corresponding to the current task type. The visual information processing result is displayed on the client of the aforementioned terminal device 102.

[0024] In one or more embodiments, the pruning method of the spiking neural network described above in this application can be applied to... Figure 2 The application environment shown. For example... Figure 2As shown, user 202 and user device 204 can interact with each other. User device 204 includes memory 206 and processor 208. In this embodiment, user device 204 can, but is not limited to, referencing and executing the operations performed by terminal device 102 to obtain visual information processing results.

[0025] Optionally, the terminal device 102 and user device 204 mentioned above include, but are not limited to, mobile phones, set-top boxes, televisions, tablets, laptops, PCs, in-vehicle electronic devices, wearable devices, and other terminals. The network 104 mentioned above may include, but is not limited to, wireless networks or wired networks. The wireless network includes Wi-Fi and other networks that enable wireless communication. The wired network may include, but is not limited to, wide area networks (WANs), metropolitan area networks (MANs), and local area networks (LANs). The server 106 mentioned above may include, but is not limited to, any hardware device capable of computing. The server may be a single server, a server cluster consisting of multiple servers, or a cloud server. The above is merely an example, and no limitations are imposed in this embodiment.

[0026] To address the aforementioned technical problems, as an optional implementation method, such as Figure 3 As shown, this embodiment of the invention provides a pruning method for a spiking neural network, comprising the following steps:

[0027] S302, initialize the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein, the synaptic connection layer is located in the spiking neural network model to be pruned, optimized and retrained;

[0028] S304, Substitute each element of the hidden parameter vector into the soft thresholding function to obtain the weight vector;

[0029] S306, Input the training data into the spiking neural network model and calculate the loss function value corresponding to each task type; wherein, the training data includes visual information, and the task type includes classification, detection and tracking of target objects contained in the visual information;

[0030] S308, when the spiking neural network is pruned and trained using the backpropagation algorithm, the gradient of each loss function value with respect to the hidden parameter vector is calculated using a predefined derivative function; wherein, the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function;

[0031] S310, perform gradient descent to update the gradient of the hidden parameter vector, and use a preset incrementing function to calculate the target threshold used when performing another gradient update using the soft threshold function.

[0032] S312, Based on the target threshold, the hidden parameter vector is mapped to the weight vector again using the soft threshold function;

[0033] S314, when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, the hidden parameter vector is deleted to obtain the pruned and trained spiking neural network model.

[0034] In this embodiment of the invention, an initial vector composed of each connection weight in the synaptic connection layer is used for initialization to obtain a hidden parameter vector with the same elements as the initial vector; wherein the synaptic connection layer is located in the spiking neural network model to be pruned, optimized, and retrained; each element of the hidden parameter vector is substituted into a soft thresholding function to obtain a weight vector; training data is input into the spiking neural network model, and the loss function value corresponding to each task type is calculated; wherein the training data includes visual information, and the task types include classification, detection, and tracking of target objects contained in the visual information; when the spiking neural network is pruned and trained based on the backpropagation algorithm, the loss function value of each hidden parameter vector is calculated using a predefined derivative function. The method involves calculating the gradient of a hidden parameter vector, where the predefined derivative is a modified derivative of the soft thresholding function; updating the gradient of the hidden parameter vector using gradient descent, and calculating the target threshold used for further gradient updates using a preset incrementing function; mapping the hidden parameter vector to the weight vector again using the soft thresholding function based on the target threshold; and deleting the hidden parameter vector when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds to obtain a pruned spiking neural network model. In this method, the application first encodes the weights of the spiking neural network using hidden parameters of the same size using a soft thresholding function, thereby initially obtaining the possibility of the weights entering a pruning state. During training, the gradient of the soft thresholding function is modified so that the pruned weights can obtain non-zero gradients to avoid gradient vanishing and the resulting decrease in network expressive power. By controlling the speed of network weight sparsity at different training stages through a threshold growth function, a balance can be achieved between the goals of learning and sparsity. The resulting network can directly discard hidden parameters and use sparse weights for inference to save hardware computing resources. It is suitable for various gradient-based spiking neural networks, thus solving the technical problem of not being able to effectively deploy spiking neural networks on neuromorphic computing chips in related technologies.

[0035] In one or more embodiments, the pruning method for the spiking neural network further includes:

[0036] The target visual information is input into the pruned and trained spiking neural network model to obtain the visual information processing result corresponding to the current task type.

[0037] In one or more embodiments, the target visual information includes at least one of images, videos, and pulse signals, and the step of inputting the target visual information into the trained spiking neural network model to obtain a visual information processing result corresponding to the current task type includes at least one of the following:

[0038] The visual information is input into a pre-trained spiking neural network model and classified to obtain the classification result of the target visual information.

[0039] Specifically, the aforementioned pulse signals include, but are not limited to, signals sampled by a neuromorphic sensor. For example, the image set or video set can be input into a pruned and trained spiking neural network model for classification, thereby classifying the image set or video set into different categories of images and videos.

[0040] The visual information is input into the pruned and trained spiking neural network model to perform target detection, and the detection result of the target object in the visual information is obtained.

[0041] Specifically, for example, by inputting the image set or video set into a pruned and trained spiking neural network model for target detection, attribute information of any target object in the image or video can be obtained in real time.

[0042] The visual information is input into the pruned and trained spiking neural network model to perform target tracking, and the tracking result of the target object in the visual information is obtained.

[0043] Specifically, for example, by inputting the image set or video set into a pruned and trained spiking neural network model for target tracking, the bounding box of any target object in the image or video can be obtained in real time.

[0044] In one or more embodiments, the synaptic connection layer includes a fully connected layer and a convolutional layer; the initialization operation of the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same number of elements as the initial vector includes:

[0045] The trainable connection weights in the fully connected layer and the convolutional layer are fused into an initial vector w;

[0046] Replace w with a hidden parameter vector θ that has the same number of elements as w;

[0047] The step of substituting each element of the hidden parameter vector into the soft thresholding function to obtain the weight vector includes:

[0048] Substitute each element of θ into the soft threshold function Sd Obtain the weight vector S d (θ); where θ is the hidden parameter vector and d is the threshold parameter;

[0049] S d (x) = sign(x)·(|x|-d) + d≥0, sign(x) is the sign function;

[0050]

[0051] In one or more embodiments, the predefined derivative function includes: S d The derivative of (θ) with respect to θ is always equal to 1.

[0052] In one or more embodiments, during the training process of the spiking neural network by pruning, the d is obtained by at least one of formulas (1), (2), and (3):

[0053] d = kx, x∈[0,1], k>0; (1)

[0054]

[0055]

[0056] Where x represents the pruning training progress. Where n is the current gradient update step of the hidden parameter vector, N is the cumulative gradient update step during the pruning training process, and k is the final value of d at the end of the pruning training.

[0057] In one or more embodiments, the number of pruning training rounds of the spiking neural network model reaching a preset number of rounds includes: the number of gradient updates of the hidden parameter vectors reaching a preset number of rounds.

[0058] Based on the above embodiments, such as Figure 4 As shown, in one application embodiment, the above-described pruning method for spiking neural networks further includes:

[0059] The first step is to define the soft threshold function as S. d (θ) = sign(θ)·(|θ|-d) + ,d≥0, where (·) + element-wise functions And the parameter d∈R + d is the threshold of the soft thresholding function. The initialized network weight vector w is directly assigned to the hidden parameter vector θ←w=S0(θ) of the same size.

[0060] The second step, in the spiking neural network, is to obtain the loss function based on the input training data X and the data label Y. value Furthermore, based on the backpropagation-based algorithm, the gradient of the loss function with respect to the weight vector is obtained. The training data here includes images, videos, or impulse signals (such as signals sampled from neuromorphic sensors) input to the network. Loss function. It depends on the specific task (such as classifying, detecting, or tracking visual information).

[0061] The third step is to calculate the gradient of the loss function with respect to the weight vector. And the modified derivative:

[0062]

[0063] According to the chain rule of differentiation The gradient of the loss function with respect to the hidden parameter vector can be obtained.

[0064] Fourth, after updating the hidden parameter θ using the gradient described above, a predefined threshold growth function is used.

[0065]

[0066] Obtain the threshold at the nth update. Here, N represents the number of updates during the entire training process, thus having This indicates the current algorithm execution progress, and k represents the preset threshold for when the algorithm ends.

[0067] Fifth, apply the soft thresholding function (after increasing the threshold) to the hidden parameters to obtain the network weights before the next update.

[0068] w = S d (θ)

[0069] Repeat the above process after step two a total of N times. In the final model, there is no need to store hidden parameters during inference. Instead, the sparsed weights are used directly for calculation and inference.

[0070] In one specific implementation, the available function f is defined on the interval [0,1], and is monotonically increasing, satisfying f(0) = 0, f(1) = 1. There are multiple choices for the specific f, such as... Figure 5 All three functions shown meet the requirements and can be implemented in ways including but not limited to: Figure 5 The given arbitrary function:

[0071] For example, a direct proportional function: d = kx, x ∈ [0, 1], k > 0;

[0072] The rising segment of the sine function:

[0073] Combination of sine and direct proportion functions:

[0074] In one specific implementation, the backpropagation-based spiking neural network training algorithm refers to a series of methods that calculate the gradient of the output pulse with respect to the network weights through direct or indirect methods. For example, the gradient can be calculated by the relationship between the pulse time and the input connection weights, the smoothed gradient can be obtained by smoothing the step function in the pulse firing using the gradient substitution method, and the approximate optimal weight descent direction can be obtained by using the Widrow-Hoff algorithm or its variants.

[0075] To verify the effectiveness of this invention, pruning experiments were conducted on the popular SEW ResNet-18 test network and the large image classification dataset ILSVRC2012. Using the three threshold growth functions mentioned above, pruning was performed under different parameters k, and the resulting sparsity and accuracy were compared as follows: Figure 6 As shown, the dashed lines represent the classification accuracy of dense networks. It can be seen that the choice of different threshold growth functions has a significant impact on the sparsity of the network, and an appropriate choice can enable the network to still achieve low classification accuracy loss even with sparsity exceeding 90%.

[0076] The technical solutions provided in this application have the following beneficial technical effects:

[0077] First, the weights of the spiking neural network are encoded using a soft thresholding function with hidden parameters of the same size, thus initially revealing the possibility of weights entering a pruned state. During training, the gradient of the soft thresholding function is modified so that pruned weights can obtain non-zero gradients, avoiding gradient vanishing and the resulting decrease in network expressive power. By controlling the rate of weight sparsity at different stages of training through a threshold growth function, a balance can be achieved between the goals of learning and sparsity. The resulting network can directly discard hidden parameters and use sparse weights for inference to save hardware computational resources, and is applicable to various gradient-based spiking neural networks.

[0078] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0079] According to another aspect of the present invention, a pruning apparatus for a spiking neural network for implementing the above-described pruning method for a spiking neural network is also provided. For example... Figure 7 As shown, the device includes:

[0080] Initialization unit 702 is used to initialize the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein, the synaptic connection layer is located in the spiking neural network model to be pruned, optimized and retrained;

[0081] The first calculation unit 704 is used to substitute each element of the hidden parameter vector into a soft threshold function to obtain a weight vector.

[0082] The second computing unit 706 is used to input training data into the spiking neural network model and calculate the loss function value corresponding to each task type; wherein, the training data includes visual information, and the task type includes classification, detection and tracking of target objects contained in the visual information;

[0083] The third calculation unit 708 is used to calculate the gradient of each loss function value with respect to the hidden parameter vector through a predefined derivative function when the spiking neural network is pruned and trained using an algorithm based on backpropagation; wherein the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function;

[0084] The gradient update unit 710 is used to perform gradient descent update on the gradient of the hidden parameter vector, and to calculate the target threshold used when performing the soft threshold function for the next gradient update using a preset incrementing function.

[0085] Mapping unit 712 is used to map the hidden parameter vector to the weight vector again based on the target threshold and using the soft thresholding function;

[0086] The determining unit 714 is used to delete the hidden parameter vector when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, so as to obtain the pruned spiking neural network model.

[0087] In this embodiment of the invention, a method is employed that obtains the distinguishing identifier information corresponding to the page to be displayed on the current client; retrieves a pop-up configuration resource file matching the distinguishing identifier information from a pop-up resource database; renders the pop-up to be displayed according to the pop-up configuration resource file to obtain a target pop-up; and displays the target pop-up on the page to be displayed. In this method, since the pop-up configuration resource file matching the distinguishing identifier information is retrieved from the pop-up resource database, and the pop-up to be displayed is rendered according to the pop-up configuration resource file to obtain the target pop-up, there is no need to develop pop-ups with different display styles separately. This improves the development efficiency of web applications, reduces application maintenance costs, and thus solves the technical problems of low development efficiency and high maintenance costs in related technologies.

[0088] In one or more embodiments, the pruning device for the spiking neural network further includes:

[0089] The first acquisition unit is used to input the target visual information into the pruned and trained spiking neural network model to obtain the visual information processing result corresponding to the current task type.

[0090] In one or more embodiments, the target visual information includes at least one of images, videos, and pulse signals, and the first acquisition unit includes at least one of the following:

[0091] The first acquisition module is used to input the visual information into a pruned and trained spiking neural network model for classification operations, and obtain the classification processing result of the target visual information.

[0092] The second acquisition module is used to input the visual information into the pruned and trained spiking neural network model to perform target detection operations and acquire the detection results of the target object in the visual information.

[0093] The third acquisition module is used to input the visual information into the pruned and trained spiking neural network model to perform target tracking operations and obtain the tracking processing results of the target object in the visual information.

[0094] In one or more embodiments, the synaptic connection layer includes a fully connected layer and a convolutional layer; the initialization unit 702 includes:

[0095] The fusion module is used to fuse the trainable connection weights in the fully connected layer and the convolutional layer into an initial vector w;

[0096] A replacement module is used to replace w with a hidden parameter vector θ that has the same number of elements as w;

[0097] The first computing unit 704 includes:

[0098] The first calculation module is used to substitute each element in θ into the soft threshold function S. d Obtain the weight vector S d (θ); where θ is the hidden parameter vector and d is the threshold parameter;

[0099] S d (x) = sign(x)·(|x|-d) + d≥0, sign(x) is the sign function;

[0100]

[0101] In one or more embodiments, the predefined derivative function includes: S d The derivative of (x) with respect to x is always equal to 1.

[0102] In one or more embodiments, the pruning device for the spiking neural network further includes:

[0103] The second acquisition unit is used to acquire the d through at least one of formulas (1), (2), and (3) during the training process of pruning the spiking neural network:

[0104] d = kx, x∈[0,1], k>0; (1)

[0105]

[0106]

[0107] Where x represents the pruning training progress. Where n is the current gradient update step of the hidden parameter vector, N is the cumulative gradient update step during the pruning training process, and k is the final value of d at the end of the pruning training.

[0108] In one or more embodiments, the number of pruning training rounds of the spiking neural network model reaching a preset number of rounds includes: the number of gradient updates of the hidden parameter vectors reaching a preset number of rounds.

[0109] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described pruning method for a spiking neural network is also provided. This electronic device may be... Figure 1 The terminal device or server shown. This embodiment uses the electronic device as a server as an example for illustration. Figure 8 As shown, the electronic device includes a memory 802 and a processor 804. The memory 802 stores a computer program, and the processor 804 is configured to execute the steps in any of the above method embodiments via the computer program.

[0110] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.

[0111] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0112] S1, initialize the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein, the synaptic connection layer is located in the spiking neural network model to be pruned, optimized and retrained;

[0113] S2, Substitute each element of the hidden parameter vector into the soft threshold function to obtain the weight vector;

[0114] S3, input the training data into the spiking neural network model and calculate the loss function value corresponding to each task type; wherein, the training data includes visual information, and the task type includes classification, detection and tracking of target objects contained in the visual information;

[0115] S4, when the spiking neural network is pruned and trained using the backpropagation algorithm, the gradient of each loss function value with respect to the hidden parameter vector is calculated using a predefined derivative function; wherein, the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function;

[0116] S5, perform gradient descent to update the gradient of the hidden parameter vector, and use a preset incrementing function to calculate the target threshold used when performing another gradient update using the soft threshold function.

[0117] S6, Based on the target threshold, the hidden parameter vector is mapped to the weight vector again using the soft threshold function;

[0118] S7. When the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, the hidden parameter vector is deleted to obtain the pruned spiking neural network model.

[0119] Alternatively, as those skilled in the art will understand, Figure 8 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 8 This does not limit the structure of the aforementioned electronic devices or electronic equipment. For example, electronic devices or electronic equipment may also include components that are more... Figure 8 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 8 The different configurations shown.

[0120] The memory 802 can be used to store software programs and modules, such as the program instructions / modules corresponding to the spiking neural network pruning method and apparatus in this embodiment. The processor 804 executes various functional applications and data processing by running the software programs and modules stored in the memory 802, thereby implementing the aforementioned spiking neural network pruning method. The memory 802 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 802 may further include memory remotely located relative to the processor 804, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 802 may be used, but is not limited to, to store weight vectors and visual information. As an example, such as... Figure 8 As shown, the memory 802 may include, but is not limited to, the initialization unit 702, the first calculation unit 704, the second calculation unit 706, the third calculation unit 708, the gradient update unit 710, the mapping unit 712, and the determination unit 714 in the pruning device for the spiking neural network described above. Furthermore, it may include, but is not limited to, other module units in the pruning device for the spiking neural network described above, which will not be elaborated upon in this example.

[0121] Optionally, the transmission device 806 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 806 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 806 is a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0122] In addition, the aforementioned electronic device also includes: a display 808 for displaying weight vectors and visual information; and a connection bus 810 for connecting various module components in the aforementioned electronic device.

[0123] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this peer-to-peer network.

[0124] In one or more embodiments, this application also provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described pruning method for a spiking neural network. The computer program is configured to execute the steps of any of the above method embodiments at runtime.

[0125] Optionally, in this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the following steps:

[0126] S1, initialize the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same elements as the initial vector; wherein, the synaptic connection layer is located in the spiking neural network model to be pruned, optimized and retrained;

[0127] S2, Substitute each element of the hidden parameter vector into the soft threshold function to obtain the weight vector;

[0128] S3, input the training data into the spiking neural network model and calculate the loss function value corresponding to each task type; wherein, the training data includes visual information, and the task type includes classification, detection and tracking of target objects contained in the visual information;

[0129] S4, when the spiking neural network is pruned and trained using the backpropagation algorithm, the gradient of each loss function value with respect to the hidden parameter vector is calculated using a predefined derivative function; wherein, the predefined derivative function is a derivative function obtained by modifying the derivative function of the soft thresholding function;

[0130] S5, perform gradient descent to update the gradient of the hidden parameter vector, and use a preset incrementing function to calculate the target threshold used when performing another gradient update using the soft threshold function.

[0131] S6, Based on the target threshold, the hidden parameter vector is mapped to the weight vector again using the soft threshold function;

[0132] S7. When the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, the hidden parameter vector is deleted to obtain the pruned spiking neural network model.

[0133] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0134] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0135] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention.

[0136] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0137] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or the indirect coupling or communication connection of units or modules may be electrical or other forms.

[0138] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0139] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0140] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A pruning method for a spiking neural network, characterized in that, include: The initial vector composed of each connection weight in the synaptic connection layer is initialized to obtain a hidden parameter vector with the same number of elements as the initial vector; wherein, the synaptic connection layer is located in the spiking neural network model to be pruned, optimized and retrained; Substitute each element of the hidden parameter vector into the soft thresholding function to obtain the weight vector; The training data is input into the spiking neural network model, and the loss function value corresponding to each task type is calculated; wherein, the training data includes visual information, and the task type includes classification, detection, and tracking of target objects contained in the visual information; the visual information includes images and videos; When the spiking neural network is pruned and trained using an algorithm based on backpropagation, the gradient of each loss function value with respect to the hidden parameter vector is calculated using a predefined derivative function; wherein, the predefined derivative function is a derivative function with respect to the soft threshold function that is always equal to 1; The gradient of the hidden parameter vector is updated by gradient descent, and the target threshold used for the next gradient update is calculated using a preset incrementing function to calculate the soft threshold function. Based on the target threshold, the hidden parameter vector is mapped to the weight vector again using the soft threshold function; When the number of pruning training rounds of the spiking neural network model reaches a preset number, the hidden parameter vector is deleted to obtain the pruned and trained spiking neural network model.

2. The method according to claim 1, characterized in that, The method further includes: The target visual information is input into the pruned and trained spiking neural network model to obtain the visual information processing result corresponding to the current task type.

3. The method according to claim 2, characterized in that, The target visual information includes at least one of images, videos, and pulse signals. The step of inputting the target visual information into the trained spiking neural network model to obtain visual information processing results corresponding to the current task type includes at least one of the following: The visual information is input into a pruned and trained spiking neural network model for classification to obtain the classification result of the target visual information. The visual information is input into the pruned and trained spiking neural network model to perform target detection, and the detection result of the target object in the visual information is obtained. The visual information is input into the pruned and trained spiking neural network model to perform target tracking, and the tracking result of the target object in the visual information is obtained.

4. The method according to claim 1, characterized in that, The synaptic connection layer includes fully connected layers and convolutional layers; the initialization operation, which initializes the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same number of elements as the initial vector, includes: The trainable connection weights in the fully connected layer and the convolutional layer are fused into an initial vector. ; The hidden parameter vector has the same number of elements as w. Replace the ; The step of substituting each element of the hidden parameter vector into the soft thresholding function to obtain the weight vector includes: The Substitute each element into the soft threshold function Obtain the weight vector ;in, d is the hidden parameter vector, and d is the threshold parameter.

5. The method according to claim 4, characterized in that, The predefined derivative functions include: right The derivative of is always equal to 1.

6. The method according to claim 4, characterized in that, During the pruning training of the spiking neural network, d is obtained through at least one of formulas (1), (2), and (3): ;(1) ;(2) (3); Where x represents the pruning training progress. , where n is the current gradient update step of the hidden parameter vector, N is the cumulative gradient update step during the pruning training process, and k is the final value of d at the end of the pruning training.

7. The method according to claim 1, characterized in that, The step of pruning the spiking neural network model to reach a preset number of training rounds includes: The gradient update of the hidden parameter vector is performed for a preset number of rounds.

8. A pruning device for a spiking neural network, characterized in that, include: An initialization unit is used to initialize the initial vector composed of each connection weight in the synaptic connection layer to obtain a hidden parameter vector with the same number of elements as the initial vector; wherein, the synaptic connection layer is located in the spiking neural network model to be pruned, optimized and retrained; The first calculation unit is used to substitute each element of the hidden parameter vector into the soft threshold function to obtain the weight vector; The second computing unit is used to input training data into the spiking neural network model and calculate the loss function value corresponding to each task type; wherein, the training data includes visual information, and the task type includes classification, detection, and tracking of target objects contained in the visual information; the visual information includes images and videos; The third calculation unit is used to calculate the gradient of each loss function value with respect to the hidden parameter vector through a predefined derivative function when the spiking neural network is pruned and trained using an algorithm based on backpropagation; wherein the predefined derivative function is a derivative function with respect to the soft threshold function that is always equal to 1. The gradient update unit is used to perform gradient descent update on the gradient of the hidden parameter vector, and to calculate the target threshold used when performing the soft threshold function for the next gradient update using a preset incrementing function. A mapping unit is used to map the hidden parameter vector to the weight vector again based on the target threshold using the soft threshold function; The determining unit is used to delete the hidden parameter vector when the number of pruning training rounds of the spiking neural network model reaches a preset number of rounds, so as to obtain the pruned spiking neural network model.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 through the computer program.

Citation Information

Patent Citations

  • Water supply pipe leakage edge equipment detection method based on time convolutional neural network

    CN112949817A

  • Water supply pipe leakage edge equipment detection method and system applied to smart park

    CN113723210A