[mlpack] Question regarding Optimizer template template params.

Arun Reddy arunreddy.nelakurthi at gmail.com
Thu Mar 2 15:03:18 EST 2017


Hey Ryan,

On Thu, Mar 2, 2017 at 12:05 PM Ryan Curtin <ryan at ratml.org> wrote:

> 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?
>
> Hi Arun,
>
> 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.
> For example:
>
> template<typename FunctionType>
> using StandardSGD = SGD<FunctionType, EmptyUpdate>;
>
> template<typename FunctionType>
> using MomentumSGD = SGD<FunctionType, MomentumUpdate>;
>
> This looks more cleaner. Got it.


> and so forth.
>
> You can see this strategy is done with trees and the TreeType API:
>
> https://github.com/mlpack/mlpack/blob/master/src/mlpack/
> core/tree/binary_space_tree/typedef.hpp
>
> And the TreeType API itself (if you are interested, though it is off
> topic for what you are working on) is documented here:
>
> http://mlpack.org/docs/mlpack-git/doxygen.php?doc=trees.html
>
> Pretty exhaustive and a good read. I compiled the docs on my local with
USE_MATHJAX and it works like charm - No more broken equations.

(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.
>
> Thanks,
>
> Ryan
>
> --
> Ryan Curtin    | "For more enjoyment and greater efficiency,
> ryan at ratml.org | consumption is being standardized."
>

Thanks
Arun.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://knife.lugatgt.org/pipermail/mlpack/attachments/20170302/622d69e5/attachment-0001.html>


More information about the mlpack mailing list