W1A2: Dinosaurus_Island_Character_level_language_model

I guess I am doing it right for

def model(data_x,

Since it is not proper to paste code, I paste the output:

j =  0 idx =  0
single_example = turiasaurus
single_example_chars ['t', 'u', 'r', 'i', 'a', 's', 'a', 'u', 'r', 'u', 's']
single_example_ix [14, 23, 24, 8, 0, 6, 0, 23, 24, 23, 6]
 X =  [None, 14, 23, 24, 8, 0, 6, 0, 23, 24, 23, 6] 
 Y =        [14, 23, 24, 8, 0, 6, 0, 23, 24, 23, 6, 22] 

But at Iteration: 22000, Loss: 22.685007
my output is:

Espgrongeus
Ytsahitosaurus
Epcopheimospmeustuxeorove
Elaanodelas
Prophes
Sajnodyhatocteys
Rophosaurus

Any idea where I was doing wrong? All the cells above were correct. And I think I got the idea of building X and Y

Thanks

To help me assist you,

Please click on my name to start a private message. Then, attach your notebook as a .ipynb file. Please note that mentors cannot access your Coursera Jupyter workspace, so sending the notebook in a .ipynb format is essential.

The bug is with the function def clip.
The order of iteration of gradients is incorrect. Please see this comment and fix your code:
# Clip to mitigate exploding gradients, loop over [dWax, dWaa, dWya, db, dby]. (≈2 lines)

Hey, @balaji.ambresh , thanks for pointing this out. Although I believe the order does not matter. Anyway, I changed the order to be correct ([dWax, dWaa, dWya, db, dby]) in clip, but it still output a wrong name:

1 Like

My bad. Sorry. Please wait.

1 Like

You’ve modified the starter code at a place not recommended by the staff and hence the problem:

Starter version:

chars = sorted(chars)
print(chars)
char_to_ix = { ch:i for i,ch in enumerate(chars) }
ix_to_char = { i:ch for i,ch in enumerate(chars) }
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(ix_to_char)

Your version:

char_to_ix = { ch:i for i,ch in enumerate(chars) }
ix_to_char = { i:ch for i,ch in enumerate(chars) }
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(ix_to_char)

With your modification, the sample method should’ve broken. I don’t understand how that passed. Fix that and your notebook is good.

2 Likes

Hey, @balaji.ambresh ! Thanks for the info! Good catch. I don’t know why these 2 lines were removed. Maybe by accident…

Yeah, I noticed the same. But I looked at the ‘sample_text’ code again. It seems like it only compared the first 6 indices. See a screenshot I took 2 days ago when I found it a bit weird (why I passed, LOL)

So the suggestion is maybe we should be more strict on the sample test :smile:

Your recommendation has been passed along to the staff. That said, please don’t edit the notebook at places that aren’t supposed to be modified.

2 Likes