I am beginner in ANN. I am trying to train an ANN for prediction nanofibers diameters using Matlab.

I tried to write code for that but i think there is some thing wrong.

May you help me writting the true codes?

I've attached the data and here is the tow kind of codes i tried to write :

- the first using k-fold cross validation

- the second using normalization function and dividevec function

the first:

M=xlsread('ANN1.xls','sheet1','B2:F19');

pp=M(1:18,1:4);

p=pp';

tt=M(:,5);

t=tt';

net=newff(minmax(p),t,[12,7],{'tansig','tansig','purelin'},'traingd');

cv=cvpartition (6,'kfold',6);

c=crossvalind('kfold',6,6);

for i=1:6

testidx=(c==i);

trainidx=~testidx;

trind=find(trainidx);

tsind=find(testidx);

net.trainparam.epochs=500;

net.trainparam.goal=0.0001;

net.trainparam.lr=0.1;

net1=train(net,p,t);

O=sim(net1,p);

plot(p,t,'black-',p,O,'black+');

end

-the second:

M=xlsread('ANN1.xls','sheet1','B2:F19');

pp=M(1:18,1:4);

p=pp';

tt=M(:,5);

t=tt';

plot(p,t);

[pn,ps]=mapminmax(p);

[tn,ts]=mapminmax(t);

[tarinv,val,test]=dividevec(pn,tn,0.2,0.15);

net=newff(minmax(pn),tn,[12,7,1],{'tansig','tansig','purelin'},'traingd');

init(net);

net.trainparam.epochs=500;

net.trainparam.goal=0.0001;

net.trainparam.lr=0.1;

[net,tr]=train(net,trainv.P,tarinv.T,[],[],val,test);

an=sim(net,pn);

a=mapminmax('reverse',an,ts)

plot(p,t,'black-',p,a,'black+');

More Ghazal Tuhmaz's questions See All
Similar questions and discussions