Sequence model W1 Dinosaur Island-Character-Level Language Modeling

A. I’m facing this problem, Please support me. What is my wrong???

Sampling:
list of sampled indices:
[23, 16, 26, 26, 19, 25, 22, 16, 7, 11, 17, 26, 23, 23, 23, 18, 10, 6, 12, 2, 14, 24, 14, 17, 7, 18, 0]
list of sampled characters:
[‘w’, ‘p’, ‘z’, ‘z’, ‘s’, ‘y’, ‘v’, ‘p’, ‘g’, ‘k’, ‘q’, ‘z’, ‘w’, ‘w’, ‘w’, ‘r’, ‘j’, ‘f’, ‘l’, ‘b’, ‘n’, ‘x’, ‘n’, ‘q’, ‘g’, ‘r’, ‘\n’]

AssertionError Traceback (most recent call last)
in
19 print(“\033[92mAll tests passed!”)
20
—> 21 sample_test(sample)

in sample_test(target)
15 assert indices[-1] == char_to_ix[‘\n’], “All samples must end with \n”
16 assert min(indices) >= 0 and max(indices) < len(char_to_ix), f"Sampled indexes must be between 0 and len(char_to_ix)={len(char_to_ix)}"
—> 17 assert np.allclose(indices[0:6], [23, 16, 26, 26, 24, 3]), “Wrong values”
18
19 print(“\033[92mAll tests passed!”)

AssertionError: Wrong values

B This is my code

{moderator edit - solution code removed}

You filed this under AI Discussions, but it is a question about DLS Course 5 Week 1, so I moved it for you by using the little “edit pencil” on the title.

This line makes no sense:

x[idx] = y[idx]

The goal here is to make x a “one hot” vector, but no element of the y vector will be equal to integer 1, right? y is the output of softmax.

Thanks for support!
Sorry so I need change x[idx]=???
I not yet clear it

Yes. You may need to re-read the instructions and additional hints for step 4.

Right! The key point is that we want x to be a one hot vector representing the index that we sampled. Remember what the definition of a one hot vector is: it is a vector with all zeros except for a one in the position of the relevant index, right? Hence the name “one hot”. :nerd_face: Although I guess now that I think about it the word “one” in the name plays two roles there. :grinning: