Python implementation of gradient descent.