Last active
March 2, 2017 02:36
-
-
Save arunreddy/13d87f976f0f578df1e7b117042e3010 to your computer and use it in GitHub Desktop.
Momentum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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