Matlab code for Classification of IRIS data using MLP (Multi Layer Perceptron)
3 次查看(过去 30 天)
显示 更早的评论
I'm trying to execute the following matlab code but I'm getting error about Time steps (TS) which is presented in network/sim.m (predefined matlab code). I couldn't edit this sim.m.
close all; clear; clc
%%load divided input data set
load fisheriris
% coding (+1/-1) of 3 classes
a = [-1 -1 +1]';
b = [-1 +1 -1]';
c = [+1 -1 -1]';
% define training inputs
rand_ind = randperm(50);
trainSeto = meas(rand_ind(1:35),:);
trainSeto=trainSeto';
trainVers = meas(50 + rand_ind(1:35),:);
trainVers=trainVers';
trainVirg = meas(100 + rand_ind(1:35),:);
trainVirg=trainVirg';
trainInp = [trainSeto trainVers trainVirg];
% define targets
tmp1 = repmat(a,1,length(trainSeto));
tmp2 = repmat(b,1,length(trainVers));
tmp3 = repmat(c,1,length(trainVirg));
T = [tmp1 tmp2 tmp3];
%%network training
trainCor = zeros(10,10);
valCor = zeros(10,10);
Xn = zeros(1,10);
Yn = zeros(1,10) ;
for k = 1:10 ,
Yn(1,k) = k;
for n = 1:10,
Xn(1,n) = n;
net = newff(trainInp,T,[k n],{},'trainbfg');
net = init(net);
net.divideParam.trainRatio = 1;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 0;
net.trainParam.show = NaN;
net.trainParam.max_fail = 2;
rand_ind = randperm(50);
valSeto = meas(rand_ind(1:20),:);
valSeto= valSeto';
valVers = meas(50 + rand_ind(1:20),:);
valVers=valVers';
valVirg = meas(100 + rand_ind(1:20),:);
valVirg=valVirg';
valInp = [valSeto valVers valVirg];
VV.P = valInp;
tmp1 = repmat(a,1,length(valSeto));
tmp2 = repmat(b,1,length(valVers));
tmp3 = repmat(c,1,length(valVirg));
valT = [tmp1 tmp2 tmp3];
net = train(net,trainInp,T,[],[],VV);%,TV);
Y = sim(net,trainInp);
[Yval,Pfval,Afval,Eval,perfval] = sim(net,valInp,[],[],valT);
Error of my matlab code:

0 个评论
采纳的回答
Walter Roberson
2016-11-23
At the moment it appears to me to be a bug in the sim code. It looks to me as if you could get around the bug by not requesting the 5th output of sim()
11 个评论
Walter Roberson
2016-12-1
I mean that I would need to dig into the Mathworks neural network code. I would rather not do that for the old code. You should re-write using feedforwardnet() instead of newff() and make other such appropriate changes.
Time spent investigating the inner working of code that was replaced six years ago would be a waste for me; I would have no further use for any information gained. Time spent investigating the current Mathworks code has the potential to be of use in future.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!