Week 1 Sequence Model Dinasour: np.allclose(indices[0:6], [23, 16, 26, 26, 24, 3]) ERROR

Hello guys,
I need some help with the following problem in:

Function sample(parameters, char_to_ix, seed):

I believe the issue is here:
I used these 2:

idx = np.random.choice(range(len(y.ravel())), p = y.ravel())
idx = np.random.choice(list(range(vocab_size)), p = y.ravel())

I get
list of sampled indices:
[23, 16, 26, 26, 24]
list of sampled characters:
[‘h’, ‘p’, ‘i’, ‘i’, ‘\n’]

But the error says
ValueError: operands could not be broadcast together with shapes (5,) (6,), which is related to

assert np.allclose(indices[0:6], [23, 16, 26, 26, 24, 3]), “Wrong values”

It makes sense because my result is (5,) but the assert is (6,). Why I get this difference?

Nevermind guys… I went back in time. Used the checkpoint to clear all. Retyped everything and it worked perfectly :confused: So likely I deleted something without noticing and it created some error…but I don’t know what it was…anyways…

1 Like

Hey @statsconchris, please be mindful about posting your queries in the right category. You are posting your query in the General Discussions - AI new, jobs, career advice category. This category is not monitored by our mentors. Your specific query belongs to DLS Course 5.

If you are unclear about how to use Discourse, we have made this guide for our learners. Hopefully reading it will help you out in posting in the appropriate categories next time.

For now, I have moved your post in the DLS Course 5 category. For future, in order to get swift responses, post in the appropriate categories.

Thank you and happy learning!