Deep Learning Specialization: C5W1_Assignment_2

Hi, I need help with sample().

It’s not clear to me how to compute idx in step 3 of sample() in C5W1_Assignment_2, given that y is not 1D array. Raveling the array does not give me the correct sequence. Is there anything else that needs to be done to y besides raveling it ?
Thanks

I’ll provide some very broad hints, because the code is a bit of a puzzler
The index values come from calling np.random.choice(), with two parameters:

  • The first is the range of the vocabulary size.
  • The second is the ‘p’ parameter (for the probabilities), set equal to using y with the ravel() method.
1 Like

I added some print statements to my code to show the shapes of everything and here’s what I see:

vocab_size = 27
Wax (100, 27) dot (27, 1) + Waa (100, 100) dot a_prev (100, 1)
Wya (27, 100) dot (100, 1) + by (27, 1)
y.shape (27, 1)
len(y) 27