[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix |
Date: |
Tue, 29 Oct 2019 17:34:03 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko |
Follow-up Comment #10, bug #57113 (project octave):
fminunc is implemented in an m-file so experiments are pretty easy to make.
Note this code at the end of the function:
## When info != 1, recalculate the gradient and Hessian using the final x.
if (nargout > 4 && (info == -1 || info == 2 || info == 3))
grad0 = grad;
if (has_grad)
[fval, grad] = fcn (reshape (x, xsz));
grad = grad(:);
else
grad = __fdjac__ (fcn, reshape (x, xsz), fval, typicalx, cdif)(:);
endif
if (nargout > 5)
## Use the damped BFGS formula.
y = grad - grad0;
sBs = sumsq (w);
Bs = hesr' * w;
sy = y' * s;
theta = 0.8 / max (1 - sy / sBs, 0.8);
r = theta * y + (1-theta) * Bs;
hesr = cholupdate (hesr, r / sqrt (s' * r), "+");
hesr = cholupdate (hesr, Bs / sqrt (sBs), "-");
endif
## Return the gradient in the same shape as x
grad = reshape (grad, xsz);
endif
## Restore original shapes.
x = reshape (x, xsz);
if (nargout > 3)
output.iterations = niter;
output.successful = nsuciter;
output.funcCount = nfev;
endif
if (nargout > 5)
hess = hesr'*hesr;
endif
So there is specific code that calculates the Hessian at the final value of x.
One issue, is that the gradient and Hessian aren't calculated when info == -3
which is also an error condition. Maybe the test condition should be updated
to "info != 1".
Second, the calculation uses the damped BFGS formula and the damping will mean
that the Hessian only slowly changes over to the true value. It seems like
this would be the location to insert a different Hessian calculation
algorithm.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57113>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, anonymous, 2019/10/24
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Kai Torben Ohlhus, 2019/10/24
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Giuseppe, 2019/10/25
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Markus Mützel, 2019/10/28
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Nir Krakauer, 2019/10/28
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Giuseppe, 2019/10/28
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Giuseppe, 2019/10/28
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Rik, 2019/10/29
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Rik, 2019/10/29
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix, Giuseppe, 2019/10/29
- [Octave-bug-tracker] [bug #57113] fminunc return wrong Hessian matrix,
Rik <=