开发者

How can I modify my code to show training and testing graphs in MATLAB?

开发者 https://www.devze.com 2023-03-01 22:33 出处:网络
I have this code about neural networks. How can I modify this code so that it can show the training and testing graphs?

I have this code about neural networks. How can I modify this code so that it can show the training and testing graphs?

%~~~~~~~~~~~[L1 L2 1];first hidden layer,second & output layer~~~~~
layer = [11 15 1];
myepochs = 30;
attemption = 1; %i;
mytfn = {'tansig' 'tansig' 'purelin'};

%~~~~~~load data~~~~~~~~~~~~~~~~~~~~~~~
m = xlsread('C:\Documents and Settings\winxp\My Documents\MATLAB\MATLAB_DATA\datatrain.csv');   

%~~~~~~convert the data in Ma开发者_运维技巧trix form~~~~
[row,col] = size(m);          

P = m(1:row,1:10)';

T1 = m(1:row, col)';   % target data for training...last column

net = newff([minmax(P)],layer,mytfn,'trainlm');  %nnet 
net.trainParam.epochs = myepochs;   % how many time newff will repeat the training
net.trainParam.showWindow = true;
net.trainParam.showCommandLine = true;
net = train(net,P,T1);  % start training newff with input P and target T1

Y = sim(net,P);   % training

save 'net114' net;

Also, is this code correct? I want to calculate the area and the perimeter of an image. But the calculated values show that perimeter is bigger than area which does not make sense, right? Or maybe maybe there's an explanation for that?

BW =~c;
area= bwarea(BW);
area
imshow(BW);

bw2=~c;

pm=bwperim(bw2);
perimeter=bwarea(pm);


You might want to try something like net.trainParam.show = 30 to show the training progress every 30 epochs.

0

精彩评论

暂无评论...
验证码 换一张
取 消