[mlpack] Question regarding Optimizer template template params.
ryan at ratml.org
Thu Mar 2 14:05:57 EST 2017
On Thu, Mar 02, 2017 at 06:25:54PM +0000, Arun Reddy wrote:
> Hi Devs,
> I was working on refactoring SGD optimizer to incorporate UpdatePolicyType
> as a template param.
> *Question*: Instead of adding additional template parameters everytime
> we make some changes to the optimizer, can we make it more generic?
This is a tricky little corner of C++ that we're kind of painted into
here. We shouldn't change the generic optimizer API, so we shouldn't
adapt classes like RegularizedSVD, because other optimizers may have
completely different behaviors.
Instead, we should use template typedefs to "adapt" the very generic
optimizers to the type signatures required by the OptimizerType policy.
using StandardSGD = SGD<FunctionType, EmptyUpdate>;
using MomentumSGD = SGD<FunctionType, MomentumUpdate>;
and so forth.
You can see this strategy is done with trees and the TreeType API:
And the TreeType API itself (if you are interested, though it is off
topic for what you are working on) is documented here:
(The CSS for doxygen keeps changing and making what I was working on out
of date... looks like I have a few little things to fix there...)
Let me know if I can clarify anything.
Ryan Curtin | "For more enjoyment and greater efficiency,
ryan at ratml.org | consumption is being standardized."
More information about the mlpack