Added generic gradient descent.