C5_W3: one_step_attention_test fails without a clue

To illustrate the issue with notebooks that use global objects, here is a simple example:

Let’s say you have a notebook that has three cells.

  • Cell 1 creates a global object.
  • Cell 2 modifies that object.
  • Cell 3 tests the expected value of the object.

Let’s say when you wrote the code in Cell 2, you made a mistake, so the test in Cell 3 throws an error message.

So you edit Cell 2, and then run Cells 2 and 3 again. This modifies the value of the global object. You do this several times before your code in Cell 2 is correct.

But the test in Cell 3 still fails, because your code in Cell 2 has modified the global object many times. The test in Cell 3 assumes that your code in Cell 2 was only run once.

So you have to go back and clear the state of the notebook, and re-run Cell 1 to create a fresh instance of the object, and run Cell 2 once to modify the object. Then the test in Cell 3 will pass.

I’m not saying this is a good design for the notebook - I’m just explaining a little about why the Course 5 assignments behave this way.

The global object that causes this issue is usually the LSTM itself.

4 Likes