i trying implement regularized logistic regression algorithm, using fminunc()
function in octave minimising cost function. advised, plot cost function function of iterations of fminunc()
function. function call looks follows -
[theta, j, exit_flag] = ... fminunc(@(t)(costfunctionreg(t, x, y, lambda)), initial_theta, options);
with
options = optimset('gradobj', 'on', 'maxiter', 400, 'outputfcn',@showj_history);
[showj-history
intended output function; hope have set options
parameter correctly].
but, can't find sources on internet highlighting how write output function, specifically, parameters passed fminunc()
, returns (if in particular required fminunc()
).
could please mention helpful links or assist me in writing output function.
i think can refer the source code. consider example:
1; function f = __rosenb (x) # http://en.wikipedia.org/wiki/rosenbrock_function n = length (x); f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2); endfunction function bstop = showj_history(x, optv, state) plot(optv.iter, optv.fval, 'x') # setting bstop true stops optimization bstop = false; endfunction opt = optimset('outputfcn', @showj_history); figure() xlabel("iteration") ylabel("cost function") hold on [x, fval, info, out] = fminunc (@__rosenb, [5, -5], opt);
Comments
Post a Comment