spaic.Neuron package
Submodules
spaic.Neuron.Decoders module
@author: Yuan Mengwen @contact: mwyuan94@gmail.com @project: PyCharm @filename: Decoders.py @time:2021/5/7 14:50 @description:
- class spaic.Neuron.Decoders.Spike_Rate(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Spike_Counts(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Spike_Rates(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Final_Step_Voltage(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
DecoderGet label that has the highest voltage.
- class spaic.Neuron.Decoders.First_Spike(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.TimeSpike_Counts(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.NullDeocder(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.V_Trajectory(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Time_Softmax(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder- property loss
- class spaic.Neuron.Decoders.Voltage_Sum(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Complex_Count(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Complex_Phase(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Complex_Latency(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Complex_TimingDistance(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
- class spaic.Neuron.Decoders.Complex_Trajectory(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Decoder
spaic.Neuron.Encoders module
@author: Yuan Mengwen @contact: mwyuan94@gmail.com @project: PyCharm @filename: Encoders.py @time:2021/5/7 14:50 @description:
- class spaic.Neuron.Encoders.NullEncoder(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
EncoderPass the encoded data.
- class spaic.Neuron.Encoders.FloatEncoding(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Encoder
- class spaic.Neuron.Encoders.SigleSpikeToBinary(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
EncoderTransform the spike train (each neuron firing one spike) into a binary matrix The source is the encoded time value in the range of [0,time]. The shape of encoded source should be [batch_size, shape].
- class spaic.Neuron.Encoders.MultipleSpikeToBinary(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
EncoderTransform the spike train (each neuron firing multiple spikes) into a binary matrix The source is the encoded time value in the range of [0,time]. The shape of encoded source should be [time_step, batch_size, neuron_shape].
- class spaic.Neuron.Encoders.PoissonEncoding(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Encoder泊松频率编码,发放脉冲的概率即为刺激强度,刺激强度需被归一化到[0, 1]。 Generate a poisson spike train. time: encoding window ms dt: time step
- class spaic.Neuron.Encoders.bernoulli(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Encoder伯努利分布。 Generate a bernoulli spike train. time: encoding window ms dt: time step
- class spaic.Neuron.Encoders.Latency(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Encoder延迟编码,刺激强度越大,脉冲发放越早。刺激强度被归一化到[0, 1]。 Generate a latency encoding spike train. time: encoding window ms dt: time step
- class spaic.Neuron.Encoders.Relative_Latency(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Encoder相对延迟编码,在一个样本中,其相对强度越大,放电越靠前
spaic.Neuron.Generators module
@author: Yuan Mengwen @contact: mwyuan94@gmail.com @project: PyCharm @filename: Generators.py @time:2021/6/21 16:35 @description:
- class spaic.Neuron.Generators.Poisson_Generator(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson_generator', 'cc_generator', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Generator泊松生成器,根据输入脉冲速率生成。 Generate a poisson spike train according input rate. time: encoding window ms dt: time step HZ: cycles/s
- class spaic.Neuron.Generators.Poisson_Generator2(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson_generator', 'cc_generator', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Generator泊松生成器,根据输入脉冲速率生成。 Generate a poisson spike train according input rate. time: encoding window ms dt: time step
- class spaic.Neuron.Generators.CC_Generator(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson_generator', 'cc_generator', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
Generator恒定电流生成器。 Generate a constant current input. time: encoding window ms dt: time step
- class spaic.Neuron.Generators.Sin_Generator(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson_generator', 'cc_generator', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
GeneratorGenerate a sin current input. time: encoding window ms dt: time step
spaic.Neuron.Module module
Created on 2021/4/12 @project: SPAIC @filename: Module @author: Hong Chaofei @contact: hongchf@gmail.com
@description: wrap around deep learning module such as a cnn network lstm cell
spaic.Neuron.Neuron module
Created on 2020/8/5 @project: SPAIC @filename: Neuron @author: Hong Chaofei @contact: hongchf@gmail.com
@description: 定义神经集群和神经元模型。 神经元集群保存神经元数目、神经元编号、类型、模型、模型参数、神经元位置等信息,参与网络构建
- class spaic.Neuron.Neuron.NeuronGroup(num=None, model=None, shape=None, neuron_type=('excitatory', 'inhibitory', 'pyramidal', '...'), neuron_position='x, y, z', name=None, parameter_variables: list | None = None, varible_ranges: dict | None = None, prefer_device=None, **kwargs)[source]
Bases:
AssemblyClass for a group of neurons.
- build(backend)[source]
- Parameters:
backend (Backend.Backend) –
- static custom_model(input_vars, output_vars, new_vars_dict, equation_type=('iterative', 'euler_iterative', 'exp_euler_iterative', 'ode'), backend='torch', custom_function_name='custom', base_model=None, add_threshold=True)[source]
Examples
@NeuronGroup.custom_model(input_vars=[‘M’, ‘S’, ‘WgtSum’], output_vars=[‘V’, ‘M’, ‘S’], new_vars_dict={‘V’:0, ‘M’:0, ‘S’:0, ‘WgtSum’:0}, equation_type=’exp_euler_iterative’) def func(M, S, WgtSum):
M = (WgtSum-M)/tau S = (WgtSum-S)/tau V = M - S return V, M, S
NeuronGroup(…., model=func)
- class spaic.Neuron.Neuron.NeuronModel(**kwargs)[source]
Bases:
ABCop -> (return_name, operation_name, input_name1, input_name2…)
- neuron_models = {'aclif': <class 'spaic.Neuron.Neuron.AdaptiveCLIFModel'>, 'adex': <class 'spaic.Neuron.Neuron.aEIFModel'>, 'aeif': <class 'spaic.Neuron.Neuron.aEIFModel'>, 'alifstdp_ex': <class 'spaic.Neuron.Neuron.ALIFSTDPEXModel'>, 'cann_field': <class 'spaic.Neuron.Neuron.CANN_MeanFieldModel'>, 'clif': <class 'spaic.Neuron.Neuron.CLIFModel'>, 'clif2k': <class 'spaic.Neuron.Neuron.CLIF2kModel'>, 'constantcurrentlif': <class 'spaic.Neuron.Neuron.ConstantCurrentLIFModel'>, 'darwin_alif': <class 'spaic.Neuron.Neuron.Darwin_ALIF'>, 'darwin_clif': <class 'spaic.Neuron.Neuron.Darwin_CLIF'>, 'darwin_random': <class 'spaic.Neuron.Neuron.Darwin_Random'>, 'diehlandcook': <class 'spaic.Neuron.Neuron.DiehlAndCookModelInt'>, 'glif': <class 'spaic.Neuron.Neuron.GLIFModel'>, 'hh': <class 'spaic.Neuron.Neuron.HodgkinHuxleyModel'>, 'if': <class 'spaic.Neuron.Neuron.IFModel'>, 'ifb': <class 'spaic.Neuron.Neuron.IFBModel'>, 'ifsoftreset': <class 'spaic.Neuron.Neuron.IFSoftModel'>, 'izh': <class 'spaic.Neuron.Neuron.IZHModel'>, 'lif': <class 'spaic.Neuron.Neuron.LIFModel'>, 'lifint': <class 'spaic.Neuron.Neuron.LIFInt'>, 'lifm': <class 'spaic.Neuron.Neuron.LIFMModel'>, 'lifstdp_ex': <class 'spaic.Neuron.Neuron.LIFSTDPEXModel'>, 'lifstdp_ih': <class 'spaic.Neuron.Neuron.LIFSTDPIHModel'>, 'meanfield': <class 'spaic.Neuron.Neuron.MeanFieldModel'>, 'nonspikingifb': <class 'spaic.Neuron.Neuron.NonSpikingIFBModel'>, 'nonspikinglif': <class 'spaic.Neuron.Neuron.NonSpikingLIFModel'>, 'null': <class 'spaic.Neuron.Neuron.NullModel'>, 'pclif': <class 'spaic.Neuron.Neuron.PLIF2kModel'>, 'plif': <class 'spaic.Neuron.Neuron.PLIFModel'>, 'qlif': <class 'spaic.Neuron.Neuron.QLIFModel'>, 'selif': <class 'spaic.Neuron.Neuron.SELIFModel'>, 'slif': <class 'spaic.Neuron.Neuron.SLIFModel'>}
A dictionary mapping neuron model names to Model objects
- class spaic.Neuron.Neuron.CLIFModel(**kwargs)[source]
Bases:
NeuronModelCurrent LIF 3-kernel model: V(t) = M(t) − S(t) − E(t) I^n[t] = V0 * Isyn^n[t-1] #sum(w * O^(n-1)[t]) M^n[t] = betaM * M^n[t-1] + I^n[t-1] S^n[t] = betaS * S^n[t-1] + I^n[t-1] E^n[t] = betaM * E^n[t-1] + Vth * O^n[t-1] O^n[t] = spike_func(V^n[t-1])
- name = 'clif'
- class spaic.Neuron.Neuron.CLIF2kModel(**kwargs)[source]
Bases:
NeuronModelCurrent LIF 2-kernel model: V(t) = M(t) − S(t) − E(t) I^n[t] = V0 * Isyn^n[t-1] #sum(w * O^(n-1)[t]) M^n[t] = betaM * M^n[t-1] + I^n[t-1] S^n[t] = betaS * S^n[t-1] + I^n[t-1] E^n[t] = betaM * E^n[t-1] + Vth * O^n[t-1] O^n[t] = spike_func(V^n[t-1])
- name = 'clif2k'
- class spaic.Neuron.Neuron.PLIF2kModel(**kwargs)[source]
Bases:
NeuronModelCurrent LIF 2-kernel model: V(t) = M(t) − S(t) − E(t) I^n[t] = V0 * Isyn^n[t-1] #sum(w * O^(n-1)[t]) M^n[t] = betaM * M^n[t-1] + I^n[t-1] S^n[t] = betaS * S^n[t-1] + I^n[t-1] E^n[t] = betaM * E^n[t-1] + Vth * O^n[t-1] O^n[t] = spike_func(V^n[t-1])
- name = 'pclif'
- class spaic.Neuron.Neuron.AdaptiveCLIFModel(**kwargs)[source]
Bases:
NeuronModelCurrent LIF 3-kernel model: V(t) = M(t) − S(t) − E(t) I^n[t] = V0 * Isyn^n[t-1] #sum(w * O^(n-1)[t]) M^n[t] = betaM * M^n[t-1] + I^n[t-1] S^n[t] = betaS * S^n[t-1] + I^n[t-1] E^n[t] = betaM * E^n[t-1] + Vth * O^n[t-1] O^n[t] = spike_func(V^n[t-1])
- name = 'aclif'
- class spaic.Neuron.Neuron.IFModel(**kwargs)[source]
Bases:
NeuronModelIF model: V(t) = V(t-1) * (1 - O(t-1)) + Isyn[t] - ConstantDecay
O^n[t] = spike_func(V^n[t-1])
- name = 'if'
- class spaic.Neuron.Neuron.IFSoftModel(**kwargs)[source]
Bases:
NeuronModelIF soft reset model: V(t) = V(t-1) * (1 - O(t-1)) + Isyn[t] - ConstantDecay O^n[t] = spike_func(V^n[t-1])
- name = 'ifsoftreset'
- class spaic.Neuron.Neuron.IFBModel(**kwargs)[source]
Bases:
NeuronModelIF model: V(t) = V(t-1) * (1 - O(t-1)) + Isyn[t] - ConstantDecay
O^n[t] = spike_func(V^n[t-1])
- name = 'ifb'
- class spaic.Neuron.Neuron.NonSpikingIFBModel(**kwargs)[source]
Bases:
NeuronModelIFB model: V(t) = V(t-1) * (1 - O(t-1)) + Isyn[t] - ConstantDecay
O^n[t] = spike_func(V^n[t-1])
- name = 'nonspikingifb'
- class spaic.Neuron.Neuron.NullModel(**kwargs)[source]
Bases:
NeuronModelreturn ‘O’
- name = 'null'
- class spaic.Neuron.Neuron.QLIFModel(**kwargs)[source]
Bases:
NeuronModelLIF neuron model for Q-Backprop learning
E[t] = beta_m*E[t-1] + Vth*O[t-1] V[t] = WgtSum(PSP[t]) - E[t] O[t] = spike_function(V[t])
# Q for non-spiking Mp[t] = beta_m*Mp[t-1] + WpSum[t] Sp[t] = beta_s*Sp[t-1] + WpSum[t] P[t] = Mp[t] - Sp[t]
# Q for spiking Mq[t] = beta_m*Mq[t-1] + WqSum[t] Sq[t] = beta_s*Sq[t-1] + WqSum[t] Q[t] = Mq[t] - Sq[t]
R[t] = ~O[t]*beta_s*R[t-1] + O[t] F[t] = 1 - R[t] QP[t] = Q[t] - P[t] BQ[t] = R[t]*Q[t] + F[t]*P[t]
TP[t] = R[t]*P[t] + F[t]*Reward - P[t-1] TQ[t] = F[t]*Q[t] + R[t]*Reward - Q[t-1]
- name = 'qlif'
- class spaic.Neuron.Neuron.SELIFModel(tau_m=12.0, tau_p=6.0, tau_q=2.0, tau_r=16.0, v_th=1.0, v_reset=2.0, outlayer=False, **kwargs)[source]
Bases:
NeuronModelSpikeProp LIF 3-kernel model:
V[t] = WgtSum[t-1] - E[t-1] I[t] = spike_func(V[t]) M[t] = betaM * M[t-1] + I[t] S[t] = betaS * S[t-1] + I[t] E[t] = betaM * E[t-1] + Vth * I[t] O[t] = M[t] − S[t]
- initial_op_code
V(t) = M(t) − S(t) − E(t) I^n[t] = V0 * WgtSum^n[t-1] #sum(w * O^(n-1)[t]) M^n[t] = betaM * M^n[t-1] + I^n[t-1] S^n[t] = betaS * S^n[t-1] + I^n[t-1] E^n[t] = betaM * E^n[t-1] + Vth * O^n[t-1]
O^n[t] = spike_func(V^n[t-1])
- property E_values
- property E_grads
- name = 'selif'
- class spaic.Neuron.Neuron.SLIFModel(tau_m=20.0, tau_p=20.0, tau_q=8.0, v_th=1.0, v_reset=2.0, outlayer=False)[source]
Bases:
NeuronModelSpikeProp LIF 3-kernel model:
V[t] = WgtSum[t-1] - E[t-1] I[t] = spike_func(V[t]) M[t] = betaM * M[t-1] + I[t] S[t] = betaS * S[t-1] + I[t] E[t] = betaM * E[t-1] + Vth * I[t] O[t] = M[t] − S[t]
- initial_op_code
V(t) = M(t) − S(t) − E(t) I^n[t] = V0 * WgtSum^n[t-1] #sum(w * O^(n-1)[t]) M^n[t] = betaM * M^n[t-1] + I^n[t-1] S^n[t] = betaS * S^n[t-1] + I^n[t-1] E^n[t] = betaM * E^n[t-1] + Vth * O^n[t-1]
O^n[t] = spike_func(V^n[t-1])
- property E_values
- property E_grads
- name = 'slif'
- class spaic.Neuron.Neuron.SELIFDebugModel(tau_m=20.0, tau_p=20.0, tau_q=8.0, v_th=1.0, outlayer=False)[source]
Bases:
NeuronModel
- class spaic.Neuron.Neuron.LIFModel(**kwargs)[source]
Bases:
NeuronModelLIF model: # V(t) = tuaM * V^n[t-1] + Isyn[t] # tauM: constant membrane time (tauM=RmCm) O^n[t] = spike_func(V^n[t-1])
- name = 'lif'
- class spaic.Neuron.Neuron.PLIFModel(**kwargs)[source]
Bases:
NeuronModelLIF model: # V(t) = tuaM * V^n[t-1] + Isyn[t] # tauM: constant membrane time (tauM=RmCm) O^n[t] = spike_func(V^n[t-1])
- name = 'plif'
- class spaic.Neuron.Neuron.ConstantCurrentLIFModel(**kwargs)[source]
Bases:
NeuronModelConstantCurrentLIF model: V(t) = V^n[t-1] + (dt/taum) * (Ureset-V^n[t-1]+I) # tauM: constant membrane time (tauM=RmCm) Isyn = I*Weight O^n[t] = spike_func(V^n[t-1])
- name = 'constantcurrentlif'
- class spaic.Neuron.Neuron.NonSpikingLIFModel(**kwargs)[source]
Bases:
NeuronModelNonSpikingLIF model: # V(t) = -tuaM * V^n[t-1] + M^n[t] - S^n[t] # tauM: constant membrane time (tauM=RmCm) V(t) = V^n[t-1] + (dt/taum) * (PSP-V^n[t-1]) # tauM: constant membrane time (tauM=RmCm) I^n[t] = V0 * Isyn^n[t-1] # sum(w * O^(n-1)[t]) M^n[t] = tauP * M^n[t-1] + I^n[t-1] # tauP: decaying time constants of membrane integration S^n[t] = tauQ * S^n[t-1] + I^n[t-1] # tauQ: decaying time constants of synaptic currents PSP = M - S
- name = 'nonspikinglif'
- class spaic.Neuron.Neuron.LIFMModel(**kwargs)[source]
Bases:
NeuronModelLIF model: # I_che = tauP*I + Isyn^n[t-1] + b^n # sum(w * O^(n-1)[t]) # I = I_che + I_ele # F = tauM * exp(-O^n[t-1] / tauM) # V(t) = V^n[t-1] * F + I # O^(n)[t] = spike_func(V^n(t))
- name = 'lifm'
- class spaic.Neuron.Neuron.IZHModel(**kwargs)[source]
Bases:
NeuronModelIZH model:
\[ \begin{align}\begin{aligned}V = V + dt / tauM * (C1 * V * V + C2 * V + C3 - U + I) # tauM=1 此处加tauM是为了添加op时和LIF模型保存一致 \ V = V + dt / tauM * (V* (C1 * V + C2) + C3 - U + I) # 由上式拆分而来 \ U = U + a. * (b. * V - U) \\\O^n[t] = spike\_func(V^n[t-1])\\if V > Vth, \ then V = C, U = U + d\end{aligned}\end{align} \]References
Izhikevich, E. M. (2003). Simple model of spiking neurons. IEEE Transactions on neural networks, 14(6), 1569-1572.
- name = 'izh'
- class spaic.Neuron.Neuron.aEIFModel(**kwargs)[source]
Bases:
NeuronModelaEIF model:
\[ \begin{align}\begin{aligned}V = V + dt / tauM * (EL - V + EXP - U + I^n[t]) \ U = U + dt / tauW * (a * (V - EL) - U) \ EXP = delta\_t * delta\_t2 * exp(dv\_th/delta\_t2) \ dv = V - EL \ dv\_th = V - Vth\\O^n[t] = spike\_func(V^n[t-1]) \\\If V > 20: \ then V = EL, U = U + b\end{aligned}\end{align} \]References
Brette, R., & Gerstner, W. (2005). Adaptive exponential integrate-and-fire model as an effective description of neuronal activity. Journal of neurophysiology, 94(5), 3637-3642.
- name = 'adex'
- class spaic.Neuron.Neuron.GLIFModel(**kwargs)[source]
Bases:
NeuronModelCurrent GLIF5 model:
V = V + dt / C * (I + I1 + I2 - (V - E_L) / R) Theta_s = Theta_s - dt * b_s * Theta_s I_j = I_j - dt * k_j * I_j (j = 1,2) Theta_v = Theta_v + dt * (a_v * (V - E_L) - b_v * Theta_v)
v_th = Theta_v + Theta_s + Theta_inf O = spike_func(V)
Reset function:
V = E_L + f_v * (V - E_L) - delta_v Theta_s = Theta_s + delta_Theta_s I_j = f_j * I_j + delta_I_j (j = 1, 2) Theta_v = Theta_v
References
Teeter, C., Iyer, R., Menon, V., Gouwens, N., Feng, D., Berg, J., … & Mihalas, S. (2018). Generalized leaky integrate-and-fire models classify multiple neuron types. Nature communications, 9(1), 1-15.
- name = 'glif'
- class spaic.Neuron.Neuron.HodgkinHuxleyModel(**kwargs)[source]
Bases:
NeuronModelHodgkin-Huxley model:
V = V + dt/tau_v * (I - Ik) Ik = NA + K + L NA = g_NA * m^3 * h * (V - V_NA) K = g_K * n^4 * (V - V_K) L = g_L * (V - V_L)
Na activation: m = m + dt/tau_m * (alpha_m * (1-m) - beta_m * m)
K activation: n = n + dt/tau_n * (alpha_n * (1-n) - beta_n * n)
Na inactivation: h = h + dt/tau_h * (alpha_h * (1-h) - beta_h * h)
original function1: alpha_m = 0.1 * (-V + 25) / (exp((-V+25)/10) - 1) beta_m = 4 * exp(-V/18) alpha_n = 0.01 * (-V + 10) / (exp((-V+10)/10) - 1) beta_n = 0.125 * exp(-V/80) alpha_h = 0.07 * exp(-V/20) beta_h = 1/(exp((-V+30)/10) + 1)
O^n[t] = spike_func(V^n[t-1])
- name = 'hh'
- class spaic.Neuron.Neuron.LIFSTDPEXModel(**kwargs)[source]
Bases:
NeuronModelLIF model: V(t) = decay_v * (v - v_rest) + v_rest + I^n[t] I^n[t] = V0 * Isyn^n[t] #V0 = 1 theta(t) = decay_th * theta[t-1] if v >= (vth + theta) then s_out = 1; else s_out = 0; Reset: V(t) = s_out * v_reset + (1 - s_out) * v; theta = theta + s_out * th_inc O^n[t] = spike_func(V^n[t-1])
- name = 'lifstdp_ex'
- class spaic.Neuron.Neuron.ALIFSTDPEXModel(**kwargs)[source]
Bases:
NeuronModelLIF model: V(t) = decay_v * (v - v_rest) + v_rest + I^n[t] I^n[t] = V0 * Isyn^n[t] #V0 = 1 theta(t) = decay_th * theta[t-1] if v >= (vth + theta) then s_out = 1; else s_out = 0; Reset: V(t) = s_out * v_reset + (1 - s_out) * v; theta = theta + s_out * th_inc
O^n[t] = spike_func(V^n[t-1])
- name = 'alifstdp_ex'
- class spaic.Neuron.Neuron.LIFSTDPIHModel(**kwargs)[source]
Bases:
NeuronModelLIF model: V(t) = decay_v * (v - v_rest) + v_rest + I^n[t] I^n[t] = V0 * Isyn^n[t] #V0 = 1
Reset: V(t) = s_out * v_reset + (1 - s_out) * v;
O^n[t] = spike_func(V^n[t-1])
- name = 'lifstdp_ih'
- class spaic.Neuron.Neuron.DiehlAndCookModelInt(**kwargs)[source]
Bases:
NeuronModelLayer of leaky integrate-and-fire (LIF) neurons with adaptive thresholds (modified for Diehl & Cook 2015 replication), based on integer arithmetic: if thresh > max_threshold: thresh = thresh/2 # Decay voltages. V(t) = ((self.decay * (v - self.rest)) >> shift_voltage) + self.rest # decay = 1013; v_rest = 0; shift_voltage = 10 # Integrate inputs. V(t) = V(t) + (self.refrac_count <= 0).int() * ((Isyn^n[t] * self.weight_sum_coef) >> self.shift_weight_sum_coef) refrac_count=0; weight_sum_coef = 154; shift_weight_sum_coef = 10 # Decrement refractory counters. self.refrac_count -= 1 # Check for spiking neurons. O^n[t] = spike_func(V^n[t-1]) # Refractoriness, voltage reset, and adaptive thresholds. self.refrac_count.masked_fill_(self.s, self.reset_refrac) self.reset_refrac = 5 self.v.masked_fill_(self.s, self.reset) self.thresh = self.thresh + self.thresh_plus * self.s.int().sum(0) # Voltage clipping to lower bound. if self.lbound is not None:
self.v.masked_fill_(self.v < self.lbound, self.lbound)
- update(x, v, thresh, refrac_count, decay, rest, shift_voltage, max_threshold, weight_sum_coef, shift_weight_sum_coef, refrac, reset, thresh_plus, lbound, weight_sum_min, weight_sum_max)[source]
- name = 'diehlandcook'
- class spaic.Neuron.Neuron.LIFInt(**kwargs)[source]
Bases:
NeuronModelLayer of leaky integrate-and-fire (LIF) neurons based on integer arithmetic:
- name = 'lifint'
- class spaic.Neuron.Neuron.CANN_MeanFieldModel(**kwargs)[source]
Bases:
NeuronModelMean Field Model used in “Fung CC, Wong KY, Wu S. A moving bump in a continuous manifold: a comprehensive study of the tracking dynamics of continuous attractor neural networks. Neural Comput. 2010 Mar;22(3):752-92. doi: 10.1162/neco.2009.07-08-824. ” “Wu S, Wong KY, Fung CC, Mi Y, Zhang W. Continuous Attractor Neural Networks: Candidate of a Canonical Model for Neural Information Representation.F1000Res. 2016 Feb 10;5:F1000 Faculty Rev-156. doi: 10.12688/f1000research.7387.1. “
U = U + dt/tau * (Iext + rho*WgtSum - U) O = U^2/(1 + k*rho*sum(U^2)) (WgtSum = weight*O_pre)
- name = 'cann_field'
- class spaic.Neuron.Neuron.MeanFieldModel(**kwargs)[source]
Bases:
NeuronModelMean Field Model of LIF neuron “
U = U + dt/tau * (rho*(Iext + Isyn) - U) O = relu(U) (WgtSum = weight*O_pre)
- name = 'meanfield'
- class spaic.Neuron.Neuron.SimpleRateModel(**kwargs)[source]
Bases:
NeuronModelRate model “
U = U + dt/tau * (sigmoid(Iext + WgtSum) - U) (WgtSum = weight*O_pre)
- class spaic.Neuron.Neuron.Darwin_CLIF(**kwargs)[source]
Bases:
NeuronModelI = I*P4 + Wgt_sum V = V*P0 + I + P1
- name = 'darwin_clif'
- class spaic.Neuron.Neuron.Darwin_ALIF(**kwargs)[source]
Bases:
NeuronModelAdaptive threshold LIF I = I*P4 + Wgt_sum V = V*P0 + I + P1 Vth = Vth*P2 + C1 if spike: Vth = Vth + C2
- name = 'darwin_alif'
spaic.Neuron.Node module
Created on 2020/8/11 @project: SPAIC @filename: Node @author: Hong Chaofei @contact: hongchf@gmail.com
@description: 定义神经网络的输入输出接口
- class spaic.Neuron.Node.Node(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
AssemblyBase class for input encoder and output decoders.
- property dt
- property time_step
- property time
- static register(name, coding_class)[source]
Register a coding class. Registered encoding or decoding classes can be referred to # via their name. :param name: A short name for the state updater (e.g. ‘poisson’, ‘spike_counts’) :type name: str :param coding_class: The subclass of coding object, e.g. an ‘PoissonEncoding’, ‘Spike_Counts’.
- torch_coding(source: Tensor, target: Tensor, device: str) Tensor[source]
- Parameters:
source – It is input spike trains for encoding class and output spike trains for decoding class.
target – It is None for encodoing class and labels for decoding class.
device – CPU or CUDA, this parameter is taken from backend
Returns:
- class spaic.Neuron.Node.Encoder(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
NodeFive encoding method are provided, as shown below (key: class): 1. ‘sstb’: SigleSpikeToBinary, 2. ‘mstb’: MultipleSpikeToBinary 3. ‘poisson’: PoissonEncoding 4. ‘latency’: Latency 5. ‘relative_latency’: Relative_Latency
- static register(name, coding_class)[source]
Register a coding class. Registered encoding or decoding classes can be referred to # via their name. :param name: A short name for the state updater (e.g. ‘poisson’, ‘spike_counts’) :type name: str :param coding_class: The subclass of coding object, e.g. an ‘PoissonEncoding’, ‘Spike_Counts’.
- class spaic.Neuron.Node.Decoder(num=None, dec_target=None, dt=None, coding_method='spike_counts', coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
NodeFive decoding method are provided, as shown below (key: class): 1. ‘spike_counts’: Spike_Counts 2. ‘first_spike’: First_Spike 3. ‘time_spike_counts’: TimeSpike_Counts 4. ‘time_softmax’: Time_Softmax 5. ‘final_step_voltage’: Final_Step_Voltage
- static register(name, coding_class)[source]
Register a coding class. Registered encoding or decoding classes can be referred to # via their name. :param name: A short name for the state updater (e.g. ‘poisson’, ‘spike_counts’) :type name: str :param coding_class: The subclass of coding object, e.g. an ‘PoissonEncoding’, ‘Spike_Counts’.
- class spaic.Neuron.Node.Reward(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
NodeThree reward method are provided, as shown below (key: class): 1. ‘global_reward’, Global_Reward 2. ‘xor_reward’: XOR_Reward 3. ‘da_reward’: DA_Reward 4. ‘environment_reward’: Environment_Reward
- class spaic.Neuron.Node.Generator(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson_generator', 'cc_generator', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
NodeTwo generator method are provided, as shown below (key: class): 1. ‘poisson_generator’: Poisson_Generator, 2. ‘cosine_generator’: Cosine_Generator
- static register(name, coding_class)[source]
Register a coding class. Registered encoding or decoding classes can be referred to # via their name. :param name: A short name for the state updater (e.g. ‘poisson’, ‘spike_counts’) :type name: str :param coding_class: The subclass of coding object, e.g. an ‘PoissonEncoding’, ‘Spike_Counts’.
- class spaic.Neuron.Node.Action(shape=None, num=None, dec_target=None, dt=None, coding_method=('poisson', 'spike_counts', '...'), coding_var_name='O', node_type=('excitatory', 'inhibitory', 'pyramidal', '...'), **kwargs)[source]
Bases:
NodeSix action method are provided, as shown below (key: class): 1. ‘pop_rate_action’: PopulationRate_Action 2. ‘softmax_action’: Softmax_Action 3. ‘highest_spikes_action’: Highest_Spikes_Action 4. ‘highest_voltage_action’, Highest_Voltage_Action 5. ‘first_spike_action’: First_Spike_Action 6. ‘random_action’: Random_Action
- static register(name, coding_class)[source]
Register an action class. Registered action classes can be referred to # via their name. :param name: A short name for the state updater (e.g. ‘pop_rate_action’) :type name: str :param coding_class: The subclass of coding object, e.g. an ‘PopulationRate_Action’.
Module contents
Created on 2020/8/11 @project: SPAIC @author: Hong Chaofei @contact: hongchf@gmail.com
@description: