DLS course5, wk1, Dinosaur Island lab -- need a hint

Hi @ydsk1234 ,

Looking at the output generated, the first time going through the while loop, there is no problem in executing the statement:
idx = np.random.choice(range(vocab_size), p= np.ravel(y))
However, on the 2nd time it went through the while loop, valueError is raised because there is a mismatch of a and p.
Within the while loop, x is changed, and x is used in the calculation of a that eventually produced y. And the offending line is :
x = np.zeros(Wax.shape[1])
making x a 1D array of vocab_size without specifying what that array is. In step 1 of your code,
x = np.zeros((Wax.shape[1], 1)), you specified x is a column vector of vocab_size number of elements. That change in x is causing the problem.

To make the code easier to read, may I suggest you use vocab_size consistently across the code.

Here is a post on vector written by one of our mentors that you may find useful.