DLS course 5 Week1 Assignment2 Exercise 4


When making the Model function, this is my result at Iteration 22000.

It looks like the model is working, but the names do not match. I can’t figure out why. Here is the code part:
{code removed by mentor}
Could someone help me, please?
P.S. I passed exercises 1,2, and 3

Hello @1492r

  1. I just want to first make sure that you were running the code on Coursera instead of any other of your own Python environment, right? There was a recent report of not able to get expected results because of that, so I want to eliminate that possibility. :slight_smile:

  2. Be reminded to take a single_example from the examples that was preprocessed by the assignment’s provided code.


PS: I have removed your code for you because it is against the community’s honor code to share it.

Hi, Raymond,

Thank you for your reply!

  1. Yes I was using Coursera notebook
  2. Yes I completed the assignment in sequential order. The data was preprocessed.
    My apologies for the code! I should have thought of it.

Hi @1492r ,

As Raymond pointed out from his reply, point2, you need to take a single_example from examples. These examples are built from data_x with unwanted character, such as whitespace, removed. But your single_example is taken from data_x not the examples, so it would contain unwanted character, hence your code failed to generate the expected output.

Ah, I misunderstood it.
It makes sense. Thank you, Raymond and Kic!

I got the same problem.
though I use examples[idx] as single_example.

The last iteration gives :

The debug statements gives :

j = 0 idx = 497
single_example = xenotarsosaurus
single_example_chars [‘x’, ‘e’, ‘n’, ‘o’, ‘t’, ‘a’, ‘r’, ‘s’, ‘o’, ‘s’, ‘a’, ‘u’, ‘r’, ‘u’, ‘s’]
single_example_ix [24, 5, 14, 15, 20, 1, 18, 19, 15, 19, 1, 21, 18, 21, 19]
X = [None, 24, 5, 14, 15, 20, 1, 18, 19, 15, 19, 1, 21, 18, 21, 19]
Y = [24, 5, 14, 15, 20, 1, 18, 19, 15, 19, 1, 21, 18, 21, 19, 0]

I don’t see where I made a mistake, have you some hints ?

I found my mistake,
it came from the initialization of idx if it can help someone else