C5-W4 UNQ_C2 Sample() method in Dinosaurus problem

In the sample() method in UNQ_C2,

    # Step 2: Forward propagate x using the equations (1), (2) and (3)
    a = ...
    z = ...      
    y = ... # softmax is applied to z here

y comes back as a (27, 100) matrix. If y ’ s shape was (27, ) sampling is easy using np.choice(). What do with the 100 columns?

np.ravel() results in 2700 size vector.

That is not the correct shape for y, so there is something wrong with your logic. Here are the shapes that I see from some prints that I added in my code:

vocab_size = 27
Wya (27, 100) x (100, 1) + by (27, 1)
y.shape (27, 1)
len(y) 27
len(y.ravel()) 27
type(y.ravel()) <class 'numpy.ndarray'>

Also please note that you filed this under “General Discussions”. Fortunately I recognized the name of the assignment, so I moved it for you to DLS Course 5 (Sequence Models). You’ll have better luck getting help if people can recognize which course and assignment you are asking about. Note that you can move threads by using the little “edit pencil” to the right of the title.