What happens to compute_gradient?

From what I can tell, gradient_function replaces the compute_gradient function in the labs. Why is this and how is this possible since gradient_function is not mentioned or define prior to being used in the gradient_descent function?

Hello @Justin_McCarty ,

Welcome to our community!

I think you are asking about “C1_W1_Lab04_Gradient_Descent”. Next time, please share reference info because it can help us be on the same page. :slight_smile:

Just as we can pass variables like numbers, strings, or lists into a function, we can pass variables like functions too!

If we look at the def line for gradient_descent and its DocString (the red string followed), the 7th and the 8th arguments are supposed to be functions. When we call the gradient_descent function, we need to provide predefined functions in the corresponding 7th and 8th place of the list of input arguments. If we can accept passing numbers into a function, we can follow the same idea to accept passing functions into another function. We only need to predefined those numbers and functions.

Cheers,
Raymond

1 Like