How to fix error "Model parameter must be a string" in Run a Neural network sample Code
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hello in this sample code this error " Model parameter must be a string" occurs when run section for plot regression graphs for 3 data type (train, validation,test)
codes :
data=xlsread('sarvak_normalized.xlsx'); % Input File
corrplot(data)
input=[1:9]; % Input Layer
p=data(:,input);
output=[10:11]; % Output Layer
t=data(:,output);
p=p'; t=t'; % Transposing Matrices
% t=log(t);
% Defining Validation Dataset
trainRatio1=.6;
valRatio1=.2;
testRatio1=.2;
%%Network Definition
nnn1=5; % First Number of Neurons in Hidden Layer
nnnj=5; % Jump in Number of Neurons in Hidden Layer
nnnf=100; % Last Number of Neurons in Hidden Layer
% net1.trainparam.lr=0.1;
% net1.trainParam.epochs=500;
% Training Network
it=20; % Max Number of Iteration
ii=0;
netopt{:}=1:nnnf;
for nnn=nnn1:nnnj:nnnf
ii=ii+1; nnn
net1=newff(p,t,[nnn nnn],{'purelin','purelin'},'traingd'); % For more functions see: 'Function Reference' in 'Neural Network Toolbox' of Matlab help
evalopt(ii)=1000;
for i=1:it
[net1,tr,y,et]=train(net1,p,t); % Training
net1.divideParam.trainRatio=trainRatio1;
net1.divideParam.valRatio=valRatio1;
net1.divideParam.testRatio=testRatio1;
estval=sim(net1,p(:,tr.valInd));
eval=mse(estval-t(:,tr.valInd));
if eval<evalopt(ii)
netopt{(ii)}=net1; tropt(ii)=tr; evalopt(ii)=eval;
end
end
end
plot(nnn1:nnnj:nnnf,evalopt)
%%Output
%clear
%load('run1');
nn=17
ptrain=p(:,tropt(nn).trainInd); ttrain=t(:,tropt(nn).trainInd); esttrain=sim(netopt{nn},ptrain);
ptest=p(:,tropt(nn).testInd); ttest=t(:,tropt(nn).testInd); esttest=sim(netopt{nn},ptest);
pval=p(:,tropt(nn).valInd); tval=t(:,tropt(nn).valInd); estval=sim(netopt{nn},pval);
estwhole=sim(netopt{nn},p);
% ttrain=exp(ttrain); ttest=exp(ttest); tval=exp(tval); t=exp(t);
% esttrain=exp(esttrain); esttest=exp(esttest); estval=exp(estval); estwhole=exp(estwhole);
plotregression(ttrain,esttrain,'Train',tval,estval,'Validation',...
ttest,esttest,'Test',t,estwhole,'Whole Data');
5 Kommentare
Rafik
am 22 Feb. 2020
Error is: error using corrplot (line 119)
the value of X is invalidv . observed data is empty.
error corrplot (data)
Antworten (1)
Rafik
am 16 Okt. 2017
Please I need the full program could you please share It ? Thanks
3 Kommentare
Greg Heath
am 19 Nov. 2017
ANOTHER COMMENT ERRONEOUSLY PLACED IN AN ANSWER BOX!
by Rafik on 16 Oct 2017
Please I need the full program could you please share It ? Thanks
THE RESPONSE BY SEYID (above)
hello I wrote full Program in this post. thank you...
Siehe auch
Kategorien
Mehr zu Define Shallow Neural Network Architectures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!