Example from patternnet docs fails in Neural Network Toolbox Version 10.0 (R2017a)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Terrance Nearey
le 16 Sep 2017
Modifié(e) : Terrance Nearey
le 18 Sep 2017
I'd remove this post now if I could. Tracking down the function name conflict has been difficult. The code attached to this answer https://www.mathworks.com/matlabcentral/answers/100197-is-there-any-way-to-list-all-shadowed-files-in-the-matlab-path-in-matlab-7-8-2009a#answer_109545 got me started.
Original problem: Trying to run the example from
help paternnet
but get:
Index exceeds matrix dimensions.
Error in initnw>initialize_layer (line 168)
range(inputStart(j):inputStop(j),:) = temp2((inputStart(j):inputStop(j))-inputStart(j)+1,:);
Complete code (revised):
% NNTest from help patternnet
clear all
clc
dbstop if error
[x,t] = iris_dataset;
net = patternnet(10);
net = train(net,x,t);
Complete output:
Index exceeds matrix dimensions.
Error in initnw>initialize_layer (line 168)
range(inputStart(j):inputStop(j),:) = temp2((inputStart(j):inputStop(j))-inputStart(j)+1,:);
Error in initnw (line 93)
out1 = initialize_layer(in1,in2);
Error in initlay>initialize_network (line 147)
net = feval(initFcn,net,i);
Error in initlay (line 89)
out1 = initialize_network(in1);
Error in network/init (line 32)
net = feval(initFcn,net);
Error in network/configure (line 243)
net = init(net);
Error in nntraining.config (line 116)
net = configure(network(net),X,T);
Error in nntraining.setup>setupPerWorker (line 68)
[net,X,Xi,Ai,T,EW,Q,TS,err] = nntraining.config(net,X,Xi,Ai,T,EW,configNetEnable);
Error in nntraining.setup (line 43)
[net,data,tr,err] = setupPerWorker(net,trainFcn,X,Xi,Ai,T,EW,enableConfigure);
Error in network/train (line 335)
[net,data,tr,err] = nntraining.setup(net,net.trainFcn,X,Xi,Ai,T,EW,enableConfigure,isComposite);
Error in NNTest (line 7)
net = train(net,x,t);
Version information:
MATLAB Version: 9.2.0.556344 (R2017a)
Neural Network Toolbox Version 10.0 (R2017a)
OS info:
Mac OS X 10.11.6 (15G1611)
2 commentaires
Walter Roberson
le 17 Sep 2017
The code
[x,t] = iris_dataset;
net = patternnet(10);
net = train(net,x,t);
view(net)
y = net(x);
perf = perform(net,t,y);
classes = vec2ind(y);
works for me in R2017a.
Réponse acceptée
Greg Heath
le 17 Sep 2017
clear all
clc
%stoperr
%Undefined function or variable 'stoperr'.
% [x,t] = iris_dataset;
% net = patternnet(10);
% net = train(net,x,t);
% view(net)
% y = net(x);
% perf = perform(net,t,y) %0.0302
% classes = vec2ind(y);
% end
% Error: Illegal use of reserved keyword "end".
close all, clear all, clc
[ x,t ] = iris_dataset;
[ I N ] = size(x)% [ 4 150 ]
[ O N ] = size(t)% [ 3 150]
truclass = vec2ind(t); % 1 to 3
MSEref = mse(t-mean(t,2)) % 0.2222
rng(0), Ntrials = 10
for h = 1:10 % No. of hidden nodes
net = patternnet(h);
for n = 1:Ntrials
net = configure(net,x,t);
[net tr y e ] = train(net,x,t);
% y = net(x); e = t-y;
NMSE(h,n) = mse(e)/MSEref;
predclass = vec2ind(y);
PCTERR(h,n) = 100*mean(predclass~=truclass);
end
end
PCTERR = PCTERR
% Columns 1 through 5
%
% 2.6667 2.0000 2.0000 3.3333 2.6667
% 2.0000 1.3333 2.6667 2.0000 2.0000
% 2.0000 2.0000 4.0000 0.6667 2.6667
% 1.3333 4.0000 4.0000 1.3333 1.3333
% 2.0000 3.3333 3.3333 2.6667 1.3333
% 3.3333 2.0000 2.6667 1.3333 2.0000
% 2.6667 4.6667 3.3333 4.0000 3.3333
% 1.3333 1.3333 2.6667 2.0000 4.6667
% 2.6667 0.6667 2.6667 1.3333 1.3333
% 2.0000 1.3333 1.3333 1.3333 4.0000
%
% Columns 6 through 10
%
% 3.3333 2.6667 2.0000 2.6667 2.0000
% 1.3333 68.6667 1.3333 2.6667 6.0000
% 1.3333 2.6667 2.6667 1.3333 1.3333
% 1.3333 3.3333 3.3333 4.0000 2.6667
% 3.3333 2.0000 1.3333 2.0000 1.3333
% 1.3333 1.3333 1.3333 2.6667 1.3333
% 2.0000 2.6667 2.6667 2.6667 1.3333
% 2.0000 1.3333 1.3333 2.0000 1.3333
% 3.3333 4.0000 3.3333 2.0000 2.0000
% 1.3333 1.3333 2.0000 2.6667 1.3333
Hope this helps,
Thank you for formally accepting my answer
Greg
2 commentaires
Greg Heath
le 17 Sep 2017
P.S.
Any one interested in calculating the correlation coefficient between the 100 samples of NMSE and PCTERR?
Plus de réponses (1)
Greg Heath
le 17 Sep 2017
Modifié(e) : Greg Heath
le 17 Sep 2017
I get two error messages:
clear all clc
%stoperr
%Undefined function or variable 'stoperr'.
[x,t] = iris_dataset;
net = patternnet(10);
net = train(net,x,t);
view(net)
y = net(x);
perf = perform(net,t,y);
classes = vec2ind(y);
% end
% Error: Illegal use of reserved keyword "end".
Hope this helps,
Greg
0 commentaires
Voir également
Catégories
En savoir plus sur Modeling and Prediction with NARX and Time-Delay Networks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!