Course 2 Week 1: Neural network implementation in python, dense function question

In this section of week 1 we see a dense function written out as follows:

def dense(a_in, W, b):
    units = W.shape[1]
    a_out = np.zeros(units)
    for j in range(units):
        w = W[:,j]
        z =,a_in) + b[j]
        a_out[j] = g(z)
     return a_out

In this particular example W is a 2,3 matrix and a_in is a 1d array of length 2. Therefore, the dot product works. However, I had understood from previous examples, that the input activation vector need not be any particular length. But if the length of the activation vector does not match the number of rows in W, then we can’t perform the dot product in the function defined above. IE this function wont work if we have an input activation vector of length 5.

I must have a misunderstanding either of matrix operations or of activation vectors. What am I missing?

Nvm. W will always have number of rows equal to the length of the input activation vector by definition. Longer input vector = more rows in W.