Bioelectric signal detection method and device and four-valued pulse neural network accelerator
By designing a quaternary spiking neural network, the calculation process is simplified by utilizing weight operations, which solves the problem of low computational efficiency in multi-valued neural networks and enables efficient and low-power bioelectric signal detection.
Patent Information
- Application Number
- CN202511749159.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-01-23
AI Technical Summary
Existing binary neuron-based spiking neural networks fail to fully reproduce the inherent hierarchical response and coding diversity when simulating bioelectrical signals, resulting in low recognition accuracy. Furthermore, multi-valued neuron spiking networks require additional multipliers or adders during computation, leading to reduced processing efficiency.
A quaternary spiking neural network is used. The peak signal of the bioelectric signal is used as the output pulse of the 0th layer neuron of the quaternary spiking neural network. During the weighted summation process, operations such as resetting the weight to zero, keeping the weight unchanged, shifting the weight to the left by 1 bit, and shifting the weight to the left by 2 bits are used to implement the weighting process using a shifter, thus avoiding the need for additional multipliers or adders.
It improves the accuracy and computational efficiency of bioelectric signal detection, reduces the power consumption and component footprint of the quaternary pulse neural network accelerator, and enhances the real-time processing capability and battery life of wearable devices.
Smart Images

Figure CN121370176A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of signal processing, in particular to a biological electrical signal detection method, device and four-value pulse neural network accelerator. BACKGROUND
[0002] Biological electrical signals are potential changes generated by cells or tissues in the body, and are ubiquitous in the physiological activities of all living beings. Biological electrical signals have broad application prospects in the prior art. For example, obtaining the electroencephalogram of a target human body can realize real-time monitoring of the discharge condition of the cerebral cortex of the target human body, thereby realizing the identification of pathology; or reading the electroencephalogram through a brain-computer interface to control the corresponding electronic device.
[0003] The current mainstream electroencephalogram recognition algorithm generally uses a pulse neural network based on binary neurons to perform information transmission using sparse pulse events, thereby significantly reducing the redundant calculation overhead. However, the pulse neural network based on binary neurons only simulates the biological neurons at a shallow level in terms of the discreteness of pulse firing, and fails to fully reproduce the internal hierarchical response and coding diversity, resulting in a low recognition accuracy of biological electrical signals. In order to improve the above problem, the pulse network of binary neurons can be improved to a pulse network of multi-value neurons (such as ternary or quaternary), which represents the "firing intensity" or "firing frequency level" through multi-value pulses, i.e., more information is transmitted in a single time step.
[0004] However, in the pulse network of multi-value neurons, different firing intensities will result in different pulse rates transmitted to the next neuron, and additional multipliers or multiplication circuits are usually required in the actual calculation process, resulting in a serious reduction in processing efficiency. SUMMARY
[0005] Therefore, it is necessary to provide a biological electrical signal detection method, device and four-value pulse neural network accelerator to solve the above problems while ensuring the signal processing efficiency and the accuracy of signal detection.
[0006] The present application provides a biological electrical signal detection method, which comprises: obtaining a spike signal of a biological electrical signal and determining the spike signal of the biological electrical signal as an output pulse of a 0th layer neuron of a four-value pulse neural network; the four-value pulse neural network comprises k layers of neurons; performing weighted summation on the output pulse of the (n-1) th layer neuron based on the weight of the nth layer neuron to update the potential value of the nth layer neuron; k > n > 1, and n is an integer; determine an output pulse of the n-th layer neuron according to the updated potential value of the n-th layer neuron; the output pulse of the n-th layer neuron is a four-value pulse value; the four-value pulse value is used to indicate a weight operation performed during the weighted summation; the weight operation includes one of weight zeroing, weight invariance, weight left shifting by one bit, and weight left shifting by two bits; obtain a detection result of the bioelectric signal according to the output pulse of the neuron of the k-th layer.
[0007] In an optional implementation, the weighted summation of the output pulse of the (n-1)-th layer neuron based on the weight of the n-th layer neuron to update the potential value of the n-th layer neuron includes: obtain a first potential value of the n-th layer neuron at a first time point; obtain a first transmission value by performing the weighted summation of the output pulse of the (n-1)-th layer neuron at a second time point based on the weight of the n-th layer neuron; the second time point is a next time point of the first time point; obtain a first attenuation value of the n-th layer neuron at the first time point; update the first potential value of the n-th layer neuron at the first time point according to the first attenuation value and the first transmission value, and obtain a second potential value of the n-th layer neuron at the second time point.
[0008] In an optional implementation, the weighted summation of the output pulse of the (n-1)-th layer neuron at the second time point based on the weight of the n-th layer neuron to obtain the first transmission value includes: when the weight operation is weight zeroing, determine the first transmission value as 0; when the weight operation is weight invariance, determine the weight of the n-th layer neuron as the first transmission value; when the weight operation is weight left shifting by one bit, determine the first transmission value by shifting the weight of the n-th layer neuron left by one bit through a shifter; when the weight operation is weight left shifting by two bits, determine the first transmission value by shifting the weight of the n-th layer neuron left by two bits through the shifter.
[0009] In an optional implementation, the determination of the output pulse of the n-th layer neuron according to the updated potential value of the n-th layer neuron includes: if the potential value of the n-th layer neuron is less than or equal to a first threshold value, determine the output pulse of the n-th layer neuron as 0, and the weight operation corresponding to the output pulse is weight zeroing; if the potential value of the n-th layer neuron is greater than the first threshold value and less than or equal to a second threshold value, determine the output pulse of the n-th layer neuron as 1; the weight operation corresponding to the output pulse is weight invariance; if the potential value of the nth layer neuron is greater than the second threshold value and less than or equal to the third threshold value, it is determined that the output pulse of the nth layer neuron is 2; the weight operation corresponding to the output pulse is weight left shift one bit; if the potential value of the nth layer neuron is greater than the third threshold value, it is determined that the output pulse of the nth layer neuron is 4; the weight operation corresponding to the output pulse is weight left shift two bits.
[0010] In an optional implementation, the method further comprises: obtaining two continuous sampling points of the bioelectric signal; generating the spike signal according to a local oscillation feature, a large amplitude feature and a signal change feature between the two continuous sampling points of the bioelectric signal; The local oscillation feature is used to indicate the signal oscillation between the two continuous sampling points of the bioelectric signal; the large amplitude feature is used to indicate whether there is a large amplitude event in the two continuous sampling points of the bioelectric signal; and the signal change feature is used to indicate the amplitude change between the two continuous sampling points of the bioelectric signal.
[0011] In an optional implementation, the method further comprises: performing logical exclusive or processing on the two continuous sampling points of the bioelectric signal to obtain the local oscillation feature of the two continuous sampling points of the bioelectric signal.
[0012] In an optional implementation, the method further comprises: For each bioelectric signal, if the absolute value of the level of the sampling point is greater than an amplitude threshold value, the large amplitude feature corresponding to the sampling point is determined as 1.
[0013] In an optional implementation, the method further comprises: if the absolute difference between the two continuous sampling points of the bioelectric signal is greater than a change threshold value, the signal change feature of the two continuous sampling points of the bioelectric signal is determined as 1.
[0014] In an optional implementation, the method further comprises: obtaining a label value corresponding to the bioelectric signal; obtaining a loss function value based on the label value of the bioelectric signal and the detection result; updating the weight of the k-layer neuron in the four-value pulse neural network through a back propagation algorithm according to the loss function value; In the process of updating the weight of the nth layer neuron by the back propagation algorithm, the gradient of the loss function value and the potential value is obtained according to the substitute pulse function. In the alternative pulse function, if the potential value is less than or equal to the average of the first threshold value and the second threshold value, the alternative pulse function value is inversely related to a first difference value, and the maximum value is the first intensity and the minimum value is 0; the first difference value is the difference between the potential value and the first threshold value; If the potential value is greater than the average of the first threshold value and the second threshold value, and less than or equal to the average of the second threshold value and the third threshold value, the alternative pulse function value is inversely related to a second difference value, and the maximum value is the second intensity; the second difference value is the difference between the potential value and the second threshold value; If the potential value is greater than the average of the second threshold value and the third threshold value, the alternative pulse function value is inversely related to a third difference value, and the maximum value is the second intensity; the second difference value is the difference between the potential value and the third threshold value.
[0015] The application also provides a biological electric signal detection device, the device comprising: A signal acquisition module is configured to acquire a biological electric signal and determine a spike signal of the biological electric signal as an output pulse of a 0th layer neuron of a four-value pulse neural network; the four-value pulse neural network comprises k layers of neurons; A potential calculation module is configured to perform weighted summation on output pulses of an (n-1)th layer of neurons based on weights of nth layer of neurons to update a potential value of the nth layer of neurons; k≥n≥1, and n is an integer; A pulse determination module is configured to determine an output pulse of the nth layer of neurons according to the updated potential value of the nth layer of neurons; the output pulse of the nth layer of neurons is a four-value pulse value; the four-value pulse value is used to indicate a weight operation performed during the weighted summation; the weight operation comprises one of weight zeroing, weight invariance, weight left shifting by one bit, and weight left shifting by two bits; A result acquisition module is configured to acquire a detection result of the biological electric signal according to output pulses of the kth layer of neurons.
[0016] The application also provides a four-value pulse neural network accelerator, which comprises a pulse neuron processing unit, a pulse neural network controller, a data scheduler, and on-chip storage; The data scheduler is configured to acquire a biological electric signal and pulse neural network parameters from the on-chip storage; The pulse neural network controller is configured to schedule data between the pulse neuron processing unit and the on-chip storage; The pulse neuron processing unit is configured to perform the above method.
[0017] In an optional implementation, the pulse neuron processing unit comprises an encoding unit, an accumulation module, a four-value pulse activation unit, a pulse inhibition unit, and a register cluster. The encoding unit is used to convert the received bioelectric signal into a spike signal; The accumulation module is used to perform weighted summation on the input pulses; The four-valued pulse activation unit is used to add the weighted sum of the neuronal pulse input to the neuron's potential value, and to divide the neuron's potential value into four-valued pulse values through a comparator. The register cluster includes multiple sets of registers, each set of registers stores pulse data collected over a specified time period, and when all data in the register is 0, the four-value pulse activation unit is instructed to skip the weighted summation operation; The pulse suppression unit is used to perform spike time step counting and disable the register cluster, accumulation module and quad pulse activation unit after detecting a spike signal; The encoding unit and the four-value pulse activation unit multiplex the adder and comparator.
[0018] Compared with the prior art, the technical solution provided in this application has the following advantages: After acquiring the bioelectric signal, this application first extracts its peak signal and uses it as the output pulse of the 0th layer neuron of the four-value spiking neural network, which is then input into the four-value spiking neural network. For the nth layer neuron in the k layer of the four-value spiking neural network, it can perform a weighted summation based on its own weight and the output pulse of the previous layer neuron to update its own potential value. During the weighted summation process, the output pulse of this application is a four-value pulse value, so that the weight operation performed during the weighted summation is one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, or weight shifted left by 2 bits. In other words, it can be directly implemented through a shifter. Finally, the output pulse of the kth layer neuron can be directly obtained through the decoder to obtain the detection result of the bioelectric signal, thereby completing the bioelectric signal detection process. The above scheme, in the quaternary spiking neural network, sets the weight operation corresponding to the quaternary spiking value to one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, and weight shifted left by 2 bits. This allows the weighting process to be implemented with only a shifter. While achieving weight multiplication, it avoids introducing additional adders or multipliers, which greatly improves the computational efficiency in the training and application of the quaternary spiking neural network. It also reduces the power consumption of the quaternary spiking neural network accelerator and the area occupied by the components.
[0019] In addition, when extracting the spike signal, the biological electrical signal is fused and encoded by using the encoding unit, that is, whether rapid change occurs between two continuous sampling points of the biological electrical signal, the change rate, and whether there is a large voltage offset are considered for time domain feature fusion encoding, so that the spike signal can fully represent the information amount in the biological electrical signal, which improves the coding efficiency of the pulse and the processing accuracy of the coded pulse. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 An architecture schematic diagram of a four-value pulse neural network accelerator provided by an embodiment of the present application is shown.
[0021] FIG. 2 shows a structure flowchart of a register cluster in an embodiment of the present application.
[0022] Figure 3 A flowchart of a biological electrical signal detection method in an embodiment of the present application is shown.
[0023] Figure 4 A method flowchart of a biological electrical signal detection method in an embodiment of the present application is shown.
[0024] Figure 5 An encoding method schematic diagram of a biological electrical signal related by an embodiment of the present application is shown.
[0025] Figure 6 A structure schematic diagram of a biological electrical signal detection device provided by an embodiment of the present application is shown.
[0026] Figure 7 A structure schematic diagram of an electronic device provided by an optional embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings. In the following description, a large number of specific details are set forth in order to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without departing from the scope of the present application, so the present application is not limited to the specific embodiments disclosed below.
[0028] Biological electrical signals are potential changes generated by cells or tissues in the body, which exist universally in the physiological activities of all living beings. Biological electrical signals have become one of the core technologies in the fields of medicine, neuroscience, intelligent wearable devices, brain-computer interfaces, etc.
[0029] For example, in the medical field, epilepsy is a neurological disease caused by abnormal discharge of neurons in the brain. Electroencephalography (EEG), as a core technology for monitoring brain activity, collects weak electrical signals generated by the synchronous discharge of neuronal groups by placing an electrode array on the scalp. With its advantages such as non-invasiveness, millisecond-level time resolution, and low detection cost, it plays a key role in the diagnosis and seizure monitoring of epilepsy.
[0030] For example, in the field of brain-computer interfaces, brain-computer interfaces can acquire electroencephalograms (EEGs). By analyzing the EEGs, computer devices can achieve functions such as assisted communication (e.g., users can directly input text and generate images through brain signals) and motion control (e.g., users can control robotic arms or wheelchairs directly with their brains).
[0031] However, in applications such as smart wearable devices, brain-computer interfaces, and continuous monitoring of epilepsy patients in medicine, existing wearable devices face challenges including bulkiness, insufficient real-time processing capabilities, and the high energy consumption of neural network models, which can quickly deplete the device's battery and cause thermal safety issues. Therefore, to significantly reduce computational complexity and power consumption and achieve long-term reliable operation, Spiking Neural Networks (SNNs) are employed to process bioelectrical signals. Compared to traditional neural network models that rely on highly dense multiplication and accumulation, SNNs utilize sparse impulse events for information transmission, significantly reducing redundant computational overhead.
[0032] However, current mainstream SNN models generally use binary neurons (i.e., only "fires" (1) or "does not fire" (0) states). While this is beneficial for the simplicity and computational efficiency of hardware implementation, it has significant limitations in the modeling depth of neural coding mechanisms. Therefore, some engineers have tried to use multi-valued neurons to construct SNN models. Multi-valued neurons can be used to characterize different firing intensities, which can better simulate the actual state of human bioelectric signals. However, in the pulse network of multi-valued neurons, different firing intensities will lead to different pulse multipliers transmitted to the next neuron, which requires the intervention of multiplier or adder circuits in the transmission process of neurons. This increases the amount of computation, reduces processing efficiency, and easily leads to a rapid increase in power consumption, making it unsuitable for wearable devices with strict power consumption requirements.
[0033] To address the aforementioned problems, this application provides a quaternary spiking neural network accelerator and a quaternary spiking neural network operating on the quaternary spiking neural network accelerator. Figure 1 A schematic diagram of the architecture of a four-valued spiking neural network accelerator according to an embodiment of the present invention is shown. Figure 1As shown, the quaternary spiking neural network accelerator includes a spiking neuron processing unit, a spiking neural network controller, a data scheduler, and on-chip memory.
[0034] The data scheduler is used to acquire bioelectrical signals and retrieve spiking neural network parameters from on-chip storage. Specifically, the data scheduler is responsible for reading bioelectrical signals (e.g., EEG data), weights (i.e., synaptic weights), reset voltages, and membrane potential thresholds from on-chip storage via a bus. The synaptic weights and membrane potential thresholds are stored in designated memory locations, while the raw EEG data is directly forwarded by the spiking neural network controller to the spiking neuron processing unit for encoding.
[0035] The spiking neural network controller is used to schedule the data between the spiking neuron processing unit and the on-chip storage. Specifically, after encoding, the spiking sequence is written back to a designated memory location on the on-chip storage by the spiking neural network controller for subsequent calculations.
[0036] On-chip memory, as the main storage medium, stores the intermediate and final states of the pulse, synaptic weights and biases, membrane potential thresholds, and reset voltages.
[0037] like Figure 1 As shown, the quaternary spiking neural network accelerator also includes a main controller, which consists of a finite state machine (FSM), a state register, and a decoder. The main controller is responsible for coordinating the entire hardware computing process, scheduling operations, and ensuring that instructions are executed correctly throughout the system.
[0038] Figure 1 The spiking neuron processing unit in the quaternary spiking neural network is the specific hardware implementation device. It can perform inference of the quaternary spiking neural network, thereby processing bioelectrical signals.
[0039] Specifically, such as Figure 1 As shown, the spiking neuron processing unit includes an encoding unit, an accumulation module, a four-value spiking activation unit, and a register cluster. The encoding unit is used to convert the received bioelectric signal into a spike signal; The accumulation module is used to perform weighted summation on the input pulses; The Quad-Spike Spiking Neural Network (QSNN) is used to add the weighted sum of the neuron's spike input to the neuron's potential value, and then use a comparator to divide the neuron's potential value into four-value spike values. The register cluster includes multiple sets of registers (clusters). Each register cluster stores pulse data collected over a specified time period. When all data in a register cluster is 0, the four-value pulse activation unit is instructed to skip the weighted summation operation.
[0040] Specifically, the encoding unit is used to convert the raw bioelectrical signal (using an 8-bit EEG signal as an example below) into a spike representation. The encoding unit uses two parallel encoding channels, each containing three feature extraction modules: DTE (Difference Threshold Extractor), ZCE (Zero-Crossing Event Detector), and ATE (Amplitude Threshold Extractor).
[0041] To reduce hardware overhead, the DTE module shares computing resources with the QSNN unit, reusing its adder and comparator circuits for computation. And perform a threshold comparison, where, This represents the voltage value obtained by sampling the bioelectric signal at time i+1. Let be the voltage value obtained by sampling the bioelectric signal at time i. The ZCE module used to detect polarity reversal employs an efficient design, requiring only a single XOR (or NOT) gate to be applied to the sign bit of consecutive samples.
[0042] In the ATE module, the amplitude threshold is set to 127. Specifically, the module outputs a binary '1' when the absolute value of the input sample |x| ≥ 127; otherwise, it outputs '0'. Since the input data uses 8-bit two's complement signed format, the condition |x| ≥ 127 is only true when |x| = -128, |x| = -127, or |x| = 127. To avoid explicitly calculating the absolute value and reduce hardware complexity, the ATE module uses comparison-based logic, generating the final binary output by checking if |x| is equal to -128, -127, or 127. The results of each comparison are combined using a logical OR operation to ultimately form the binary output signal.
[0043] Subsequently, the binary outputs of the DTE, ZCE, and ATE modules are expanded to a 2-bit representation by adding '0's after the most significant bit. These scaled outputs are then element-wise added to generate the final 2-bit pulse signal, achieving efficient fusion of complementary time and amplitude characteristics. The encoded pulse sequence is written back to memory, preparing it for the next inference stage.
[0044] Specifically, the accumulator unit performs a weighted summation of the pulse inputs within a given time step. Before computation, the neuron retrieves the required synaptic weights for the current layer from memory and stores them in the weight register. These weights then undergo two consecutive 1-bit left shift operations: the first left shift generates double the weight (2×weight); the second left shift generates quadruple the weight (4×weight). (The design principle of the weight operation can be found in...) Figure 3 As shown in the embodiment, the generated weights are finally stored in dedicated registers.
[0045] Optionally, before starting the accumulation process, the accumulator unit will first check the all-zero flag of the current time step. If the flag is '0', it indicates that all input pulses are zero. In this case, the unit will skip the calculation process and directly output a zero pulse, thereby avoiding redundant operations and reducing the amount of computation. Otherwise, if the flag is '1', a weighted accumulation operation will be performed. During the data accumulation phase, the system sequentially reads two-bit pulse signals from the pulse register. Each pulse is first processed by a two-bit bitwise OR operation. If the result is '0' (i.e., the pulse value is 0), the corresponding synaptic contribution is zero. In this case, the neuron skips the subsequent processing of that pulse and directly proceeds to the processing of the next input signal. Through this perceptual skipping mechanism, the inherent temporal sparsity of neural activity is cleverly utilized, which improves computational efficiency and reduces energy consumption.
[0046] Furthermore, when a non-zero pulse signal is detected, its value is used as the selection signal for the multiplexer group to determine the scaled weighted output: a pulse value of 1 selects the original weight register output, a value of 2 selects the double weight register output, and a value of 3 selects the quaternary weight register output. This multiplexer scheme efficiently implements scalable synaptic multiplication operations without the need for an arithmetic multiplier, significantly reducing hardware complexity and eliminating the need for runtime multiplication operations. The selected weighted values are then accumulated in the accumulator register. This process continues until all spikes within the current time step have been processed. Finally, the accumulated result is passed to the QSNN unit to trigger spike activation and threshold determination, thereby updating the neuron state.
[0047] Specifically, after receiving the weighted, accumulated neuronal pulse input and synaptic weights, the four-valued pulse activation unit adds it to the residual membrane potential retained from the previous time step. Then, a two-stage comparison process using only two comparators classifies the generated membrane potential into four different levels, thus forming a four-valued pulse.
[0048] This quaternary pulse activation unit can also generate a 2-bit output spike representing the discharge intensity by decoding the comparison result. When a spike is generated, the membrane potential decreases according to a specific reset voltage level. Since each voltage level corresponds to a different reset value, the system uses a multiplexer (MUX) to select an appropriate reset voltage based on the generated spike pattern. The remaining membrane potential after reset is stored in a dedicated register and retained in subsequent time steps, where it will be updated through a new round of weighted spike accumulation.
[0049] Specifically, such as Figure 2 As shown, the register cluster employs four register clusters, each corresponding to a tightly coupled SNPU (Spiking Neural Processing Unit), which can provide both input data and output sparsity metrics, thereby achieving efficient computation. Furthermore, each register cluster can also contain four sets of pulse registers, each consisting of sixteen 2-bit registers, specifically used to buffer the time-step pulse input required for weighted pulse accumulation operations, significantly improving memory access efficiency.
[0050] For each register family containing four pulse registers, during inference, the pulse calculation unit sequentially reads the data of the Nth time step from the current pulse register and performs the required calculations. After completing the current step, the system automatically switches to the (N+1)th register to obtain the data for the next time step. When N exceeds 4, the system uses a modulo-4 loop mechanism to switch to the (N-3)th register. Simultaneously, the memory controller prefetches the pulse data of the (N+4)th time step from memory and overwrites the longest-used register group, thus constructing a four-stage pipeline structure. If the 16 2-bit registers in the register are bitwise ORed before weighted pulse accumulation, and the all-zero flag is detected as 0 (indicating no active pulse in the current time step), then the following is generated: Figure 2 The all-zero indicator signal shown indicates that the SNPU should skip weighted memory access and accumulation operations, dynamically saving computational resources. This design effectively hides memory access latency through register round-robin and data prefetching, avoiding computational idleness under sparse input conditions.
[0051] Optionally, in this embodiment, the spiking neuron processing unit further includes a spiking suppression unit. The suppression unit is responsible for performing spike time step counting and monitoring neuronal activity within a suppression window of n time steps. If no spike signal is detected during this period, the unit activates the register cluster, the accumulation module, and the QSNN unit, allowing subsequent time step calculations to continue based on the spike signal. Conversely, once a spike signal is detected, the suppression unit immediately disables the aforementioned components, thereby terminating subsequent calculations of neurons within the current window and setting all remaining output spikes to zero. This early termination mechanism effectively reduces redundant computation and significantly improves energy efficiency. In convolutional layers requiring average pooling, output spikes are temporarily buffered until the spike outputs of adjacent convolutional kernels are available. Subsequently, the spike sequence is jointly processed by the average pooling module, and the final generated pooling value is written back to memory. This strategy minimizes redundant data transfer between the processing unit and memory, thereby effectively improving overall computational efficiency.
[0052] In providing such Figure 1 Based on the quaternary spiking neural network accelerator shown, this application also provides a quaternary spiking neural network built on the quaternary spiking neural network accelerator, thereby performing, as shown in the example... Figure 3 The method for detecting bioelectrical signals is shown in Figure 3. Figure 3 shows a flowchart of a bioelectrical signal detection method according to an embodiment of the present invention. Figure 3 As shown, the method flow includes: Step 301: Acquire the peak signal of the bioelectric signal and determine the peak signal of the bioelectric signal as the output pulse of the 0th layer neuron of the four-value spiking neural network; the four-value spiking neural network includes k layers of neurons; This application uses EEG signals as an example of bioelectrical signals. After the raw EEG signal is acquired, the data scheduler obtains the raw EEG signal from the data input channel, and then processes it as follows: Figure 1 The DTE, ZCE, and ATE modules in the encoding unit shown extract features from the raw EEG signal to generate a spike signal of the bioelectric signal, which is a 2-bit pulse signal. Then, the spiking neural network controller stores the generated spike signal in a designated location in the on-chip storage and defines it as the output pulse of the neuron in layer 0 for subsequent processing.
[0053] Step 302: Based on the weights of the neurons in the nth layer, perform a weighted summation of the output pulses of the neurons in the (n-1)th layer to update the potential value of the neurons in the nth layer; k≥n≥1, and n is an integer.
[0054] Step 303: Determine the output pulse of the nth layer neuron based on the updated potential value of the nth layer neuron; the output pulse of the nth layer neuron is a four-valued pulse value; the four-valued pulse value is used to indicate the weighting operation performed during weighted summation; the weighting operation includes one of the following: resetting the weight to zero, keeping the weight unchanged, shifting the weight left by 1 bit, and shifting the weight left by two bits; Step 304: Obtain the detection result of the bioelectric signal based on the output pulse of the neurons in the k-th layer.
[0055] In this embodiment, steps 302 to 304 are essentially iterative processes in a spiking neural network, where the output pulse of a neuron in the previous layer is passed to the neuron in the next layer. Specifically, for a neuron in layer 1, it should receive the output pulse of the neuron in the previous layer. However, since there is no neuron in layer 1, it should directly receive the externally input pulse signal. Therefore, in this embodiment, the spike signal is directly defined as the output pulse of the neuron in layer 0.
[0056] At this point, for the neurons in the first layer, they can perform a weighted summation of the output pulses of the neurons in the 0th layer according to their own weights. In other words, the spike signal affects the potential value of the neurons in the first layer according to the weights of the neurons in the first layer, thereby updating the potential value of the neurons in the first layer.
[0057] When the potential value of the first layer of neurons is updated, that is, after it is affected by the spike signal, it may generate a new pulse and transmit it to the second layer of neurons. At this time, it is necessary to determine whether the potential value of the first layer of neurons will generate a pulse after the update, and how large the pulse is.
[0058] Therefore, in this embodiment, the potential value of the first layer of neurons is converted into a four-valued pulse value. Specifically, the four-valued pulse value can be (0, 1, 2, 4). When the potential value of the first layer of neurons is small, such as in the first range, it can be considered that it will not generate a new pulse, and the four-valued pulse value can be determined as 0. When the potential value of the first layer of neurons is slightly larger, such as in the second range, it can be considered that it will generate a new pulse, but the amplitude of the generated pulse is small, and the four-valued pulse value can be determined as 1. When the potential value of the first layer of neurons is larger, such as in the third range, it can be considered that it will generate a new pulse, and the amplitude of the generated pulse is larger, and the four-valued pulse value can be determined as 2. When the potential value of the first layer of neurons is very large, such as in the fourth range, it can be considered that it will generate a new pulse, and the amplitude of the generated pulse is the largest, and the four-valued pulse value can be determined as 4.
[0059] Through the above design, the potential value of the first layer of neurons can be converted into a four-value pulse value. Compared with the existing binary spiking neural network, it can not only show the pulse transmission process of bioelectric signals, but also reflect the intensity of bioelectric signals in the pulse transmission process to a certain extent, thereby distinguishing between mild bioelectric signal stimulation and severe bioelectric signal stimulation.
[0060] Furthermore, in this embodiment, the four-valued pulse values generated by the neurons in the first layer are used to perform a weighted summation with the pulses of the neurons in the second layer, thereby transmitting the potential to the neurons in the second layer. Figure 1 As shown, the weights (synaptic weights) of neurons in each layer are stored in a specific register in binary format.
[0061] Therefore, in this embodiment, the four-valued pulse value is designed as (0, 1, 2, 4), so that when the four-valued pulse value is 0, the weighted sum of the four-valued pulse value and the weight is equivalent to setting it to zero directly, and the corresponding weight operation is to reset the weight to zero; when the four-valued pulse value is 1, the weighted sum of the four-valued pulse value and the weight is still the weight itself; when the four-valued pulse value is 2, the weighted sum of the four-valued pulse value and the weight is equivalent to twice the weight, which can be achieved by shifting left by one bit in binary.
[0062] If we set the maximum value of the quaternary pulse value to 3 according to the growth law of natural numbers, the weighted sum of the quaternary pulse value and the weight is equivalent to three times the weight. This requires a multiplier or adder circuit, which would require additional computing circuitry in wearable devices and would increase the amount of additional computation (because iterative calculations may require multiple multipliers or adders). Therefore, in this embodiment, the maximum value of the quaternary pulse value can be set to 4. The weighted sum of the quaternary pulse value and the weight is equivalent to four times the weight. In binary, this can be achieved directly by shifting left by two bits, which can be done directly by a shifter without the need for additional multiplication circuitry. This greatly improves the computational efficiency in the training and application of the quaternary spiking neural network and also reduces the power consumption and component footprint of the quaternary spiking neural network accelerator.
[0063] Following the logic described above, after the first layer of neurons generates an output pulse in a four-value pulse format, it will pass the output pulse of the first layer of neurons to the second layer of neurons. At this time, the second layer of neurons will then perform a weighted summation of the output pulse of the first layer of neurons based on its own weights to update the potential value of the second layer of neurons.
[0064] Similarly, if there are k layers of neurons in a four-valued spiking neural network, then for each layer of neurons in the k layers, the output pulse of each layer of neurons can be obtained sequentially through the above logic. When the output pulse of the last layer, that is, the k-th layer of neurons, is obtained through iteration, the detection result of the bioelectric signal can be obtained directly based on the output pulse of the k-th layer of neurons.
[0065] Optionally, the four-valued spiking neural network in this embodiment further includes a decoding layer. This decoding layer receives the output pulses of the k-th layer neurons and decodes the output pulses to obtain the detection result of the bioelectrical signal. For example, in the field of epilepsy monitoring, the detection result can be the seizure risk of an epileptic patient or the probability of currently being in a seizure phase; or, for example, in the field of brain-computer interfaces, the detection result can be the command that the user needs to issue, such as controlling a robotic arm to move or turn within a specified range.
[0066] Figure 4 shows a flowchart of a bioelectrical signal detection method according to an embodiment of the present invention, as follows: Figure 4 As shown, the method flow includes: Step 401: Obtain two consecutive sampling points of the bioelectric signal.
[0067] In this embodiment, the electroencephalogram (EEG) signal is used as an example of a bioelectric signal. The original EEG signal is a continuous analog electrical signal that reflects the potential changes generated by the activity of brain neuron groups. It is usually measured in microvolts (µV) and has a frequency range between 0.1 Hz and 100 Hz. In this embodiment, to facilitate subsequent processing, the original EEG signal can be sampled at a specified frequency to obtain the level values of two consecutive sampling points of the bioelectric signal.
[0068] Step 402: Generate the spike signal based on the local oscillation characteristics, large amplitude characteristics, and signal change characteristics between two consecutive sampling points of the bioelectric signal.
[0069] In this embodiment, the local oscillation feature is used to indicate the signal oscillation between two consecutive sampling points of the bioelectrical signal; the large amplitude feature is used to indicate whether there is a large amplitude event within two consecutive sampling points of the bioelectrical signal; and the signal change feature is used to indicate the amplitude change between two consecutive sampling points of the bioelectrical signal. In other words, the spike signal is obtained by time-domain feature fusion encoding considering whether rapid changes occur between two bioelectrical signals, the magnitude of the rate of change, and whether there is a large voltage shift. Therefore, the spike signal can fully characterize the information content of the bioelectrical signal.
[0070] Figure 5A schematic diagram of a time-domain feature fusion encoding method for bioelectrical signals according to an embodiment of this application is shown. Figure 5 As shown, specifically, in this embodiment of the application, the ZCE module can perform logical XOR processing on two consecutive sampling points of the bioelectric signal to obtain the local oscillation characteristics of the two consecutive sampling points of the bioelectric signal, and its formula is expressed as follows:
[0071] Where Z represents the local oscillation characteristic. For logical XOR operators, Z is used to characterize the positive and negative polarity of the sampling point's level. Z=1 indicates that a zero-crossing event has occurred between the current sampling point (level) and the sampling point (level) at the next moment, meaning that the positive and negative polarity has changed. For example, during an epileptic seizure, this indicator will significantly increase due to the prevalence of high-frequency spike discharges.
[0072] The ATE module can also process each sampling point; if the absolute value of the level at that sampling point is greater than the amplitude threshold... If so, the large amplitude feature corresponding to the sampling point is determined as 1.
[0073] The ATE module passes each input The absolute value and the predefined amplitude threshold Comparison is used to detect large amplitude events, and the output large amplitude features are shown. In binary, its formula is expressed as follows:
[0074] Although the ATE output does not directly calculate the moving average, it reflects the periods of increased signal amplitude within a local window, which are highly correlated with the overall energy level. This module is particularly effective during high-amplitude seizures; for example, the spikes and peaks observed during epileptic seizures often exceed the amplitude threshold, providing strong discriminative ability for seizure onset detection.
[0075] The DTE module can also compare two consecutive sampling points of a bioelectrical signal. If the absolute difference between two consecutive sampling points of the bioelectrical signal is greater than a change threshold, the comparison will be successful. Then, the signal change characteristic D of two consecutive sampling points of the bioelectric signal is defined as 1, and its formula is expressed as follows:
[0076] The above mechanism allows for the capture of temporal sharpness and local signal complexity between bioelectrical signals, enabling responses to rapid voltage fluctuations and the generation of active pulses. During epileptic seizures, paroxysmal discharges typically manifest as potential abrupt changes, leading to a significant increase in DTE activity.
[0077] The outputs of the ZCE, ATE, and DTE modules are encoded into binary and added element-wise to generate a final 2-bit spike representation. This fusion encoding scheme maintains high computational efficiency while providing a rich and discriminative representation of neurophysiological dynamics. It's worth noting that these three modules are built entirely on basic arithmetic and logical operations, including sign detection, absolute value calculation, subtraction, and threshold comparison. By avoiding computationally intensive functions such as exponentiation and multiplication, this design incurs minimal computational overhead and is highly adaptable to hardware implementations. This lightweight, event-driven architecture ensures high efficiency and ultra-low power consumption, making it particularly suitable for real-time detection of users' bioelectrical signals in resource-constrained wearable devices.
[0078] Step 403: Based on the weights of the neurons in the nth layer, perform a weighted summation of the output pulses of the neurons in the (n-1)th layer to update the potential value of the neurons in the nth layer; k≥n≥1, and n is an integer.
[0079] Specifically, in the calculation process of a four-valued spiking neural network, the potential can be updated in the following way: Obtain the first potential value of the nth layer neuron at the first time step; based on the weight of the nth layer neuron, perform a weighted summation of the output pulses of the (n-1)th layer neuron at the second time step to obtain the first transmission value; the second time step is the next time step after the first time step; obtain the first decay value of the nth layer neuron at the first time step; based on the first decay value and the first transmission value, update the first potential value of the nth layer neuron at the first time step to obtain the second potential value of the nth layer neuron at the second time step.
[0080] In simple terms, the first potential value of the nth layer neuron at the first moment represents the potential value (i.e., membrane potential) of the nth layer neuron at time t. It represents the total energy accumulated by the neuron at all historical moments, including all pulse energy received in history, all pulse energy released by itself, and energy that decays naturally over time.
[0081] Therefore, when we need to calculate the potential value of the nth layer neuron at the next moment, we need to consider the current potential value of the nth layer neuron (usually stored in a specific register that can be directly read), the pulse energy transmitted from the (n-1)th layer neuron to the nth layer neuron (that is, the weighted sum of the output pulse of the (n-1)th layer neuron and the weight of the nth layer neuron, i.e., the first transmission value), and the natural decay energy of the nth layer neuron from the current moment to the next moment (i.e., the first decay value).
[0082] Specifically, this process can be described by the following model:
[0083] in, To control the decay factor of the membrane potential over time, This represents the first decay value of neuron j in layer l. This represents the synaptic weight connecting neuron i in layer (l-1) and neuron j in layer l; This represents the four-valued binary pulse output of neuron i in layer (l-1) at time t; It is the reset potential of neuron j in layer l at time t-1; optionally, the decay factor τ can be set to 0.875.
[0084] As can be seen from the above model, after the j-th neuron in layer l generates an action potential, a reset potential will be subtracted from its membrane potential. This represents the transfer of pulse energy to the next layer of neurons; this reset potential It can be determined based on the pulse level emitted by neuron j in layer l at time t-1.
[0085] In the above model, it can be seen that when calculating the current potential value of the neurons in the current layer, the pulse energy transmitted from the (n+1)th layer neuron to the nth layer neuron needs to be considered. Optionally, there may be several neurons in the (n+1)th layer, and similarly, there may be several neurons in the nth layer. In this case, for each target neuron in the (n+1)th layer, the pulse energy transmitted from each neuron in the nth layer to the target neuron needs to be considered. However, in reality, the transmission process between every two neurons is similar, that is, the calculation method for each first transmission value is similar. The specific steps can be broken down as follows: When the weight operation is to reset the weight to zero, the first transfer value is determined to be 0; when the weight operation is to keep the weight unchanged, the weight of the nth layer neuron is used as the first transfer value; when the weight operation is to shift the weight to the left by 1 bit, the weight of the nth layer neuron is shifted to the left by 1 bit through the shifter and then determined as the first transfer value; when the weight operation is to shift the weight to the left by 2 bits, the weight of the nth layer neuron is shifted to the left by 2 bits through the shifter and then determined as the first transfer value.
[0086] In simple terms, for two neurons connected in adjacent layers—specifically, a designated neuron in layer n and a designated neuron in layer n+1—the first step is to obtain the weight of the designated neuron in layer n+1. This weight represents the proportion of pulse energy transferred from the designated neuron in layer n to the designated neuron in layer n+1. Then, based on the potential of the designated neuron in layer n, a corresponding four-valued pulse value is generated. This value is then weighted and summed with the aforementioned weights to obtain the pulse energy (i.e., the first transfer value) transferred from the designated neuron in layer n to the designated neuron in layer n+1. The specific weighting process can be found in [link to relevant documentation]. Figure 3The embodiments shown are not described in detail here.
[0087] Step 404: Determine the output pulse of the nth layer neuron based on the updated potential value of the nth layer neuron; the output pulse of the nth layer neuron is a four-valued pulse value.
[0088] In this embodiment of the application, the four-value pulse value is used to indicate the weighting operation performed during weighted summation; the weighting operation includes one of the following: resetting the weight to zero, keeping the weight unchanged, shifting the weight left by 1 bit, and shifting the weight left by 2 bits.
[0089] Furthermore, if the potential value of the nth layer neuron is less than or equal to the first threshold... If the output pulse of the nth layer neuron is 0, the corresponding weight operation is reset to zero; if the potential value of the nth layer neuron is greater than the first threshold... And less than or equal to the second threshold If the output pulse of the nth layer neuron is 1, then the weight operation corresponding to this output pulse is to keep the weight unchanged; if the potential value of the nth layer neuron is greater than the second threshold... And less than or equal to the third threshold If the output pulse of the nth layer neuron is 2, then the weight operation corresponding to this output pulse is a left shift of the weight by one bit; if the potential value of the nth layer neuron is greater than the third threshold... If so, the output pulse of the nth layer neuron is determined to be 4; the weight operation corresponding to this output pulse is to shift the weight left by two bits.
[0090] Specifically, the membrane level corresponding to neuron j in layer l. The corresponding four-valued pulse value can be generated using the following function. :
[0091] The design principle of this weighting operation can be found in [reference]. Figure 3 The embodiments shown are not described in detail here.
[0092] Step 405: Obtain the detection result of the bioelectric signal based on the output pulse of the neurons in the k-th layer.
[0093] In this embodiment of the application, the four-valued spiking neural network also has a decoding layer, which is used to receive the output pulses of the k-th layer neurons and decode the output pulses to obtain the detection results of bioelectric signals.
[0094] In one alternative implementation, the above steps can be performed during the training process of the quaternary spiking neural network or during the application process of the quaternary spiking neural network. However, regardless of the process, after obtaining the detection results of the bioelectric signal, the parameters in the quaternary spiking neural network can be updated by obtaining the label corresponding to the bioelectric signal.
[0095] Specifically, the update process of this four-valued spiking neural network can be performed using other computer equipment. For example, computer equipment can obtain the tag value corresponding to the bioelectric signal; Based on the label value and detection results of the bioelectric signal, the loss function value is obtained; Based on the loss function value, the weights of the k-layer neurons in the four-valued spiking neural network are updated using the backpropagation algorithm.
[0096] The above training framework is the basic framework of the backpropagation algorithm. However, since the peak signal generated from the bioelectric signal is non-differentiable, and the backpropagation algorithm usually requires calculation based on the gradient, an alternative impulse function needs to be introduced in this embodiment.
[0097] Specifically, during the backpropagation algorithm's update of the weights of neurons in the nth layer, the gradient between the loss function value and the potential value is obtained based on the substitution impulse function; In this alternative pulse function, if the potential value is less than or equal to the first threshold... With the second threshold When the mean value is reached, the substitute pulse function value is inversely correlated with the first difference, with the maximum value being the first intensity and the minimum value being 0; the first difference is the potential value to the first threshold. The difference; If the potential value is greater than the first threshold With the second threshold The mean, and less than or equal to the second threshold. With the third threshold When the mean value is reached, the substitute pulse function value is inversely correlated with the second difference, and the maximum value is the second intensity; the second difference is the potential value to the second threshold. The difference; If the potential value is greater than the second threshold With the third threshold The mean of the substitution pulse function value is inversely correlated with the third difference, and the maximum value is the second intensity; the second difference is the potential value to the third threshold. The difference.
[0098] The above logic can be summarized as follows:
[0099] in, These are preset parameters used to control the slope of the linear segment of the substitute impulse function, while , , These adjustments involve scaling factors on the gradient magnitudes of different regions to balance the contributions of different threshold-driven activation modes and ensure... , , The gradient in the vicinity remains non-zero.
[0100] Since this application requires parameter updates for a four-valued spiking neural network, which has multiple levels of activation intensity, and the alternative pulse function has three thresholds, each corresponding to a local gradient function segment, the sensitivity of different intensity intervals can be distinguished during backpropagation, making the network more sensitive and stable to changes in potential values during gradient propagation; furthermore, the alternative pulse function has a larger gradient near the threshold, which is beneficial for learning key features, and the gradient gradually decreases as it leaves the threshold interval, thereby avoiding gradient diffusion or oscillation.
[0101] In summary, after acquiring the bioelectric signal, this application first extracts its peak signal and uses it as the output pulse of the 0th layer neuron of the quaternary spiking neural network (QSNN) as input to the QSNN. For the nth layer neuron in the k layer of the QSNN, it can perform a weighted summation based on its own weight and the output pulse of the previous layer neuron to update its own potential value. During the weighted summation process, the output pulse of this application is a quaternary pulse value, so that the weight operation performed during the weighted summation is one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, or weight shifted left by 2 bits. That is to say, it can be directly implemented through a shifter. Finally, the output pulse of the kth layer neuron can be directly obtained through the decoder to obtain the detection result of the bioelectric signal, thereby completing the bioelectric signal detection process. The above scheme, in the quaternary spiking neural network, sets the weight operation corresponding to the quaternary spiking value to one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, and weight shifted left by 2 bits. This allows the weighting process to be implemented with only a shifter. While achieving weight multiplication, it avoids introducing additional adders or multipliers, which greatly improves the computational efficiency in the training and application of the quaternary spiking neural network. It also reduces the power consumption of the quaternary spiking neural network accelerator and the area occupied by the components.
[0102] This application also provides a bioelectrical signal detection device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0103] This application provides a bioelectrical signal detection device. Figure 6 This is a schematic diagram of a bioelectrical signal detection device provided in an embodiment of this application. The device includes: The signal acquisition module 601 is used to acquire bioelectric signals and determine the peak signal of the bioelectric signals as the output pulse of the 0th layer neuron of the four-value spiking neural network; the four-value spiking neural network includes k layers of neurons; The potential calculation module 602 is used to perform weighted summation of the output pulses of the (n-1)th layer neurons based on the weights of the nth layer neurons, so as to update the potential value of the nth layer neurons; k≥n≥1, and n is an integer; The pulse determination module 603 is used to determine the output pulse of the nth layer neuron based on the updated potential value of the nth layer neuron; the output pulse of the nth layer neuron is a four-valued pulse value; the four-valued pulse value is used to indicate the weighting operation performed during weighted summation; the weighting operation includes one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, and weight shifted left by two bits; The result acquisition module 604 is used to acquire the detection result of the bioelectric signal based on the output pulse of the neuron in the k-th layer.
[0104] In summary, after acquiring the bioelectric signal, this application first extracts its peak signal and uses it as the output pulse of the 0th layer neuron of the quaternary spiking neural network (QSNN) as input to the QSNN. For the nth layer neuron in the k layer of the QSNN, it can perform a weighted summation based on its own weight and the output pulse of the previous layer neuron to update its own potential value. During the weighted summation process, the output pulse of this application is a quaternary pulse value, so that the weight operation performed during the weighted summation is one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, or weight shifted left by 2 bits. That is to say, it can be directly implemented through a shifter. Finally, the output pulse of the kth layer neuron can be directly obtained through the decoder to obtain the detection result of the bioelectric signal, thereby completing the bioelectric signal detection process. The above scheme, in the quaternary spiking neural network, sets the weight operation corresponding to the quaternary spiking value to one of the following: weight reset to zero, weight unchanged, weight shifted left by 1 bit, and weight shifted left by 2 bits. This allows the weighting process to be implemented with only a shifter. While achieving weight multiplication, it avoids introducing additional adders or multipliers, which greatly improves the computational efficiency in the training and application of the quaternary spiking neural network. It also reduces the power consumption of the quaternary spiking neural network accelerator and the area occupied by the components.
[0105] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of the present invention. The electronic device can be a computer device used to train the four-valued spiking neural network provided in this application, or the electronic device can be loaded with... Figure 1 The quaternary spiking neural network accelerator shown is used to load a quaternary spiking neural network to detect bioelectrical signals.
[0106] like Figure 7 As shown, the electronic device includes one or more processors 10, a memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processor can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces).
[0107] The processor 10 may further include a hardware chip. This hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0108] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0109] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the use of the electronic device based on the display of a mini-program landing page. Furthermore, the memory 20 may include high-speed random access memory (RAM), and may also include non-transient memory, such as at least one disk storage device, flash memory device, or other non-transient solid-state storage device. The memory 20 may include volatile memory, such as RAM; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid-state drive; the memory 20 may also include combinations of the above types of memory.
[0110] The electronic device also includes a communication interface 30 for communicating with other devices or communication networks.
[0111] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0112] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0113] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. A method of detecting a bioelectric signal, characterized by, The method comprises: acquiring a spike signal of a bioelectric signal, and determining the spike signal of the bioelectric signal as an output pulse of a neuron of a 0th layer of a four-value pulse neural network; the four-value pulse neural network comprises k-layer neurons; performing weighted summation on output pulses of an (n-1)th layer of neurons based on weights of an nth layer of neurons to update a potential value of the nth layer of neurons; k≥n≥1, and n is an integer; determining an output pulse of the nth layer of neurons according to the updated potential value of the nth layer of neurons; the output pulse of the nth layer of neurons is a four-value pulse value; the four-value pulse value is used to indicate a weight operation performed during the weighted summation; the weight operation comprises one of weight setting to zero, weight keeping unchanged, weight left shifting by one bit, and weight left shifting by two bits; acquiring a detection result of the bioelectric signal according to the output pulse of the neuron of the kth layer.
2. The method of claim 1, wherein, The performing of the weighted summation on the output pulses of the (n-1)th layer of neurons based on the weights of the nth layer of neurons to update the potential value of the nth layer of neurons comprises: acquiring a first potential value of the nth layer of neurons at a first time; performing weighted summation on output pulses of an (n-1)th layer of neurons at a second time based on weights of an nth layer of neurons to acquire a first transfer value; the second time is a next time of the first time; acquiring a first attenuation value of the nth layer of neurons at the first time; updating the first potential value of the nth layer of neurons at the first time according to the first attenuation value and the first transfer value to acquire a second potential value of the nth layer of neurons at the second time.
3. The method of claim 2, wherein, The performing of the weighted summation on the output pulses of the (n-1)th layer of neurons at the second time based on the weights of the nth layer of neurons to acquire the first transfer value comprises: when the weight operation is weight setting to zero, determining the first transfer value as 0; when the weight operation is weight keeping unchanged, determining the weight of the nth layer of neurons as the first transfer value; when the weight operation is weight left shifting by one bit, determining the weight of the nth layer of neurons as the first transfer value after left shifting by one bit through a shifter; when the weight operation is weight left shifting by two bits, determining the weight of the nth layer of neurons as the first transfer value after left shifting by two bits through the shifter.
4. The method of claim 3, wherein, The determining of the output pulse of the nth layer of neurons according to the updated potential value of the nth layer of neurons comprises: if the potential value of the nth layer of neurons is less than or equal to a first threshold value, determining the output pulse of the nth layer of neurons as 0, and the weight operation corresponding to the output pulse is weight setting to zero; if the potential value of the nth layer of neurons is greater than the first threshold value and less than or equal to a second threshold value, determining the output pulse of the nth layer of neurons as 1, and the weight operation corresponding to the output pulse is weight keeping unchanged; if the potential value of the nth layer of neurons is greater than the second threshold value and less than or equal to a third threshold value, determining the output pulse of the nth layer of neurons as 2, and the weight operation corresponding to the output pulse is weight left shifting by one bit. If the potential value of the nth layer neuron is greater than a third threshold value, it is determined that the output pulse of the nth layer neuron is 4; the weight operation corresponding to the output pulse is that the weight is left shifted by two bits.
5. The method of claim 4, wherein, The method further comprises: acquiring a label value corresponding to the bioelectric signal; based on the label value of the bioelectric signal and the detection result, acquiring a loss function value; updating the weight of the k-layer neuron in the four-value pulse neural network through a back propagation algorithm according to the loss function value; In the process of updating the weight of the nth layer neuron by the back propagation algorithm, the gradient of the loss function value and the potential value is obtained according to the substitute pulse function; In the substitute pulse function, if the potential value is less than or equal to the average of the first threshold value and the second threshold value, the substitute pulse function value is inversely related to the first difference value, and the maximum value is the first intensity and the minimum value is 0; the first difference value is the difference between the potential value and the first threshold value; If the potential value is greater than the average of the first threshold value and the second threshold value, and less than or equal to the average of the second threshold value and the third threshold value, the substitute pulse function value is inversely related to the second difference value, and the maximum value is the second intensity; the second difference value is the difference between the potential value and the second threshold value; If the potential value is greater than the average of the second threshold value and the third threshold value, the substitute pulse function value is inversely related to the third difference value, and the maximum value is the second intensity; the second difference value is the difference between the potential value and the third threshold value.
6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: acquiring the bioelectric signal; acquiring two consecutive sampling points of the bioelectric signal; generating the spike signal according to the local oscillation feature, the large amplitude feature and the signal change feature between the two consecutive sampling points of the bioelectric signal; 7. The method of claim 6, wherein, The local oscillation feature is used to indicate the signal oscillation between the two consecutive sampling points of the bioelectric signal; the large amplitude feature is used to indicate whether there is a large amplitude event in the two consecutive sampling points of the bioelectric signal; and the signal change feature is used to indicate the amplitude change between the two consecutive sampling points of the bioelectric signal. The method further comprises, before generating the spike signal: performing logical exclusive or processing on the sign bits of the two consecutive sampling points of the bioelectric signal to acquire the local oscillation feature of the two consecutive sampling points of the bioelectric signal; for each sampling point, if the absolute value of the level of the sampling point is greater than an amplitude threshold value, the large amplitude feature corresponding to the sampling point is determined as 1; 8. A bioelectric signal detecting apparatus characterized by comprising: if the absolute difference between the sign bits of the two consecutive sampling points of the bioelectric signal is greater than a change threshold value, the signal change feature of the two consecutive sampling points of the bioelectric signal is determined as 1. The device comprises: a signal acquisition module, configured to acquire a bioelectric signal and determine a spike signal of the bioelectric signal as an output pulse of a 0th layer neuron of a four-value pulse neural network; the four-value pulse neural network comprises k-layer neurons; a potential calculation module, configured to perform weighted summation on the output pulse of an (n-1)th layer neuron based on the weight of an nth layer neuron to update a potential value of the nth layer neuron; k≥n≥1, and n is an integer. The pulse determination module is configured to determine an output pulse of the n-th layer neuron according to the updated potential value of the n-th layer neuron; the output pulse of the n-th layer neuron is a four-value pulse value; the four-value pulse value is used to indicate a weight operation performed during the weighted summation; the weight operation includes one of weight setting to zero, weight keeping unchanged, weight left shifting by one bit, and weight left shifting by two bits; The result acquisition module is configured to acquire a detection result of the bioelectric signal according to the output pulse of the neuron of the k-th layer.
9. A four-value pulse neural network accelerator, comprising: The four-value pulse neural network accelerator includes a pulse neuron processing unit, a pulse neural network controller, a data scheduler, and on-chip storage; The data scheduler is configured to acquire the bioelectric signal and acquire pulse neural network parameters from the on-chip storage; The pulse neural network controller is configured to schedule data between the pulse neuron processing unit and the on-chip storage; The pulse neuron processing unit is configured to perform the method according to any one of claims 1 to 7.
10. The accelerator of claim 9, wherein, The pulse neuron processing unit includes an encoding unit, an accumulation module, a four-value pulse activation unit, a pulse inhibition unit, and a register cluster; The encoding unit is configured to convert the received bioelectric signal into a spike signal; The accumulation module is configured to perform weighted summation on the input pulse; The four-value pulse activation unit is configured to add the neuron pulse input of the weighted summation to the potential value of the neuron, and divide the potential value of the neuron into a four-value pulse value through a comparator; The register cluster includes multiple groups of registers, each group of registers stores pulse data collected in a specified time period, and when the data in the register is all 0, it indicates that the four-value pulse activation unit skips the weighted summation operation; The pulse inhibition unit is configured to perform spike time step counting, and disable the register cluster, the accumulation module, and the four-value pulse activation unit after detecting the spike signal; The encoding unit and the four-value pulse activation unit share an adder and a comparator.