W3 assignment submission error and assertion error

Hello @R2004W,

Since writing working code is part of the assignment, code debugging is also part of it. What we can do is to give you some tips so that you can inspect your code, find the bug, and try to fix it.

Let’s analyze the error messages.

  1. You still have problem with z_wb in cell #14 even though you had put some effort in it previously, otherwise, the message would not have appeared and you would not need to share it with us. First, identify (code) cell #14. Then, in the cell, check if z_wb is explicitly used OR used in one of the functions that is called AND defined by you. Think whether z_wb should be used there, and if it should be, make sure it is defined before it’s being used. I know you must think you had defined it, otherwise, you would have fixed it already. The error message doesn’t lie, so you will have to check very very carefully.

  2. C6 depends on C3, so I suggest you to fix C3 and C4 first, then try the test for C6 again before starting to look for any bug.

  3. I added this point because you suspect it to be related to indentations. There may or may not be indenation problems, but it is worth having a look at it. First, if you want, you might spend 10 minutes on this post to get more familiar with how to indent. Then read your code and make sure each and every line is indented according to your understanding of the equations that the functions are implemented for. For example, if there are 2 loops in one of your function, where one is nested inside another, then you should ask yourself, did you place each line of your code in the correct loop? Did you put any outer loop code in the inner loop or any inner code in the outer loop? This can happen if you miss or mis-add an indentation. Try to reason about every line with yourself. This checking takes less time than what I am going to propose next.

  4. The error messages in C3, C4 and C6 all indicate that your functions cannot return correct results. This means you were not implementing the functions exactly according to the exercise’s description. Now, it is our own job to understand the description and implement the required function in the correct way, so we must know what each line of our code should produce. I suggest you to spend around 30 minutes to go through this post. The post is about where to add “printing lines” in between your codes to keep track of the progress of your function. You will NEED TO create a new and temporary code cell, define some simple inputs as demonstrated in the post, call your function to be inspected in that temporary code cell, read the printed lines, reason yourself whether the printed results are as expected, locate the bug when unexpected results occur, and fix the bug based on your understanding. After you fix the bug and pass the tests, you NEED to remove the temporary code cell, before any submission trials, or the autograder might not work properly and result in failure.

@R2004W, these are some general code debugging tips I can offer to you for this and any future assignments when a function can compute some results but those results are incorrect. Since we can’t fix the bug for you anyway, I hope you will take this time as an opportunity to go through these debugging techniques, fix the problems yourself, and most importantly, be able to locate and fix any future problems as an individual machine learning practitioner. This is more than just an assignment.

I write code everyday, and I verify and debug my code everyday.

I wish you good luck and a successful new year ahead!


1 Like