Course 5 week 3 lab 2 exercise 3

I am getting the following error: “NameError Traceback (most recent call last)
17 print(”\033[92m All tests passed!")
—> 19 insert_ones_test(insert_ones)

in insert_ones_test(target)
2 import random
3 def insert_ones_test(target):
----> 4 segment_end_y = random.randrange(0, Ty - 50)
5 segment_end_ms = int(segment_end_y * 10000.4) / Ty;
6 arr1 = target(np.zeros((1, Ty)), segment_end_ms)

NameError: name ‘Ty’ is not defined"

Ty is defined as “_, Ty = y.shape” in the function.
Pls help me!

Here is the code it self:

1 Like

Hi @simplystephen ,

The execution environment is not up to date. Please refresh the kernel and rerun the code cell from start:

Thank you Boss! It worked. Spent over 2.5 hrs on it already. Thank you very much

1 Like

In these sequence model assignments, every time you change one of the LSTM objects anywhere in the notebook, you pretty much need to re-run all of the cells starting from the top of the notebook.

This is because they LSTM models are global variables, and you can’t modify a variable halfway down the page after it has been previously created.

Thank you sir. Much appreciated!