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

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 日

1 投票

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 件のコメント

The Mathworks code looks to me to have problems, not something you can fix by reinstalling.
Change your line
[Yval,Pfval,Afval,Eval,perfval] = sim(net,valInp,[],[],valT);
To
[Yval,Pfval,Afval,Eval] = sim(net,valInp,[],[],valT);
Bunny
Bunny 2016 年 11 月 24 日
Thank you sir, I got my required output. :)
Bunny
Bunny 2016 年 11 月 30 日
Sir, I want to execute the output with each epoch (in figures). and I want to execute the orthogonal projections for training set and validation set. What commands i have to use to get these outputs?
Walter Roberson
Walter Roberson 2016 年 11 月 30 日
Which MATLAB release are you using? newff() is obsolete now so I want to be sure that I look at documentation for your particular release.
Bunny
Bunny 2016 年 11 月 30 日
編集済み: Bunny 2016 年 11 月 30 日
MATLAB R2014a
Walter Roberson
Walter Roberson 2016 年 11 月 30 日
newff() was replaced in R2010b. It was no longer documented after R2010a, so I cannot describe how it is intended to work in R2014a.
You should rewrite your code to use feedforwardnet() and another advances that came with R2010b.
Bunny
Bunny 2016 年 12 月 1 日
What about orthogonal projection outputs? is it related with this newff()?
Walter Roberson
Walter Roberson 2016 年 12 月 1 日
I would need to dig into the code to figure out if it is possible at all. I am reluctant to do that for code that was replaced over 6 years ago.
Bunny
Bunny 2016 年 12 月 1 日
編集済み: Bunny 2016 年 12 月 1 日
I got this code from here--> Classification of Iris data set but i made some modifications in loading the IRIS dataset.
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 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2016 年 11 月 23 日

コメント済み:

2016 年 12 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by