DLS course 5 week1 Help! Second lab:Dinosaur Island-Character-Level Language Modeling. The content of the error report does not match the actual situation

DLS course 5 week1 Help! Second lab:Dinosaur Island-Character-Level Language Modeling. The content of the error report does not match the actual situation.

When I was trying the fix the exercise2- sample, I need to implement this function πβ¨π‘+1β©=tanh(πππ₯π₯β¨π‘+1β©+ππππβ¨π‘β©+π)(1). But I aways get error like: ValueError: shapes (100,27) and (100,27) not aligned: 27 (dim 1) != 100 (dim 0)!!! I used print statements but I can see shapes of Waa, x<t+1>, Waa and a are (100,27), (27,1), (100,100) and (100,1) respectively. What causes that ValueError or this is the systemβs error?

You have to implement this equation:

a^{\langle t+1 \rangle} = \tanh(W_{ax} x^{\langle t+1 \rangle } + W_{aa} a^{\langle t \rangle } + b)

First, you have to use the dot product between W_{ax} and x^{\langle t+1\rangle}, and dot product between W_{aa} and a^{\langle t\rangle}. Then you have to add b with them and then take the Tanh.

Best,
Saif.

Hi, thanks for your reply. Here is my code: np.tanh(np.dot(Wax, x) + np.dot(Waa, a_prev) + b). This is exactly what I was doing. I got β 49 a = np.tanh(np.dot(Wax, x) + np.dot(Waa, a_prev) + b),ValueError: shapes (100,27) and (100,27) not aligned: 27 (dim 1) != 100 (dim 0). I got error. It is strange.

shape of Wax: (100, 27)
shape of x: (27, 1)
shape of Waa: (100, 100)
shape of a_prev: (100, 1)



If so, share the full error.

Hi, yes here are my shapes of four parameters:

The full error is as follow:

But your print statement is after the line that βthrowsβ, so it wonβt get executed, right? Or if thereβs another copy someplace else, then try moving it exactly to be the line before the line that throws so that we can see what weβre really working with here.

Obviously the print statement you show does not match what actually is happening in the line that throws. So the next step as a scientist is to figure out why the two do not match. That is to say: something is flawed about the scientific experiment that you ran, since it produces inconsistent results. So your next debugging step is to figure out why that happened.

Thank you very much. I have solved the problem. The error happened in the second loop because at the end of the first loop, where a new βxβ need to be updated, I updated the variableβs shape as (n_a, vocab_size), but it supposed to be x = np.zeros(((vocab_size, by.shape[1]))), which should match (sequence_lenth, features) convention.