Sequence Models: Week 1 assignment: Dinosaur Island

Hi, Could someone help with the ‘Sample()’ function for Dinosaur Island? My first output in the list of indices is correct, but the rest are wrong. I suspect it has to do with the hints about ‘ravel’ and/or ‘append’. I have read the hints but dont see how to incorporate the hints in the code.

Below is what I have for Step 3:

    # Step 3: Sample the index of a character within the vocabulary from the probability distribution y
    # (see additional hints above)
    idx = np.random.choice(range(len(y[:,counter])), p = y[:,counter])

    # Append the index to "indices"
    indices.append(idx)

I figured out the problem. I had initialized x and a_prev to row vectors instead of columns. This caused my y to be the wrong shape (27x100 instead of 27x1)

That’s great that you were able to find the solution under your own power. Nice work!