Skip to content

Instantly share code, notes, and snippets.

@arunreddy
Last active March 2, 2017 02:36
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/13d87f976f0f578df1e7b117042e3010 to your computer and use it in GitHub Desktop.
Save arunreddy/13d87f976f0f578df1e7b117042e3010 to your computer and use it in GitHub Desktop.
Momentum
// Without policy class..
Optimize(arma::mat& iterate){
arma::mat v = arma::zeros<arma::mat>(iterate.n_rows, iterate.n_cols);
for(;;){
v = momentum*v - stepSize * gradient;
iterate += v;
}
}
// The above code in MomentumSGD wil be changed to the following by using a Momentum updatePolicy class:
Optimize(arma::mat& iterate){
updatePolicy.init(iterate.n_rows, iterate.n_cols);
for(;;){
iterate += updatePolicy.update(stepSize,gradient)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment