DLS week 1 assignment 2 Dino name last exercise

Hi, I’m stuck with wrong output dunno what’s wrong with the code
Here is the output

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-29-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

Generally this type of problem comes from mistakes in these three lines:
single_example =
single_example_chars =
single_example_ix =

I cannot see where is the problem with that
from the code snippet
here is my pseducode
single_example = idx of examples
single_example_chars = list of char from single_example
single_example_ix = convert to idx from single_example_chars

example output:

here is the program output:

turiasaurus
['t', 'u', 'r', 'i', 'a', 's', 'a', 'u', 'r', 'u', 's']
[20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
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.054380

Nkzxwtdmfqoeyhsqwasjkjvu
Kneb
Kzxwtdmfqoeyhsqwasjkjvu
Neb
Zxwtdmfqoeyhsqwasjkjvu
Eb
Xwtdmfqoeyhsqwasjkjvu
...

Mgwuuueeeeeevfuuuallllssaangypdaaaasbaaaccaagbuuho
Hhhaaamseedotkteeeuuraxaahpaarsmadcaeetpiiillcomso
Ivuuudlboojxehhpallllssaangypdaaaasbaaaccaagbuuhoo
Maaaamseedotkteeeuuraxaahpaarsmadcaeetpiiillcomsoo
Yyyybkagmbyjsmsalkjgssabsjzgdaaaasbaaaccaagbuuhooo
Caaamseedotkteeeuuraxaahpaarsmadcaeetpiiillcomsooo
Uuueeeeeevfuuuallllssaangypdaaaasbaaaccaagbuuhooog


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-67-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 Wanzl, did you have any answer on this? I got the same, though in your case you have a list of list. Look what I have and still get an ssert error:

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]

@TMosh any ideas please!

Hi @carlosrv19

Could not see any iteration printed, so my guess is that there might be a problem with the way idx is calculated. So check for that, and refer to the implementation notes if not sure.

Hi @Wanzl ,

Couple of suggestions to check:

  1. recycling of idx to zero, refer to implementation notes for guidance
  2. formation of X is incorrect.
    the implementation notes suggested to add two lists together: ['a'] + ['b']
    so, X = [None, 20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]

Hi Kic, thanks I found the error. The problem was that by mistake I was recycling on j%n_x and it should be j%len(examples)
Thanks

Hi @carlosrv19 ,

Great to hear you have got it sorted. Thanks

Thanks for reply, Mentor. My implementation of X was error, with little experiment i found out that a list variable don’t need bracket ‘

a = [1,2,3]
b = [4,5,6]
c = a + b
d = [a] + [b]  # i made this mistake
print(c)
print(d) 

output

[1, 2, 3, 4, 5, 6]
[[1, 2, 3], [4, 5, 6]]

I still can’t figure mine yet. I’ve been struggling with it for over a month now. I even found some code online and that didn’t work also ( even they claimed it was the ultimate solution to the assignment).

This is an old post, but it seems like the only one with the information I was looking for, so here are my two cents.

  1. I had the error where I was using len(data_x) instead of len(examples), which I guess shouldn’t matter as I think both are the same length.
  2. I was using data_x instead of examples to obtain single_example, this is important as examples gets shuffled.
  3. Important: I’m working locally (M1 Macbook Pro) and this test doesn’t pass in my machine but it does on Coursera…