Getting at the parameters from each step of optimization

Is there an easy way to access/pull the elements stored in the “extended” trace of the output of Optim.optimize()?

I’d like to have a matrix, or an array of arrays, where the ith column (or row) is the ith set of parameters the optimizer hit during optimization. I’d also like to have corresponding arrays with the objective values and gradient norms.

I know I can view all of this info in the trace itself, but my goal is to create some plots and do other fun stuff too.

Sure, why not just include a print statement inside your function over which you are calling optimize?

1 Like

I realize I could do that, or even create a global variable that serves as a container - storing each set of parameters, loss value, etc. for each step the optimizer takes. But I would prefer to avoid this if I can, though if I can’t it’s not a big deal.

Just thought there might be something I am missing.