C5 W1 A2 Dinosaur Island - "Reasonable" but wrong output names

Hi,

I’m having problems getting the correct output (dinosaur names) of the model in exercise 4. The loss decreases and I seem to get reasonable names but something is wrong unfortunately.

My output:

Iteration: 22000, Loss: 20.578871

Hutusaurus
Euca
Eustrioppn
Hocamptopanceus
Xuspeodon
Elacropechus
Uspeodon 

Expected output:

Iteration: 22000, Loss: 22.728886

Onustreofkelus
Llecagosaurus
Mystolojmiaterltasaurus
Ola
Yuskeolongus
Eiacosaurus
Trodonosaurus

Some of the variables after the first iteration:

idx 0
single example: aachenosaurus
single example chars: ['a', 'a', 'c', 'h', 'e', 'n', 'o', 's', 'a', 'u', 'r', 'u', 's']
single example ix: [1, 1, 3, 8, 5, 14, 15, 19, 1, 21, 18, 21, 19]
X: [None, 1, 1, 3, 8, 5, 14, 15, 19, 1, 21, 18, 21, 19]
Y: [1, 1, 3, 8, 5, 14, 15, 19, 1, 21, 18, 21, 19, 0]

Here are some things I did to get where I’m at:

I used j, the modulo operator and the number of examples len(examples) to set idx.
For single_example_ix I created a list comprehension like so:

[char_to_ix[i] for i in single_example_chars]

and added [None] to it to set X.

For Y I removed [None] by using X[1:] and added the index for the newline (0) to it at the end.

I can share more specifics if that helps, but didn’t want to paste the entire implementation here to start with. I tried restarting the kernel but got the same error.

2 Likes

One common mistake is to use the original ordered list of names as the input, instead of the scrambled list that they create for you in the preamble code in that function. That results in perfectly reasonable, but different, outputs.

1 Like

That was exactly the problem. Thanks a lot!

That’s good news. Everything else you described sounded right to me and the results look completely reasonable, so I figured that your code is fundamentally correct. But having different inputs changes the results, of course.