Error while using newpnn for classification and then fminunc for optimization.
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I am using newpnn for classification, where i have input vector X, target vector Tc and output vector Yc. I need to optimize the newpnn function by varying the spread value in it to get the maximum correct classifications.(newpnn is an inbuilt function and has spread in its code for output estimation). Here is the code i wrote for the same:
T=ind2vec(Tc);
net=newpnn(X,T,spread);
Y= net(X);
Yc=vec2ind(Y);
Penalty=@(spread, Tc)((Tc-Yc).^2);
out= Penalty(spread, Tc);
spread0= 1;
[spread, fval,exitflag,output]=fminunc(out,1);
On running the script, I am getting this error:
Error using optimfcnchk (line 288)
FUN must be a function, a valid string expression, or an inline function object.
Error in fminunc (line 240)
funfcn = optimfcnchk(FUN,'fminunc',length(varargin),funValCheck,gradflag,hessflag);
Error in join (line 20)
[spread, fval,exitflag,output]=fminunc(out,1);
Any help/guidance/suggestion would be appreciated.
2 Comments
by varying the spread value in it to get the maximum correct classifications.
You cannot use fminunc to optimize an integer-valued function. fminunc is designed for functions f(x) that vary continuously (and differentiably) as a function of a continuously varying vector x.
Ritesh Kalbande
on 20 Feb 2015
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!