Week 1 - Assignment 1 - Exercise 3

I have some doubts regarding the multiplications in exercise 3.
when we calculate the cell state variable by the given equation:

ft * c_prev + it * cct

and the dimensions of the elements of this equation (considering the test case) is

c_prev: (5, 10)
cct: (5, 10)
ft: (5, 10)
it: (5, 10)

and the resulting dimension is

c_next: (5, 10)

my question is:
why does broadcasting work when I use element-wise multiplication "*" but when I use dot product it produces an error?
Note: my question is regarding the broadcasting (regardless of the correctness of the output)
any help would be appreciated.

Maybe I’m confused, but I think this has nothing to do with broadcasting.

Element-wise products require that the shapes of the two operands be identical. (5,10) * (5,10) works fine. Note that it doesn’t include computing the sum of the products.

Using a dot product requires that the inner dimensions of the operands be the same. So (5, 10) dot (5,10) will give an error. You would have to transpose the second operand so you have (5, 10) dot (10, 5). And the dot product will also compute the sum of the products.

Tom has addressed the particular situation you showed. The general answer is that the definition of broadcasting is that it can expand a vector to match the size of a matrix for an operation that requires two operands of the same shape. So it only applies to “elementwise” operations. Of course that covers other elementwise operations besides just multiplication. That is what broadcasting is for, so it is not relevant to the dot product case, because that (by definition) is not about operands with the same shape.