# Course 5 W1 Assignment 2 Exercise 2

I got an error, ‘ValueError: ‘a’ and ‘p’ must have same size’.

Could you kindly help me to find what’s wrong?
The shape of y is (27, 100), is it correct?

If otherwise, the problem is before calculation y, if yes, the problem is after.

Please post a screen capture image showing the entire assert log.
They size of ‘y’ depends on what test you’re running.

I’m guessing you’re talking about the sample() function. No, that is not the correct shape for y, but this is a pretty common error on this function. I added print statements to show the shapes of the matrices and the outputs there. Here’s what I see:

``````vocab_size = 27
Wax (100, 27) x (27, 1) Waa (100, 100) a_prev (100, 1)
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'>
``````

This is the screen shot.

I added print statement.
I think the first time matches your result, but not the second time.

Wax: (100, 27)
x: (27, 1)
Waa: (100, 100)
a_prev: (100, 1)
b: (100, 1)
Wya: (27, 100)
a: (100, 1)
by: (27, 1)
z: (27, 1)
y: (27, 1)
y.ravel(): 27

Wax: (100, 27)
x: (27,)
Waa: (100, 100)
a_prev: (100, 1)
b: (100, 1)
Wya: (27, 100)
a: (100, 100)
by: (27, 1)
z: (27, 100)
y: (27, 100)
y.ravel(): 2700

I found where is wrong, it was step 4, thanks!

It’s great to hear that you found the solution! Thanks for confirming.