Matlab code for Classification of IRIS data using MLP (Multi Layer Perceptron)
Ältere Kommentare anzeigen
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:

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!