11 篇文章 0 订阅

# 有导师学习神经网络的分类

## 广义回归神经网络（GRNN）

    1.GRNN结构
GRNN最早是由Specht提出的,是RBF神经网络的一个分支,是一种基于非线性回归理

GRNN的结构如图所示，一般由输人层、隐含层和输出层组成。输人层仅将样本



## 概率神经网络（PNN）

1.PNN结构
PNN是一种前馈型神经网络，由Specht在1989年提出,他采用Parzen 提出的由高斯函

PNN的结构如图所示，与GRNN类似，由输人层、隐含层及输出层组成。与
GRNN不同的是，PNN的输出层采用竞争输出代替线性输出,各神经元只依据Parzen方法来



## 题目及代码

(1）利用GRNN和PNN分别建立鸢尾花种类识别模型,并对模型的性能进行评价。
(2）利用GRNN和PNN分别建立各个属性及属性组合与鸢尾花种类间的识别模型,并

% 有导师学习神经网络的分类 -- 鸢尾花种类识别
clear
clc
% 产生训练集/测试集
Ptrain = [];
ttrain = [];
Ptest = [];
ttest = [];
for i = 1:3
tempinput = features((i-1)*50+1:i*50,:);
tempoutput = classes((i-1)*50+1:i*50,:);
n = randperm(50);
Ptrain = [Ptrain tempinput(n(1:40),:)'];
ttrain = [ttrain tempoutput(n(1:40),:)'];
Ptest = [Ptest tempinput(n(41:50),:)'];
ttest =[ttest tempoutput(n(41:50),:)'];
end
% 建立模型
resultgrnn = [];
resultpnn = [];
timegrnn = [];
timepnn = [];
for i = 1:4
for j = i:4
ptrain = Ptrain(i:j,:);
ptest = Ptest(i:j,:);
t = cputime;
netgrnn = newgrnn(ptrain,ttrain);
tsimgrnn = sim(netgrnn,ptest);
Tsimgrnn = round(tsimgrnn);
t = cputime - t;
timegrnn = [timegrnn t];
resultgrnn = [resultgrnn Tsimgrnn'];
t = cputime;
tctrain = ind2vec(ttrain);
netpnn = newpnn(ptrain,tctrain);
tctest = ind2vec(ttest);
tsimpnn = sim(netpnn,ptest);
Tsimpnn = vec2ind(tsimpnn);
t = cputime - t;
timepnn = [timepnn t];
resultpnn = [resultpnn Tsimpnn'];
end
end
% 性能评价
accuracygrnn = [];
accuracypnn = [];
time = [];
for i = 1:10
accuracy1 = length(find(resultgrnn(:,i)==ttest'))/length(ttest);
accuracy2 = length(find(resultpnn(:,i)==ttest'))/length(ttest);
accuracygrnn = [accuracygrnn accuracy1];
accuracypnn = [accuracypnn accuracy2];
end
result = [ttest' resultgrnn resultpnn];
accuracy = [accuracygrnn;accuracypnn];
time = [timegrnn;timepnn];
% 画图
figure(1)
plot(1:30,ttest,'bo',1:30,resultgrnn(:,4),'r-*',1:30,resultpnn(:,4),'k:^')
grid on
xlabel('测试集样本编号')
ylabel('测试集样本类别')
string = {'测试集预测结果对比（GRNN vs PNN）';['正确率',num2str(accuracygrnn(4)*100),'%(GRNN) vs',num2str(accuracypnn(4)*100),'%(PNN)']};
title(string)
legend('真实值','GRNN预测值','PNN预测值')
figure(2)
plot(1:10,accuracy(1,:),'r-*',1:10,accuracy(2,:),'b:o')
grid on
xlabel('模型编号')
ylabel('测试集正确率')
title('10个模型的测试集正确率对比（GRNN vs PNN）')
legend('GRNN','PNN')
figure(3)
plot(1:10,time(1,:),'r-*',1:10,time(2,:),'b:o')
grid on
xlabel('模型编号')
ylabel('运行时间（s）')
title('10个模型的运行时间对比（GRNN vs PNN）')
legend('GRNN','PNN')


# 无导师学习神经网络的分类

## 竞争神经网络

1. 竞争神经网络结构



## 问题及代码

Nat,K+,Ca2+,Mg’+,Cl-,SO’和HCO,7种离子的含量作为判别因素，试利用竞争神经

% 无导师学习神经网络分类--矿井突水水源判别
clear
clc
% 产生训练集/测试集
attributes = mapminmax(attributes);
ptrain = attributes(:,1:35);
ttrain =classes(:,1:35);
ptest = attributes(:,36:end);
ttest = classes(:,36:end);
% 创建/训练竞争神经网络及仿真测试
net = competlayer(4,0.01,0.01);
net.trainParam.epochs = 500;
net = train(net,ptrain);
tsimcompet1 = net(ptrain);
Tsimcompet1 = vec2ind(tsimcompet1);
tsimcompet2 = net(ptest);
Tsimcompet2 = vec2ind(tsimcompet2);
% 创建SOFM神经网络仿真测试
net = selforgmap([4 4]);
net.trainParam.epochs = 200;
net = train(net,ptrain);
tsimsofm1 = net(ptrain);
Tsimsofm1 = vec2ind(tsimsofm1);
tsimsofm2 = net(ptest);
Tsimsofm2 = vec2ind(tsimsofm2);
% 性能评价
resultcompet1 = [ttrain' Tsimcompet1'];
resultcompet2 = [ttest' Tsimcompet2'];
resultsofm1 = [ttrain' Tsimsofm1'];
resultsofm2 = [ttest' Tsimsofm2'];
`

• 1
点赞
• 0
评论
• 2
收藏
• 一键三连
• 扫一扫，分享海报

06-11 92

06-22 3641
01-25 385
10-14 4271
08-21 4001
04-11 808
08-20 1616
03-07 1160
10-10 209
06-25 2万+
01-16 108