近年来,深度学习彻底改变了机器学习领域,尤其是计算机视觉。在这种方法中,使用反向传播以监督的方式训练深层(多层)人工神经网络(ANN)。虽然需要大量带标签的训练样本,但是最终的分类准确性确实令人印象深刻,有时甚至胜过人类。人工神经网络中的神经元的特征在于单个、静态、连续值的激活。然而生物神经元使用离散的脉冲来计算和传输信息,并且除了脉冲发放率外,脉冲时间也很重要。因此脉冲神经网络(SNN)在生物学上比ANN更现实,并且如果有人想了解大脑的计算方式,它无疑是唯一可行的选择。 SNN也比ANN更具硬件友好性和能源效率,因此对技术,尤其是便携式设备具有吸引力。但是训练深度SNN仍然是一个挑战。脉冲神经元的传递函数通常是不可微的,从而阻止了反向传播。在这里,我们回顾了用于训练深度SNN的最新监督和无监督方法,并在准确性、计算成本和硬件友好性方面进行了比较。目前的情况是,SNN在准确性方面仍落后于ANN,但差距正在缩小,甚至在某些任务上可能消失,而SNN通常只需要更少的操作。
SNN中的无监督学习通常将STDP纳入学习机制。生物STDP的最常见形式具有非常直观的解释。如果突触前神经元在突触后神经元之前不久触发(大约10毫秒),则连接它们的权重会增加。如果突触后神经元在突触后神经元后不久触发,则时间事件之间的因果关系是虚假的,权重会减弱。增强称为长时程增强(LTP),减弱称为长时程抑制(LTD)。短语“长时程”用于区分实验中观察到的几毫秒范围内的非常短暂的影响。
下面的公式是通过拟合实验数据对一对脉冲进行了实验上最常见的STDP规则的理想化。
以上公式中的第一种情况描述LTP,而第二种情况描述LTD。效果的强度由衰减指数调制,衰减指数的大小由突触前和突触后脉冲之间的时间常数比例时间差控制。人工SNN很少使用此确切规则。他们通常使用变体,以实现更多的简单性或满足便利的数学特性。
SNN神经网络的学习方法也不是很好,作为传统的基于速率的网络而发展,使用反向传播学习算法。使用高效的Hebbian学习方法:棘突神经元网络的稳态。类似于STDP,尖峰之间的计时用于突触修饰。内稳态确保了突触权重是有界的学习是稳定的。赢家通吃机制也很重要实施以促进输出之间的竞争性学习神经元。我们已经在一个C++对象中实现了这个方法面向对象的代码(称为CSpike)。我们已经在四个服务器上测试了代码Gabor滤波器的图像,并发现钟形调谐曲线使用不同类型的Gabor滤波器的36个测试集图像方向。这些钟形曲线与这些曲线相似实验上观察到的V1和MT/V5区域哺乳动物的大脑。
SNN即目前的最新的第三代神经网络,具体的仿真步骤如下所示:
matlab仿真程序如下所示:
登录后复制
clc;clear;close all;warning off;addpath 'func\'RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));%%load Character\Character_set.mat%显示论文fig1. character set usedfunc_view_character;%**************************************************************************%%%显示论文fig2. Representation of 'A'A_Line = Representation_Character(A_ch);figure;stem(1:5*3,A_Line,'LineWidth',2);hold onstairs(1:5*3,A_Line,'r');axis([0,5*3+1,-0.25,1.25]);title('Fig.2. Representation of A');%**************************************************************************%% 以下是程序的第一部分,即4个字符的仿真%建立SNN神经网络模型Rm = 80;theta = 10; %10mvrs = 2; %2msrm = 30; %30msrmin = 2; %2msrmax = 30; %30ms;lin = 0.3;lin_dec = 0.05;A1 = 0.1;A2 =-0.105;r1 = 1; %1msr2 = 1; %1mststep = 0.2; %0.2ms;times = 200; %训练次数error = 1e-3;%训练目标误差vth = 7; %通过神经网络对A,B,C,D进行训练识别%对应论文fig.3. Output when each character is presented individually%随机产生初始的权值wijN_in = 15;w_initial = 0.5+0.5*rand(N_in,4);for i = 1:times w{i} = w_initial;endw0 = w_initial;dew = 0;wmax = 0;wmin = 0;det = zeros(N_in,4); tpre = 300*ones(N_in,times); tpost = 301*ones(N_in,times); Time2 = 4000;dt = 0.05;STIME = 24; %%%字符转换为电平A_Line = Representation_Character(A_ch);B_Line = Representation_Character(B_ch);C_Line = Representation_Character(C_ch);D_Line = Representation_Character(D_ch);Lines = [A_Line B_Line C_Line D_Line];for num = 1:4 Dat = Lines(:,num); for ij = 1:1 for i = 1:times w{i} = w_initial; end ind = 0; for i = 1:times i ind = ind + 1; %计算rd for n1 = 1:N_in rd(n1) = rmax - abs(w{i}(n1))*(rmax - rmin); end %计算Rd for n1 = 1:N_in Rd(n1) = (rd(n1)*theta/Rm) * (rm/rd(n1))^(rm/(rm-rd(n1))); end %计算delta t for n1 = 1:N_in if Dat(n1) == 1 det(n1) = tpre(n1,i) - tpost(n1,i); else det(n1) = -(tpre(n1,i) - tpost(n1,i)); end end %计算delta w for n1 = 1:N_in if det(n1) <= 0 dew(n1) = A1*exp( det(n1)/r1); else dew(n1) = A2*exp(-det(n1)/r2); end if i > 1 %计算权值更新 if dew(n1) > 0 w{i}(n1) = w{i-1}(n1) + lin*dew(n1)*(w{i-1}(n1)); else w{i}(n1) = w{i-1}(n1) + lin*dew(n1)*(w{i-1}(n1)); end end end %计算Id for n1 = 1:N_in Id{n1} = func_Id(Rd(n1),rd(n1),w{i}(n1),Dat(n1),Time2,dt,tpre(n1,i)); end %计算Is Is = func_Is(N_in,rs,w{i},Dat,Time2,dt,tpre(n1,i)); %计算u Um = func_um(N_in,w{i},Rm,Id,Is,rm,Time2,dt,Dat,tpre(n1,i),vth); %计算训练误差 if i > 1 err2(ind-1) = abs(norm(w{i}/max(w{i})) - norm(w{i-1}/max(w{i-1}))); if abs(norm(w{i}/max(w{i}) - norm(w{i-1}/max(w{i-1})))) <= error break; end end end end Ws(:,num) = w{end}/max(w{end}); clear Is Id Um wend%%%训练完之后进行测试%A测试%A测试UmA = [];for ij = 1:STIME ij for j = 1:4 ind = 0; ind = ind + 1; %计算Id for n1 = 1:N_in Id{n1} = func_Id(Rd(n1),rd(n1),Ws(n1,1),Lines(n1,j),Time2,dt,tpre(n1,j)); end %计算Is Is{j} = func_Is(N_in,rs,Ws(:,1),Lines(:,j),Time2,dt,tpre(n1,j)); %计算u Um(j,:) = func_um(N_in,Ws(:,1),Rm,Id,Is{j},rm,Time2,dt,Lines(:,j),tpre(n1,j),vth); end UmA = [UmA,Um];end figure;plot(1:Time2*STIME,UmA(1,:),'r');hold onplot(1:Time2*STIME,UmA(2,:),'g');hold onplot(1:Time2*STIME,UmA(3,:),'b');hold onplot(1:Time2*STIME,UmA(4,:),'c');hold offlegend('Neuron1','Neuron2','Neuron3','Neuron4');axis([1,Time2*STIME,0,30]);clear Id Is Um w%B测试%B测试UmB = [];for ij = 1:STIME ij for j = 1:4 ind = 0; ind = ind + 1; %计算Id for n1 = 1:N_in Id{n1} = func_Id(Rd(n1),rd(n1),Ws(n1,2),Lines(n1,j),Time2,dt,tpre(n1,j)); end %计算Is Is{j} = func_Is(N_in,rs,Ws(:,2),Lines(:,j),Time2,dt,tpre(n1,j)); %计算u Um(j,:) = func_um(N_in,Ws(:,2),Rm,Id,Is{j},rm,Time2,dt,Lines(:,j),tpre(n1,j),vth); end UmB = [UmB,Um];end figure;plot(1:Time2*STIME,UmB(1,:),'r');hold onplot(1:Time2*STIME,UmB(2,:),'g');hold onplot(1:Time2*STIME,UmB(3,:),'b');hold onplot(1:Time2*STIME,UmB(4,:),'c');hold offlegend('Neuron1','Neuron2','Neuron3','Neuron4');axis([1,Time2*STIME,0,30]);clear Id Is Um w%C测试%C测试UmC = [];for ij = 1:STIME ij for j = 1:4 ind = 0; ind = ind + 1; %计算Id for n1 = 1:N_in Id{n1} = func_Id(Rd(n1),rd(n1),Ws(n1,3),Lines(n1,j),Time2,dt,tpre(n1,j)); end %计算Is Is{j} = func_Is(N_in,rs,Ws(:,3),Lines(:,j),Time2,dt,tpre(n1,j)); %计算u Um(j,:) = func_um(N_in,Ws(:,3),Rm,Id,Is{j},rm,Time2,dt,Lines(:,j),tpre(n1,j),vth); end UmC = [UmC,Um];end figure;plot(1:Time2*STIME,UmC(1,:),'r');hold onplot(1:Time2*STIME,UmC(2,:),'g');hold onplot(1:Time2*STIME,UmC(3,:),'b');hold onplot(1:Time2*STIME,UmC(4,:),'c');hold offlegend('Neuron1','Neuron2','Neuron3','Neuron4');axis([1,Time2*STIME,0,30]);clear Id Is Um w%D测试%D测试UmD = [];for ij = 1:STIME ij for j = 1:4 ind = 0; ind = ind + 1; %计算Id for n1 = 1:N_in Id{n1} = func_Id(Rd(n1),rd(n1),Ws(n1,4),Lines(n1,j),Time2,dt,tpre(n1,j)); end %计算Is Is{j} = func_Is(N_in,rs,Ws(:,4),Lines(:,j),Time2,dt,tpre(n1,j)); %计算u Um(j,:) = func_um(N_in,Ws(:,4),Rm,Id,Is{j},rm,Time2,dt,Lines(:,j),tpre(n1,j),vth); end UmD = [UmD,Um];end figure;plot(1:Time2*STIME,UmD(1,:),'r');hold onplot(1:Time2*STIME,UmD(2,:),'g');hold onplot(1:Time2*STIME,UmD(3,:),'b');hold onplot(1:Time2*STIME,UmD(4,:),'c');hold offlegend('Neuron1','Neuron2','Neuron3','Neuron4');axis([1,Time2*STIME,0,30]);clear Id Is Um w%连续码流测试%连续码流测试Umss = [];for ij = 1:STIME ij if ij>=1 &ij <= 2 W = Ws(:,3); end if ij>=3 &ij <= 5 W = Ws(:,4); end if ij>=6 &ij <= 8 W = Ws(:,1); end if ij>=9 &ij <= 12 W = Ws(:,3); end if ij>=13 &ij <= 15 W = Ws(:,1); end if ij>=16 &ij <= 18 W = Ws(:,2); end if ij>=19 &ij <= 21 W = Ws(:,3); end if ij>=22 &ij <= 24 W = Ws(:,4); end for j = 1:4 ind = 0; ind = ind + 1; %计算Id for n1 = 1:N_in Id{n1} = func_Id(Rd(n1),rd(n1),W(n1),Lines(n1,j),Time2,dt,tpre(n1,j)); end %计算Is Is{j} = func_Is(N_in,rs,W,Lines(:,j),Time2,dt,tpre(n1,j)); %计算u Um(j,:) = func_um(N_in,W,Rm,Id,Is{j},rm,Time2,dt,Lines(:,j),tpre(n1,j),vth); end Umss = [Umss,Um];end figure;plot(1:Time2*STIME,Umss(1,:),'r');hold onplot(1:Time2*STIME,Umss(2,:),'g');hold onplot(1:Time2*STIME,Umss(3,:),'b');hold onplot(1:Time2*STIME,Umss(4,:),'c');hold offlegend('Neuron1','Neuron2','Neuron3','Neuron4');axis([1,Time2*STIME,0,30]);clear Id Is Um w %%%Fig.5.Weight distributionfigure;subplot(121);bar3(w0(1:15,:),0.8,'r');hold onbar3(w0(1:12,:),0.8,'y');hold onbar3(w0(1:9,:) ,0.8,'g');hold onbar3(w0(1:6,:) ,0.8,'c');hold onbar3(w0(1:3,:) ,0.8,'b');hold onxlabel('Output Neruon');ylabel('Input Neruon');zlabel('Weight');title('Before training');axis([0,5,0,16,0,1.3]);view([-126,36]);subplot(122);bar3(Ws(1:15,:),0.8,'r');hold onbar3(Ws(1:12,:),0.8,'y');hold onbar3(Ws(1:9,:) ,0.8,'g');hold onbar3(Ws(1:6,:) ,0.8,'c');hold onbar3(Ws(1:3,:) ,0.8,'b');hold onxlabel('Output Neruon');ylabel('Input Neruon');zlabel('Weight');title('After training');axis([0,5,0,16,0,1.3]);view([-126,36]);1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.270.271.272.273.274.275.276.277.278.279.280.281.282.283.284.285.286.287.288.289.290.291.292.293.294.295.296.297.298.299.300.301.302.303.304.305.306.307.308.309.310.311.312.313.314.315.316.317.318.319.320.321.322.323.324.325.326.327.328.329.330.331.332.333.334.335.336.337.338.339.340.341.342.343.344.345.346.347.348.349.350.351.352.353.354.355.356.357.358.359.
将SNN进行仿真,并得到类似论文中的仿真效果,具体的仿真结果如下图所示:
上述就是实际的仿真效果图。
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删