Implement GradientDescent for general hypothesis