Thread Subject: Have fminunc show the gradient?

Subject: Have fminunc show the gradient?

From: David Doria

Date: 12 Aug, 2008 18:54:02

Message: 1 of 5

I have been looking through the help for a long while and
cant seem to find how to make fminunc display the gradient
at each iteration - maybe I am just missing it??

Thanks,

Dave

Subject: Have fminunc show the gradient?

From: Marcelo Marazzi

Date: 14 Aug, 2008 20:58:02

Message: 2 of 5

Dave,

See the output function in the doc, which provides a number of
optimization quantities at each iteration, e.g. the gradient in
fminunc:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/f19175.html#f11022

-Marcelo

David Doria wrote:
> I have been looking through the help for a long while and
> cant seem to find how to make fminunc display the gradient
> at each iteration - maybe I am just missing it??
>
> Thanks,
>
> Dave

Subject: Have fminunc show the gradient?

From: David Doria

Date: 14 Aug, 2008 21:34:01

Message: 3 of 5

Ah, great - that does the trick - although I was expecting
something a bit more built in.. so I don't have to write my
own output function, I could just toggle what the built in
output function outputs!

Thanks!

Dave

Subject: Have fminunc show the gradient?

From: David Doria

Date: 15 Aug, 2008 13:06:02

Message: 4 of 5

Ok, now I would like to see the hessian that it calculates
at every step... I don't see this in the OptimValues list...
is there a way to get at it?

Dave

Subject: Have fminunc show the gradient?

From: Marcelo Marazzi

Date: 15 Aug, 2008 20:41:48

Message: 5 of 5

There is a built-in plot function that plots the norm of the gradient.

One way to run it is to open the optimtool, and select FIrst Order
Optimality under Plot Functions. There is a way to run this from the
command line as well.

I assume you're using the medium-scale algorithm. This algorithm
does not compute the Hessian, but rather a so-called quasi-Newton
approximation to the inverse of the Hessian. This matrix is only
an approximation (often crude), and to the inverse of the Hessian
(not to the Hessian itself), so it's not made available via the
output function - typically it's not useful.

The output function gives you access to each iterate x; you can
compute the Hessian (or an approximation to it via finite differences)
at x inside the output function.

-Marcelo

David Doria wrote:
> Ok, now I would like to see the hessian that it calculates
> at every step... I don't see this in the OptimValues list...
> is there a way to get at it?
>
> Dave

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com