My code is not working even after using the hints section

My first attempt returned the same error as it was almost identical to the code provided in the hints. So is there a problem from my side?

Hello @Prakhar_Arya,

From this part of the traceback,


it seems to me that you have explicity defined a sigmoid in the graded code cell for my_dense. Initially, the upper part of that code cell should look like the following and it is without def sigmoid:

So, the problem that I would point out first is that you have defined your own sigmoid, which is unexpected. For the sake of assignment submission, we should not add or change any code outside of sections denoted by


### END CODE HERE ### 

So I suggest you to:

  1. revert any change that you have made outside of the sections, including the sigmoid function.
  2. on the jupyter notebook’s menu, click “Kernel” > “Restart”
  3. run your notebook from the first code cell down, and the problem should go away.

Note that making unexpected change might fail some public tests or the autograder’s tests.


PS: The sigmoid function is provided to you in the script file, and it is imported in the first code cell of the assignment via from autils import *. It does not use math.exp because it only supports scalar. Feel free to check out the script file for how its sigmoid is implemented. However, my suggestion is not to fix your own defined sigmoid, but to remove it, because as I have mentioned in the above, unexpected change can cause problem.

1 Like

I restarted the Kernel and it works. Though I removed by sigmid function when I learnt that it was already defined, I did not know that it will not revert the changes back to the pre defined sigmoid. Thank you so much.

I am glad to hear that it has worked!

If it was not for a successful assignment submission, I would actually be happy to see that you were trying to define the sigmoid yourself. If I were you, I would think - oh! I did a check, I didn’t see sigmoid was defined (because it is defined via the * in from autils import *), and I knew how sigmoid should look like, albeit I used the problematic math.exp.

So, 99.9% great work @Prakhar_Arya :wink: :wink: 0.1% because of the math.exp. :grin: