How to fix error "Model parameter must be a string" in Run a Neural network sample Code
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rafik
2020-2-22
Error is: error using corrplot (line 119)
the value of X is invalidv . observed data is empty.
error corrplot (data)
回答(1 个)
Rafik
2017-10-16
Please I need the full program could you please share It ? Thanks
3 个评论
Greg Heath
2017-11-19
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...
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!