Last active
December 10, 2018 13:23
-
-
Save masterdezign/5b0cbc6987552d08e5c86d46dd657303 to your computer and use it in GitHub Desktop.
A brief gradient descent illustration in Haskell
This file contains hidden or 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
descent1D gradF iterN gamma x0 = take iterN (iterate _descend x0) | |
where | |
_descend gamma' x = x - gamma' * gradF x | |
-- Suppose, we have a function F(x) = (x - 3)^2. | |
-- Therefore, Grad F(x) = 2 * (x - 3). | |
gradF_test x = 2 * (x - 3) | |
main = print (descent1D gradF_test 10 gamma 0.0) | |
where gamma = 0.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment