![]() |
Stan
1.0
probability, sampling & optimization
|
Implements Nesterov's dual average algorithm. More...
#include <dualaverage.hpp>
Public Member Functions | |
| DualAverage (double gamma, const std::vector< double > &x0) | |
| Constructor. More... | |
| void | update (const std::vector< double > &g, std::vector< double > &xk) |
| Produces the next iterate xk given the current gradient g. More... | |
| void | setx0 (const std::vector< double > &x0) |
| Set the point towards which each iterate is shrunk. More... | |
| void | xbar (std::vector< double > &xbar) |
| Get the exponentially weighted moving average of all previous iterates. More... | |
| void | gbar (std::vector< double > &gbar) |
| Get the average of all previous gradients. More... | |
| void | xk (std::vector< double > &xk) |
| Get the current iterate. More... | |
| void | x0 (std::vector< double > &x0) |
| Get the point towards which we're shrinking the iterates. More... | |
| int | k () |
| Return how many iterations we've run for. More... | |
| double | gamma () |
| Return the regularization parameter gamma. More... | |
Protected Attributes | |
| std::vector< double > | _gbar |
| std::vector< double > | _xbar |
| std::vector< double > | _x0 |
| std::vector< double > | _lastx |
| int | _k |
| double | _gamma |
Implements Nesterov's dual average algorithm.
Use by repeatedly calling update() with the gradient evaluated at xk(). When finished, use the average value of all the xk's by calling xbar().
Iterates are shrunk towards a prespecified point x0. The level of shrinkage is controlled by the parameter gamma and gets weaker with each iteration.
Note that this is an algorithm for MINIMIZATION, not MAXIMIZATION.
Definition at line 28 of file dualaverage.hpp.
|
inline |
Constructor.
| gamma | Regularization parameter. Higher values mean that iterates will be shrunk towards x0 more strongly. |
| x0 | Point towards which iterates are shrunk. |
Definition at line 42 of file dualaverage.hpp.
|
inline |
Return the regularization parameter gamma.
Definition at line 125 of file dualaverage.hpp.
|
inline |
Get the average of all previous gradients.
| [out] | gbar | Where to return the average of all previous gradients. |
Definition at line 94 of file dualaverage.hpp.
|
inline |
Return how many iterations we've run for.
Definition at line 119 of file dualaverage.hpp.
|
inline |
Set the point towards which each iterate is shrunk.
| x0 | The point towards each iterate will be shrunk. |
Definition at line 75 of file dualaverage.hpp.
|
inline |
Produces the next iterate xk given the current gradient g.
| [in] | g | The new subgradient/stochastic gradient. |
| [out] | xk | The next iterate produced by the algorithm. |
Definition at line 53 of file dualaverage.hpp.
|
inline |
Get the point towards which we're shrinking the iterates.
| x0 | Where to return the point towards which we're shrinking the iterates. |
Definition at line 111 of file dualaverage.hpp.
|
inline |
Get the exponentially weighted moving average of all previous iterates.
| [out] | xbar | Where to return the exponentially weighted moving average of all previous iterates. |
Definition at line 86 of file dualaverage.hpp.
|
inline |
Get the current iterate.
| [out] | xk | Where to return the current iterate. |
Definition at line 102 of file dualaverage.hpp.
|
protected |
Definition at line 32 of file dualaverage.hpp.
|
protected |
Definition at line 30 of file dualaverage.hpp.
|
protected |
Definition at line 31 of file dualaverage.hpp.
|
protected |
Definition at line 30 of file dualaverage.hpp.
|
protected |
Definition at line 30 of file dualaverage.hpp.
|
protected |
Definition at line 30 of file dualaverage.hpp.