IF neuron matlab simulation based on SNN pulse neural network

Table of contents

1. Theoretical basis

2. Core program

3. Simulation conclusion


1. Theoretical basis

      SNN (Spiking Neural Network) is a neural network model that simulates the transmission of pulses in the nervous system. Among them, the IF (Integrate-and-Fire) neuron model is a commonly used spiking neuron model. This article will introduce in detail the specific implementation steps, mathematical formulas and difficulties of IF neuron pulses in SNN.

      Step 1: Potential integration The IF neuron model simulates the change of neuron membrane potential by integrating the input current. At each time step, neurons receive input currents from other neurons and accumulate them onto the neuron's membrane potential. The potential integral can be expressed using the following mathematical formula:

       Among them, V(t) represents the membrane potential at time $t$, V(t-1) represents the membrane potential of the previous time step, and I_i(t) represents the input current from the i-th neuron. 

Implementation difficulties:

  1. Calculation of input currents: Changes in membrane potential depend on input currents from other neurons. In practical applications, how to accurately calculate the input current is a key issue, which involves the processing of neuron connection weights and synaptic transmission mechanisms.
  2. Clock synchronization: In order to simulate the discrete-time behavior of neurons, SNNs need a global clock for time-step synchronization. Ensuring that neurons update simultaneously at each time step is an implementation pain point.

       Step 2: Spike firing When the membrane potential exceeds a threshold V_{\text{th}}, the IF neuron will fire a spike and reset the membrane potential to an initial value V_{\text{reset}}. The pulse firing process can be expressed using the following mathematical formula:

Among them, V_{\text{th}} represents the threshold potential, and V_{\text{reset}} represents the reset potential after the pulse is released.

Implementation difficulties:

  1. Threshold selection: Choosing an appropriate threshold V_{\text{th}} has an important impact on the firing of neurons. Thresholds that are too high or too low can cause neurons to fire incorrectly or to fire too often.
  2. Determination of the reset potential: After a pulse is fired, the neuron needs to reset the membrane potential to an initial value. Determining an appropriate reset potential $V_{\text{reset}}$ to ensure membrane potential stability and correct spiking is a challenge.

Step 3: Membrane potential attenuation In order to simulate the attenuation of neuron membrane potential, a membrane potential attenuation factor \tau can be introduced. The membrane potential decays by this factor at each time step. The membrane potential decay process can be expressed using the following mathematical formula:

 

where \tau represents the time constant of membrane potential decay.

Implementation difficulties:

  1. Selection of attenuation factor: The selection of the membrane potential attenuation factor $\tau$ has an important influence on the decay speed of the neuron membrane potential. A suitable attenuation factor needs to be adjusted according to the characteristics of neurons in practical applications.

       In summary, the implementation steps of IF neuron pulses in SNN include potential integration, pulse firing and membrane potential decay. The simulation of spiking neurons is achieved by integrating the input current, the firing of the membrane potential beyond the threshold, and the decay of the membrane potential. Difficulties in implementing IF neuron spikes include calculation of input current, clock synchronization, threshold selection, determination of reset potential, and selection of decay factors. Overcoming these difficulties can lead to efficient and accurate SNN models.

2. Core program

.........................................................................
        AveRate_vect= zeros(0,length(I_vect_long));
        for I_In =I_vect_long; %loop over different I_In values 
                    I_Num = I_Num + 1; 
                    NumSpikes = 0; %holds number of spikes that have occurred 
                     i = 1; % index denoting which element of V is being assigned 
                            spike_flag=0;
                            Times=t_ref/dt;%max times
                            V_vect(i)= V0; %first element of V, i.e. value of V at t=0 
                            I_e_vect = I_In*ones(1,1+t_time/dt);
                            for t=dt:dt:t_time %loop through values of t in steps of dt ms 
                                %INTEGRATE THE EQUATION tau*dV/dt = -V + IR
                                RI =I_e_vect(i)*R_m;
                                if (V_vect(i) > V_th) %cell spiked 
                                    spike_flag=1;
                                    Times=0;
                                    NumSpikes = NumSpikes + 1; %add 1 to the total spike count 
                                end 
                                 if (spike_flag==1)
                                      V_vect(i+1) = V_res; %set voltage back to V_res
                                      Times=Times+1;
                                       else    V_vect(i+1) = RI*dt/tau + (1-dt/tau)*V_vect(i); 
                                 end   
                                 if (Times==(t_ref/dt+1))
                                     spike_flag=0;
                                 end
                                    i = i + 1; %add 1 to index, corresponding to moving forward 1 time step    
                                 end 
                 AveRate_vect(I_Num) =NumSpikes/t_time; %gives average firing rate in [#/sec = Hz] 
        end 
end
up2162

3. Simulation conclusion

 

 

Guess you like

Origin blog.csdn.net/ccsss22/article/details/131721446