performance_of_three_class_problem.m
来自「1.感知器对于线型可分问题的收敛性证明 2.用感知器对线型可分得问题进行分类 」· M 代码 · 共 34 行
M
34 行
%--------------------------------------------------------%
% Performance of Problem 2:Three Class Problem %
%--------------------------------------------------------%
%感知器神经元的输入/目标向量
P=[1 0 3 2 2 1 -1 -2 -1;
1 2 1 -1 0 -2 2 1 1];
T=[ 0 0 0 0 0 0 1 1 1;
0 0 0 1 1 1 0 0 0];
%绘制感知器神经元的输入/目标向量
plotpv(P,T);
%建立一个感知器神经网络
net=newp([-1.5 1;-1.5 1],2);
%感知器在训练之前的输出
Y=sim(net,P);
plot(P,T,P,Y,'o');
%对感知器训练20次
net.trainParam.epochs=20;
net=train(net,P,T);
%感知器在训练之后的输出
Y=sim(net,P);
%利用平均绝对误差mae计算网络的性能
err4=0.2*mae(Y-T);
figure;
plot(P,T,P,Y,'o');
%-------------------------result-------------------------%
%结果是感知器在被训练6次之后的输出符合要求,平均绝对误差减为0%
%--------------------------------------------------------%
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?