how do i optimize weights of neural network using GA in MATLAB(need codes to achieve that), again how do i call this function that optimzes the neural network weights in GA GUI so i can work with it from the interface
조회 수: 1 (최근 30일)
이전 댓글 표시
i need to train a neural network(a feedforward network and also a narx network) using genetic algorithm.and i need to do this by using GA to search for weights that will make the network learn very well.
댓글 수: 2
Alisina Gharjestani
2017년 12월 6일
Hi,have you developed a code for optimizing a narx network by using genetic algorithm?
Greg Heath
2017년 12월 7일
What have you found when you searched the NEWSGROUP and ANSWERS using
genetic narx
and
genetic narxnet
?
채택된 답변
Greg Heath
2015년 5월 20일
When
[ I N ] = size(input)
[ O N ] = size(target)
MSE00 = mean(var(target',1))% Reference MSE
The number of available training equations is
Ntrneq = N*O
For an I-H-O node topology the number of unknown weights is
Nw = (I+1)*H+(H+1)*O = (I+O+1)*H+1
Obviously,
1. The "3" in the GA input is replaced by I+O+1
2. The normalized mse calculation is
NMSE = mean((target(:)-output(:)).^2)/MSE00
Of course there will be more complications if the performance measure has to be decomposed into class and trn/val/tst subsets.
Hope this helps.
Greg
댓글 수: 2
Greg Heath
2015년 5월 24일
The first two equations yield the sizes of the input and target matrices. I and O are the dimensions of the input and target vectors, respectively. N is the total number of examples.
추가 답변 (3개)
Gurvinder Singh
2016년 5월 6일
this code is valid for only one input. if i provide more than one input the code gives an error;
Index exceeds matrix dimensions.
Error in separatewb (line 34) iw{i,j} = reshape(wb(hints.iwInd{i,j}),...
Error in setwb (line 23) [b,IW,LW] = separatewb(net,wb,hints);
Error in mse_test (line 9) net = setwb(net, x);
Error in Untitled2>@(x)mse_test(x,net,inputs,targets)
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11) fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in makeState (line 47) firstMemberScore = FitnessFcn(state.Population(initScoreProvided+1,:));
Error in gaunc (line 40) state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 371) [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Error in Untitled2 (line 24) [x_ga_opt, err_ga] = ga(h, 3*n+1, ga_opts);
Caused by: Failure in initial user-supplied fitness function evaluation. GA cannot continue.
how to run it for more than one input???
댓글 수: 0
Greg Heath
2016년 5월 6일
I have posted a new MIMO GA code in the NEWSGROUP.
Hope this helps.
Thank you for formally accepting my answer
Greg
댓글 수: 4
Harshith Bhat
2017년 2월 28일
These are the errors Error in @(x)mse_test(x,net,inputs,targets)
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11) fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in makeState (line 47) firstMemberScore = FitnessFcn(state.Population(initScoreProvided+1,:));
Error in gaunc (line 40) state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 356) [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Error in experiment (line 30) [x_ga_opt, err_ga] = ga(h, 3*n+1, ga_opts);
Caused by: Failure in initial user-supplied fitness function evaluation. GA cannot continue.
>>
Terry Chen
2020년 11월 10일
Dear Greg,
where can get this link : http://www.mathworks.com/matlabcentral/newsreader/view_thread/344888#944621
It seems disappear.
Terry
Greg Heath
2015년 5월 19일
Unfortunately, I lost my own NN GA code to a computer crash many years ago. I have not attempted to replace it. However, I have searched the NEWSGROUP and ANSWERS for examples combining the NN and OPTIMIZATION Toolboxes.
There is a post by the MATLAB SUPPORT TEAM that outlines the procedure for a SISO problem. However, I have not been successful in using it.
There is a more recent post by a user that successfully yields an answer called the Pareto Front. I haven't learned enough to go beyond that.
Try searching the NEWSGROUP and ANSWERS using
mathworks support team neural genetic
and
mathworks support team neural GA
Then
neural genetic pareto
and
neural GA pareto
and finally, just
neural genetic
and
neural GA
If you are successful, please bless us with your knowledge.
Hope this helps.
Thank you if you think this answer is worth a formal acceptance
Greg
댓글 수: 2
Greg Heath
2016년 3월 16일
inputs =1:10;
targets = cos(inputs.^2)
is a RIDICULOUS example:
plot(inputs,targets)
targets = cos(inputs).^2
is no better.
The problem is in the inputs spacing. 16 points per period should do the trick.
Hope this helps.
Greg
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!