How to fix error "Model parameter must be a string" in Run a Neural network sample Code
Show older comments
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 Comments
Greg Heath
on 18 Oct 2017
size(input) = [ I N ] = [ 9 N ]
size(target) = [ O N ] = [ 2 N ]
Ntrneq = 0.6*O*N ~ 1.2*N
1. What is N ?
2. What versions of MATLAB and NN Toolbox do you have?
---- Using NEWFF suggests your version of NNToolbox is obsolete
---- This can be verified using the doc and help commands
3. Why are you using 2 hidden layers??? One is sufficient.
4. PURELIN IS WORTHLESS IN HIDDEN LAYERS! Only use purelin
as the UNSPECIFIED default in the output layer of a regression net!
5. Why not use the default TRAINLM?
6. Assign nondefault subset division ratios BEFORE training!
7. Evalopt is dimension dependent. Better to use a fraction (e.g., <= 0.010)
of the average target variance.
Hope this helps.
Greg
Greg Heath
on 19 Nov 2017
COMMENT BY THE AUTHOR ERRONEOUSLY PLACED IN AN ANSWER BOX:
by seyed hosein alhoseiny on 1 Sep 2017
hello this sample code is designed for Estimation of Petrophysical properties of oil Reservoir rock using Logs Values as Input data (9 input variables)
Greg Heath
on 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:
seyed hosein alhoseiny about 18 hours ago hello I wrote full Program in this post. thank you...
Rafik
on 22 Feb 2020
could you please help ? Thanks sayed hocein el hoceiny
Rafik
on 22 Feb 2020
Error is: error using corrplot (line 119)
the value of X is invalidv . observed data is empty.
error corrplot (data)
Answers (1)
Rafik
on 16 Oct 2017
0 votes
Please I need the full program could you please share It ? Thanks
3 Comments
seyed hosein alhoseiny
on 18 Nov 2017
Greg Heath
on 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...
Rafik
on 22 Feb 2020
Thank you very much
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!