Skip to content

Instantly share code, notes, and snippets.

@arunreddy
Last active March 6, 2017 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arunreddy/f3bcd2709788b4bdf6c9b2570b26d5db to your computer and use it in GitHub Desktop.
Save arunreddy/f3bcd2709788b4bdf6c9b2570b26d5db to your computer and use it in GitHub Desktop.
policy_class
// SGD with variadic templates for policy type class.
template<typename DecomposableFunctionType, typename ... PolicyType>
class SGD{
}
// Use alias to declare most frequently used combinations.
using StandardSGD = SGD<FunctionType, EmptyUpdate, NoDecay>;
using SGD2 = SGD<FunctionType, MomentumUpdate, NoDecay>;
using SGD3 = SGD<FunctionType, NesterovUpdate, ExponentialDecay>;
// Is it ok to assume in the code that the Order of policy types is fixed.
// FunctionType at index 0, followed by UpdateType at 1 and DecayType at 2.
// (OR) a relaxed version..
// Choose the policy based on the PolicyType, if not provided fall back to defaults.
using StandardSGD = SGD<FunctionType> // If not provided pick the default policy type.
using SGD2 = SGD<FunctionType, MomentumUpdate> // Use default NoDecay for DecayType
using SGD3 = SGD<FunctionType, ExponentDecay> // Use default EmptyUpdate for UpdateType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment