Week3 E1 ValueError: shapes (5,10) and (5,10) not aligned: 10 (dim 1) != 5 (dim 0)


ValueError Traceback (most recent call last)
in
15 parameters_tmp[‘by’] = np.random.randn(2, 1)
16
—> 17 a_next_tmp, c_next_tmp, yt_tmp, cache_tmp = lstm_cell_forward(xt_tmp, a_prev_tmp, c_prev_tmp, parameters_tmp)
18
19 print(“a_next[4] = \n”, a_next_tmp[4])

in lstm_cell_forward(xt, a_prev, c_prev, parameters)
56 it = sigmoid(np.dot(Wi,concat)+bi)
57 cct = np.tanh(np.dot(Wc,concat)+bc)
—> 58 c_next = (np.dot(ft,c_prev))+(np.dot(it,cct))
59 ot = sigmoid(np.dot(Wo,concat)+bo)
60 a_next = np.dot(ot,np.tanh(c_next))

<array_function internals> in dot(*args, **kwargs)

ValueError: shapes (5,10) and (5,10) not aligned: 10 (dim 1) != 5 (dim 0)

Look at the dimensions for dot product: (n, m) \cdot (m, o) = (n, o)

That said, * refers to element-wise multiplication and not dot product.

1 Like

Ok I got it! thanks a lot