Performs gradient descent to learn theta