Don't count iterations

Good day to all. I don’t count iterations in lab 2 DSL course 5. It hangs at iteration 0 and doesn’t count anymore. I did three attempts for 20, 30 and 40 minutes

Thank you for your time

Try to reset the kernel and run again!

1 Like

The code shouldn’t hang. The number of iterations is set to 22001. So, you should see more print statements for iterations divisible by 2000.

Please back up your notebook and follow these steps to refresh your workspace and get the starter code.

1 Like

There may be an error in your code. Every time I run the notebook the first output at iteration 0 is this:

single_example = turiasaurus

1 Like

My result at iteration = 0 is same as Tom’s:

j =  0 idx =  0
single_example = turiasaurus
single_example_chars ['t', 'u', 'r', 'i', 'a', 's', 'a', 'u', 'r', 'u', 's']
single_example_ix [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
 X =  [None, 20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19] 
 Y =        [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19, 0] 

Iteration: 0, Loss: 23.087336

Nkzxwtdmfqoeyhsqwasjkjvu
Kneb
Kzxwtdmfqoeyhsqwasjkjvu
Neb
Zxwtdmfqoeyhsqwasjkjvu
Eb
Xwtdmfqoeyhsqwasjkjvu

So, I guess there is some bug in your code.

1 Like

Changed the code: now it counts all iterations, but both the initial and the last name do not match; and the loss value is very small.
18000
Iteration: 20000, Loss: 0.002326

Rushjinzhousaurus
Nzhousaurus
Nzhousaurus
Rnhaurus
Zzouousaurus
Ihahous
Zzohous

20000
Iteration: 22000, Loss: 0.002086

Rushjinzhousaurus
Nzhousaurus
Nzhousaurus
Rnhaurus
Zzouousaurus
Ihahous
Zzohous

22000

AssertionError Traceback (most recent call last)
in
1 parameters, last_name = model(data.split(“\n”), ix_to_char, char_to_ix, 22001, verbose = True)
2
----> 3 assert last_name == ‘Trodonosaurus\n’, “Wrong expected output”
4 print(“\033[92mAll tests passed!”)

AssertionError: Wrong expected output

Does anyone have any idea?

Send me your model code privately. Click my name and message.

1 Like

OK. The structure of the code is already given to you, right? You just need to fill in the correct terms. Don’t need to write anything else. Don’t need to write any for loop, for example, for idx in range(len(examples)) is not necessary. Don’t change the indentation and sequence of the structure of the code given to you. Just put the correct terms and run…

        ### START CODE HERE ###
        
        # Set the index `idx` (see instructions above)
        idx = None
        
        # Set the input X (see instructions above)
        single_example = None
        single_example_chars = None
        single_example_ix = None
        X = None
        
        # Set the labels Y (see instructions above)
        ix_newline = None
        Y = None

        # Perform one optimization step: Forward-prop -> Backward-prop -> Clip -> Update parameters
        # Choose a learning rate of 0.01
        curr_loss, gradients, a_prev = None
        
        ### END CODE HERE ###
1 Like

I did it. Thank all so much!