C5 W1 A2 different result obtained haven't seen this addressed elsewhere

below is last output step and traceback. I realize Loss difference from expected is a clue, but can’t find what has gone wrong. Optimize passed tests and seems straightforward. use of input args and naming of return values also seems to be what is needed.

I’ve read other discussions on this same issue (or similar anyway), my submission already uses the code lines suggested. I think I’m not alone, as there are other replies (after the mentor had responded though) to the post: “C5 W1 A2 dino names wrong output” (hence this new posting)

Assistance requested (don’t want to leave this course without understanding what went differently here).

Iteration: 22000, Loss: 0.294620

Iavesaqr
Esitoriasaurus
Esitoriasaurus
Iaeaurus
Urus
Andoravenator
Saurur


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

Could you please paste whole Output/Traceback ? An example is;

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
:

thank you for responding (appreciated your Transformer Encoder graphical depiction - might you have one for the decoder?) Anyway, full output pasted below

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

j = 1535 idx = 2
j = 1536 idx = 3
Iteration: 2000, Loss: 9.894264

Iavosaurus
Dosaurus
Esitosaurus
Iaecerus
Unus
Amanonelhoneris
Tosaurus

Iteration: 4000, Loss: 2.189096

Kesilscelmh
Esipandoravenator
Esitosaurus
Kbomaniorasrurus
Udus
Ananrurus
Tosaurus

Iteration: 6000, Loss: 0.912600

Kesosanrus
Dosaerus
Esitosaurus
Kconaururusaseliaachoselipanoomerus
Uausesitosaurus
Anaorus
Tosaurus

Iteration: 8000, Loss: 0.637094

Kcosaurus
Chomaniuanhoseuatsos
Esitosaurus
Kanceliq
Uausesitikaos
Anborisipandoravenator
Tosaurus

Iteration: 10000, Loss: 1.761213

Iavosaurus
Eripandoravenator
Esitoraerus
Iaacerubuaesitancselatdoriblselimanosaurus
Urus
Anchubelis
Tor

Iteration: 12000, Loss: 0.723301

Iavosaurus
Dosaerus
Esitorialokuburisanhlierus
Iahor
Urus
Ancoras
Tor

Iteration: 14000, Loss: 0.346465

Enisandoravenator
Andoravenator
Ctosaurus
Elimanosaerus
Urusaselanror
Ancorav
Tor

Iteration: 16000, Loss: 1.876693

Eruslorhsooosioosaurtorihosdur
Athoaerus
Avoselomorcslirohomhoor
Enahoseliaosavenoselosanoohcselimomoosasaurus
Urus
Ananosandoomorosriocsatoomasklomhhorurupatoomasesa
Urus

Iteration: 18000, Loss: 1.096196

Erus
Esesandur
Esitoriasaurus
Facbnaurus
Urus
Andhravenasinanhuravenator
Saurus

Iteration: 20000, Loss: 0.366187

Iavesaqravenaseliaurimrsaurus
Eseqlnkubesesasandnsaurus
Esitoriasaurus
Iaeaurus
Urus
Andhravenasinanosaerus
Saurus

Iteration: 22000, Loss: 0.294620

Iavesaqr
Esitoriasaurus
Esitoriasaurus
Iaeaurus
Urus
Andoravenator
Saurur


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

OK. the first thing to look at is ‘idx’. We only have 1536 examples. But, we want to iterate more, like 22001. So, we calculate an index, ‘idx’ to lap around to 0 if we reach to the last example.

j = 1535 idx = 2
j = 1536 idx = 3

But, if we look at this, even though we have 1536 examples, the index is already lapped around. So, potentially, 1536th, 1535th and 1534th examples are not used. Then, the result should be different. So, that is the first check point.

And, as you observed, your loss is too small. We need to check as the next step.

If you set a lap around counter small like above, of course the result is different. But, if you set it too small, then, there is a possibility that the loss is getting small since you only use small number of examples. In any cases, let's start to fix 'idx'.

OK, that helps. Thank you!