# C5W1A2 rnn_forward error

Does anyone know what does this error mean?

I have tested that my Y is a list

I think it’s a good theory that it’s your Y value that is wrong. I added the same print statements and here’s what I see:

``````<class 'list'>
Y = [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19, 0]
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]
``````

So the problem is not that Y is the wrong type. The problem is that you’ve made it a list of 2 elements, one of which is also a list (containing two elements one of which is a list). It is supposed to be a simple list of numbers.

See this other parallel thread with more discussion of another version of the same problem.

Thank you so much! I have a question though, why doesn’t Y have None as X does? I corrected my code buy my Y has “None” and the result is wrong.

I have just tried X[1:] and got the None out, but I still got the wrong output I don’t know why

Ok, it looks like you’ve solved all the problems with X and Y, but now there is some other part of the algorithm that is incorrect. Are you sure your sample function passed the tests in the notebook? It might shed some light to compare the results after later iterations. Here’s what I get up to Iteration 6000. Does your code give different results at 2000?

``````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 =  1535
j =  1536 idx =  0
Iteration: 2000, Loss: 27.884160

Liusskeomnolxeros
Hmdaairus
Hytroligoraurus
Lecalosapaus
Xusicikoraurus
Abalpsamantisaurus
Tpraneronxeros

Iteration: 4000, Loss: 25.901815

Mivrosaurus
Inee
Ivtroplisaurus
Mbaaisaurus
Wusichisaurus
Cabaselachus
Toraperlethosdarenitochusthiamamumamaon

Iteration: 6000, Loss: 24.608779

Onwusceomosaurus
Lieeaerosaurus
Lxussaurus
Oma
Xusteonosaurus
Eeahosaurus
Toreonosaurus
``````

Thank you so much! I got it right now!!!

That’s great news! Thanks for confirming.

1 Like

Hi,

First of all thanks to you both for helping me debugging my code, I had similar issues working with lists to get Y value right.

Now I´m stucked in iteration #22001:

Iteration: 22000, Loss: 20.578871

Hutusaurus
Euca
Eustrioppn
Hocamptopanceus
Xuspeodon
Elacropechus
Uspeodon

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

I’ve been taking a look to my sample function but it is passing all the tests:

Sampling: list of sampled indices: [23, 16, 26, 26, 24, 3, 21, 1, 7, 24, 15, 3, 25, 20, 6, 13, 10, 8, 20, 12, 2, 0] list of sampled characters: [‘w’, ‘p’, ‘z’, ‘z’, ‘x’, ‘c’, ‘u’, ‘a’, ‘g’, ‘x’, ‘o’, ‘c’, ‘y’, ‘t’, ‘f’, ‘m’, ‘j’, ‘h’, ‘t’, ‘l’, ‘b’, ‘\n’] All tests passed!

Expected output

``````Sampling:
list of sampled indices:
[23, 16, 26, 26, 24, 3, 21, 1, 7, 24, 15, 3, 25, 20, 6, 13, 10, 8, 20, 12, 2, 0]
list of sampled characters:
['w', 'p', 'z', 'z', 'x', 'c', 'u', 'a', 'g', 'x', 'o', 'c', 'y', 't', 'f', 'm', 'j', 'h', 't', 'l', 'b', '\n']
``````

Can you help me with it?

JdF

I think that’s the answer that you get if you forget to use the “shuffled” name list as your input in your model function. They gave you the code to randomly shuffle the last before you start. If the name that is input at iteration 0 is Aachenosaurus, that’s another indication that this is the mistake you’ve made. That is the very first name on the original list, as you can see from the cell early on where they show you the list. Here’s another recent thread about that type of issue.

1 Like

Thanks a lot, that was my mistake, I was using data_x instead. That little detail was blowing my mind

Iteration: 22000, Loss: 22.728886

Onustreofkelus
Llecagosaurus
Mystolojmiaterltasaurus
Ola
Yuskeolongus
Eiacosaurus
Trodonosaurus

All tests passed!