C1_W2 Exercise 8 Wrong parameter values

[Moderator edit – code removed]

image

Even after passing all the above tests and implementing the code as given in the snippet. Assertion statement is throwing error for wrong parameter values.

Can anyone suggest what could be wrong here?

Hi, @Akki400706 and welcome to the Specialization. That box you checked agreeing to the course honor code, means that you agreed to not share your work with others, which implies not posting your code in the Discourse forum (and any other public forum). A snapshot of the full traceback (i.e. the error log that makes your heart sink) is not only permitted but also encouraged. In fact, it is necessary for you and other to assist in debugging you code. So, please take note. Thanks!

Please add another post which includes the full Traceback. Thanks, again!

That said, the problem is likely due to a “hard-coding” issue. This exercise is a comparatively easy one, but lots of folks get tripped up here due to hard-coding mistakes. I say “easy” because you have already done the hard work by completing the helper functions which are called by the model function.

It is tempting for many learners to cut and paste the signature of the function called by model (i.e. the thing that follows the def statement used to start of the function definition) from your previous work. That function, for example, will include default settings for keyword arguments. For example, num_iterations=100. Those settings are not appropriate here .

Functions are useful because they are flexible and can be used and reused in a variety of settings. To make that magic happen, the arguments of the helper function called by the calling function [e.g. model(...)] must “inherit” the arguments of the calling function (e.g. num_iterations=num_iterations). The same is true of the "postional" arguments (i.e. those not followed by an =` sign and a default setting). These must also be inherited, but many times you get away with it because the main function’s parameter name is the same as the one called within. BTW, positional arguments always come first in a function definition. It’s a rule.

With all of that in mind, please review your code. And study the traceback! You will soon see the power of functions. A great wat to start or end the day! :nerd_face: