First programming assignment in week 2 error

Before you post, please make sure to:

  1. Add a clear title that describes your question.

  2. Add all required tags in the tag option (top-right of the post):

    • The platform (e.g., dl-ai-learning-platform or Coursera-platform.)

    • The course week/module

  3. Write a detailed description of your issue.

I get an error message on assignment 2 when I execute my one line sigmoid function: NameError: name ‘basic_sigmoid’ is not defined. Not sure what this is referring to. My one line of code is: s = 1/(1+math.exp(x))

It’s not enough just to type code into a function cell: you then have to actually run that cell by clicking on it to select it and then typing “Shift-Enter”. Or by using the Cell -> Run menu. You also need to run every cell earlier in the notebook before you run a given cell.

There was a reading item just before the assignments in Week 2 that walks you through how the notebooks work. It takes some getting used to.

The other thing to be aware of is that if you leave the notebook idle for more than a few minutes or close it and reopen it, you then need to run everything again. Even though you can still see the output from a previous run sitting there, the actual runtime memory does not contain the interpreted code or the generated data. One easy way to restart things is:

Kernel -> Restart and Clear Output
Save
Cell -> Run All Above

or

Cell -> Run All

to get things refreshed and regenerated after reopening the notebook.

Here’s another thread that discusses how the runtime state of the notebook can get out of sync. Please see that post that I linked and the one right after it or read the whole thread from the beginning to get the context.

I have it working now. It is a bit strange. Thanks for the help.

2 Likes