Problem with Dinosaurus Island Character

My notebook passes all tests except the last one related to Exercise 4 - model.
I’ve also read other threads related to this topic and I couldn’t find a clue to solve mine.
In 1 discussion @paulinpaloalto shared the result of the first iteration and I checked it with mine, it seems it is OK in the first iteration but will diverge as the iteration grows. Here is the screenshot of the first and last iteration


Any hint? or is anybody interested to take a look?

Hi, do you have the complete snapshot of the error?

Hi @Nydia thanks for the reply
Here is the assertion error

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

Iteration: 0, Loss: 23.070860

Nkzxwtdmfqoeyhsqwasjkjvu
Kneb
Kzxwtdmfqoeyhsqwasjkjvu
Neb
Zxwtdmfqoeyhsqwasjkjvu
Eb
Xwtdmfqoeyhsqwasjkjvu


j =  1535 idx =  1535
j =  1536 idx =  0
Iteration: 2000, Loss: 18.317592

Ohtsnaure
Loe
Murype
Oae
Vstnaurpo
Ibaurye
Tsnaurpo


Iteration: 4000, Loss: 14.753626

Oitssnauroc
Loidarrpe
Lstopisbhnaurpoe
Oddarrpe
Ttsnauroc
Idarrpe
Stnauroc


Iteration: 6000, Loss: 13.698804

Nazurpe
Loidarpoc
Ltsnaurec
Nar
Tsnaurec
Idarpoc
Stnauroe


Iteration: 8000, Loss: 13.358013

Nazurpe
Kshargpo
Ltsnaurgoc
Nar
Tsnarpec
Idarwpe
Stnaurpo


Iteration: 10000, Loss: 13.223638

Nazurpe
Loidarpoc
Lstnauroc
Nare
Tsnauroc
Idarpoc
Stnaurpo


Iteration: 12000, Loss: 13.029092

Oktsnaurgoc
Lokiaorpo
Mxsnaurgoc
Oha
Tsnaurgoc
Idaogoc
Stnaurpo


Iteration: 14000, Loss: 12.915444

Nazurye
Kiha
Ltnauro
Nar
Tnauro
Idarqsfarpoce
Stnaurpo


Iteration: 16000, Loss: 12.884703

Nazurp
Loidarpoc
Ltnaupo
Nao
Tnauro
Idarpoc
Stnaurpe


Iteration: 18000, Loss: 12.757007

Shnaurgo
Loidarpoc
Lsnauro
Sbao
Tnauro
Idarypo
Ssiauroc


Iteration: 20000, Loss: 12.685612

Sitnurgo
Lsaurgoe
Mtsnaurgoc
Sdarpoc
Tnryoc
Idarwpo
Stmauroc


Iteration: 22000, Loss: 12.691732

Lltnnrgo
Kkia
Lstnarpoce
Lidarpo
Tnargo
Idarpo
Stnaurpo


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-13-725c093d6b91> in <module>
      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

Hi @mostafa.asg ,

The debug printout you attached here is showing single _example has is 11 characters, however, the variable single_example_chars has only 6 characters. What is happening here ?

Yes, as Kic says, there must be something fundamentally wrong with your logic. Look at your single_example_chars variable contents. It should be (‘t’, ‘u’, ‘r’, …}, right? So how did that happen?

For reference here’s my output for that iteration and notice how that looks below:

initial loss 23.070858062030304
len(X) 12, len(Y) 12
a_prev.shape (50, 1)
(50, 27)
(50, 1)
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


len(X) 15, len(Y) 15
a_prev.shape (50, 1)
(50, 27)
(50, 1)
len(X) 11, len(Y) 11
a_prev.shape (50, 1)
(50, 27)
(50, 1)
len(X) 14, len(Y) 14
a_prev.shape (50, 1)
(50, 27)
(50, 1)

Thanks @Kic @paulinpaloalto and @Nydia
@Kic nice catch! I didn’t see this and that was a problem
Thanks a lot all, now it’s working. :tada:

1 Like

Great! It must have been a pretty creative bug to end up with the letters in that order. I’m having a hard time coming up with a way to get what you got if that were the actual goal. i and t are not adjacent and are shown out of order, but s, a, u, r are adjacent and appear in order. Hmmmm. :laughing: