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>; 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 (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, [email protected] | consumption is being standardized." _______________________________________________ mlpack mailing list [email protected] http://knife.lugatgt.org/cgi-bin/mailman/listinfo/mlpack
