C5 W4 A2: Wrong values: Sampling Ex.2.2 (Dinasaurus island)

I’ve been struggling with this for more than a day , any inputs appreciated -
I’ve dumped the shapes and output.

idx = np.random.choice(np.arange(vocab_size), p=y.ravel())

vocab_size = 27
np.shape(x) = (27, 1)
np.shape(Waa) = (100, 100)
np.shape(Wax) = (100, 27)
np.shape(Wya) = (27, 100)
np.shape(by) = (27, 1)
np.shape(b) = (100, 1)
np.shape(a_prev) = (100, 1)
np.shape(y) (27, 1)
np.sum(y) 1.0


Sampling:
list of sampled indices:
[11, 23, 16, 15, 1, 23, 23, 13, 17, 17, 0]
list of sampled characters:
[‘k’, ‘w’, ‘p’, ‘o’, ‘a’, ‘w’, ‘w’, ‘m’, ‘q’, ‘q’, ‘\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

Hi @GokulT,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.

Thanks,
Mubsi

hi @Mubsi

My lab ID is saibbkzr
awaiting your reply. thanks for you help!

-Gokul

1 Like

Hi @GokulT,

Your mistake was in Ex 2. You were initialising z incorrectly. You were passing in the incorrect variable. More left in your notebook.

Also, I noticed you added quite a few print statements in your notebook, be sure to delete the ones you added, otherwise the grader will have trouble grading your assignment.

Happy learning,
Mubsi

thanks @Mubsi ! Appreciate your prompt response!

@mubsi I have very similar error, except first few indexes look correct
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]
my lab id hxjlvunx

Hi @Oleksandr_Semenov,

There were quite a few mistakes in your Ex 4. You can look at your notebook for more details.

Best,
Mubsi

1 Like

I’ve been struggling to this this working. Keep getting “wrong value” assertion.

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

Found the problem and it’s working !

Hi, I am having a similar issue in ex 2 Dinasaurus Island, my id is abbpiqfb . Could you help me, I am stuck in this for a while