Calculate the hypothesis h = X * theta.Calculate the loss = h – y and maybe the squared cost (loss^2)/2m.Calculate the gradient = X’ * loss / m.Update the parameters theta = theta – alpha * gradient.
How do you find the gradient of a gradient descent in Python?
- Calculate the hypothesis h = X * theta.
- Calculate the loss = h – y and maybe the squared cost (loss^2)/2m.
- Calculate the gradient = X’ * loss / m.
- Update the parameters theta = theta – alpha * gradient.
How do you find the gradient descent of a function?
- Compute the gradient (slope), the first order derivative of the function at that point.
- Make a step (move) in the direction opposite to the gradient, opposite direction of slope increase from the current point by alpha times the gradient at that point.