# DLS Course 5 Week 1 Assignment 2 Dinosaur shape input problem

Hello friends,

It would be nice if someone could explain function def sample(parameters, char_to_ix, seed), specifically a(t+1) calculation. The formula is πβ¨π‘+1β©=tanh(πππ₯π₯β¨π‘+1β©+ππππβ¨π‘β©+π). As a result, in python for me it looks like a = np.tanh(np.dot(Wax, x) + np.dot(Waa, a_prev) + b). x and a_prev I initialize as x = 0, a_prev = 0. However, when I try to run the function it gives error at a(t+1) calculation saying : ValueError: operands could not be broadcast together with shapes (100,27) (100,100) . These shapes come from Wax = (100, 27), Waa = (100, 100).

It would be nice if someone could explain how we are supposed to sum up these different kind of matrices. Maybe the problem is in my formula implementation or x and a_prev initialization?

Best regards,
Roberts

Your code for βa = β¦β is correct.
The problem is your initialization of x and a_prev. Theyβre vectors, not scalars.

Hi @TMosh, can you help me?

I have the same issue (and same code for βa=β¦β), but my initialization of x is a np array of size βvocab_sizeβ, and my vector βa_prevβ is another np array of size βnaβ.

I canβt see my mistakeβ¦

Okβ¦ they should be 2D vectors