Skip to content

Instantly share code, notes, and snippets.

@kris-singh
Created March 17, 2017 11:32
Show Gist options
  • Save kris-singh/9ed1d88c781de14fd62264ce6b1dd1b8 to your computer and use it in GitHub Desktop.
Save kris-singh/9ed1d88c781de14fd62264ce6b1dd1b8 to your computer and use it in GitHub Desktop.
Nestrov_update_policy.hpp
.....
arma::mat TempUpdate(arma::mat& iterate,
const double momentum,
arma::mat& velocity)
{
return iterate + momentum*velocity;
}
......
sgd.hpp
inline typename std::enable_if<
HasNestrovUpdate<UpdatePolicy, void&(UpdatePolicy::*)()>::value, void>::type=0>
void updateIterate(arma::mat& iterate){}
....
sgd_impl.hpp
....
inline typename std::enable_if<
HasNestrovUpdate<UpdatePolicy, void&(UpdatePolicy::*)()>::value, arma::mat>::type=0>
void updateIterate(iterate)
{
iterate = UpdatePolicy::NestrovUpdate(iterate, momentum, velocity);
}
if (shuffle)
function.Gradient(iterate, visitationOrder[currentFunc
tion], gradient);
else
function.Gradient(iterate, currentFunction, gradient);
Restoreitera
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment