Hi am totally stumped how to use a combination of ravel and np.random.choice to draw an index in 0 to 27, from an array of probabilities of shape (27,100).

The best I’ve been able to come up with is:

mentor edit: code removed

But this is clearly wrong.

Any help on this silly bit of the assignment would be really appreciated

Your problem is that the shape of y should be (27,1) and not (27,100). That is probably what is causing the difficulty with np.random.choice. I added some print statements to show the dimensions of everything. Comparing to that may give some clue as to where your code goes off the rails:

I don’t understand what I am doing wrong in the z = Wyaa + by step then, using np.dot. Wyaa is a matrix of size (27,100). And softmax doesn’t change the size of the input. So what am I doing wrong here?

In setting a_next (just a in the code) Waa .dot. a_prev is a 100x100 matrix. … what the heck am I doing wrong?

Did you look at the dimensions that I showed above? If you dot (27, 100) with (100, 1), you end up with (27, 1), right? So why did that not happen in your case? I’ve given you the information, now you need to do some thinking. Your a is the wrong shape. I suggest you compare your code for computing a to the mathematical formula given in the instructions.