Course 5 Week 1 Assignment 1 lstm_cell_forward

The routine lstm_cell_forward throws an error:
“shapes (5,10) and (5,10) not aligned: 10 (dim 1) != 5 (dim 0)”
at the line to compute c_next

Wondering why this is happening. Matrix multiplication is being used and the variables are right. Please help.

If you use dot product (np.dot), the shape needs to be like (n, m), (m, n).
If you have two variables whose shape are identical like (n, m), and you expect the output have same shape, then, you may want to use np.multiply instead. “dot product” and “element-wise multiplication” are different.

1 Like

This makes sense. Thanks, it worked.