Unsupported operand type for *

Hello, I just couldn’t find the source of error. Can anyone help figure this out?

Why are you calling propagate twice like that? In python, you can return more than one return value from a function. Look at the return statement in the template code that they give you for propagate. Here’s what it looks like (this is ok to show, since the code is given to you):

    grads = {"dw": dw,
             "db": db}
    
    return grads, cost

So there are two mistakes you are making: the return values are not w and b and you should only invoke the function once.

Just for future reference, it is possible to assign the output of a function that returns multiple separate values to a single output value. But what python does in that case is maybe a bit surprising, e.g. different from what MATLAB does in that case: it creates a single python “tuple” that contains all the return values. That is the reason for the bizarre sounding error you get from propagate the second time you call it: the w value you are passing there is a 2-tuple containing the dictionary grads and the list costs from the first call to propagate, instead of a simple numpy array.