- grnn神经网络
今天在做classification的作业时,用newrbe会报错,因为无法求解w2b2。
故使用grnn神经网络,其原理与rbf神经网络类似,但在第二层中直接赋予w2。无需求解。
temp=randperm(106);
p_train=matrix(:,temp(1:95));
t_train=label(:,temp(1:95));
p_test=matrix(:,temp(96:106));
t_test=label(:,temp(96:106));
net=newgrnn(p_train,t_train);
t_sim_grnn=sim(net,p_test);
T_sim_grnn=round(t_sim_grnn);
plot(1:11,t_test,'o',1:11,T_sim_grnn,'*')
%法一
temp=randperm(106);
p_train=matrix(:,temp(1:95));
t_train=label(:,temp(1:95));
p_test=matrix(:,temp(96:106));
t_test=label(:,temp(96:106));
Tc_train = ind2vec(t_train);
net=newpnn(p_train,Tc_train);
t_sim_pnn=sim(net,p_test);
T_sim_pnn =vec2ind(t_sim_pnn)
plot(1:11,t_test,'o',1:11,T_sim_pnn,'*')
%法2pnn方法,数据拟合好差。。
temp1=randperm(21);matrix1=matrix(:,temp1(1:19));label1=label(:,temp1(1:19));
temp2=randperm(15);matrix2=matrix(:,21+temp2(1:13));label2=label(:,21+temp2(1:13));
temp3=randperm(18);matrix3=matrix(:,36+temp3(1:16));label3=label(:,36+temp3(1:16));
temp4=randperm(16);matrix4=matrix(:,54+temp4(1:14));label4=label(:,54+temp4(1:14));
temp5=randperm(14);matrix5=matrix(:,70+temp5(1:12));label5=label(:,70+temp5(1:12));
temp6=randperm(22);matrix6=matrix(:,84+temp6(1:20));label6=label(:,84+temp6(1:20));
p_train=[matrix1 matrix2 matrix3 matrix4 matrix5 matrix6];
t_train=[label1 label2 label3 label4 label5 label6];
net=newgrnn(p_train,t_train);
t_sim_grnn=sim(net,matrix);
T_sim_grnn=round(t_sim_grnn);
plot(1:106,T_sim_grnn,'o',1:106,label,'*')
%%法三样本选取方法不同
版权声明:本文为weixin_42882826原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。