I am having an issue with the UNQ_C3 compute_gradient function. The orginal code defined 5 positional arguments for this function - lambda_ as an unused placeholder included. The code is inconsistent in that sometimes 4 input arguments are available and sometimes 5 are. Since we are not dealing with regularised gradient functions in UNQ_C3, I’m not sure why lambda_ is present in this function at all.
Welcome to the community
Your cells isn’t complete you may delete an parameters wrongly or there are an error in your assignment lab…to get a fresh assignment from scratch, please doing these steps file → open → select running assignment and doing shutdown and select all file and delete it → after that select help
like this image and choose →
Hi @Rahmah_Saleh ,
The compute_gradient() function definition has 5 input arguments, and by default lambda is set to none. However, you have changed the definition to have 4 input arguments, removing the lambda as an input argument. This is causing the problem as reported in the error message.
In Python, setting a default value to an input argument provides flexibility. When making function call to that function with just 4 input arguements, the default value will be used.
lambda_ is included as a reminder that it will be used later in the course. Do not use it in that function. I agree that it causes confusion.
compute_gradient has lambda_ as a parameter even though it doesn’t use it is so that its parameters will match the parameters for
compute_gradient_reg. That way, we can pass either function to
gradient_descent and it can call either of them with the same parameters.
@Rahmah_Saleh, that’s why you’re seeing that error - since you removed the lambda_ parameter from
gradient_descent can no longer call it with the same parameters it uses for
compute_gradient_reg. By keeping the parameters consistent,
gradient_descent doesn’t need to know specifically which gradient computation function it’s using.