Matlab code for Classification of IRIS data using MLP (Multi Layer Perceptron)

조회 수: 2 (최근 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:

채택된 답변

Walter Roberson
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
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.
Bunny
Bunny 2016년 12월 2일
Okay I will rewrite this code. Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by