W1A2 exercise 2 - sample fails to return the right sequence

Hi fellow learners,
I have a problem with sample() function implementation. The sequence of characters is wrong from the very first element:

list of sampled indices:
 [11, 23, 16, 15, 1, 23, 23, 13, 17, 17, 0]

After reading other messages on the topic, I believe that array sizes are correct. I don’t use ravel(), instead I do < array >[:,0]

This is the value of y at the first iteration:

[0.0880708  0.25386789 0.02448389 0.00954239 0.00096825 0.01139706
 0.06803848 0.00629608 0.00886329 0.03859099 0.03716321 0.02795975
 0.0489836  0.0312244  0.01504909 0.04418995 0.01315312 0.02003612
 0.03611465 0.01445192 0.04299119 0.01107991 0.01314782 0.03202066
 0.02216931 0.01923099 0.06091519]

Hints?

Interesting. I just checked my notebook for the Dinosaur Names assignment and my sample function was able to match exactly the “expected” values that they show. I assume you’ve been over the instructions carefully and compared them to your code. They also give lots of fairly detailed instructions and hints in the comments in the template code.

If you’ve already checked all that without finding a solution, then it’s probably time to look at your code. We can’t do that on this public thread, but please check your DMs for a message from me about how to proceed. You can recognize DMs (private messages) in your “feed” by the little envelope icon.

Just as a reference for other learners: in case of doubts, check the formulas and ensure that you are using the variables at the intended timestep (t, t+1…)

1 Like