Week 4 assignment 1 exercise 4 error

When I was trying to run the function linear_activation_forward, I encountered such error

ValueError: not enough values to unpack (expected 2, got 1)

I put the weight parameter and the previous activation in the NumPy dot function, but it reports this error. I tried to replace A_prev with other matrices and all got other errors, which is about the incorrect dimension. It seems this ValueError only occurs for A_prev, I am so confused about why and have no idea about how to solve this. Can anyone help me?

Hey @ZhixiongChen,
I can’t see the use of numpy.dot() in the linear_activation_forward function. Can you please confirm if you have used the linear_forward function inside the function? It seems to be that you have used numpy.dot() instead of the linear_forward function, and it only returns a single value, while if you use the linear_forward function, it returns 2 values, which is what the function expects you to use.

In general, this error arises in the case when you are trying to unpack more values than the function is returning, for instance, consider the below example:

def mysum(a, b):
    return a + b

c, d = mysum(2, 3)

In the above and similar cases, you will get the above error. I hope this helps.


1 Like

Oh, I got it, I misunderstood the process, thanks for clarifying! It now works!