Week 3 assignment: Planar Data Classification with One Hidden Layer

Greetings. In update_parameters section I keep on getting the error:

ufunc ‘subtract’ did not contain a loop with signature matching types (dtype(‘<U32’), dtype(‘<U32’)) → dtype(‘<U32’)

And the error happens at the line where values are updated: W1 = W1 - dW1*learning_rate

Is there anything I am missing?

My lab id is xnfauqjgafcg

Hi @Mohammad_Hossein_Rez

How is dW1 obtained?

Hello @Mohammad_Hossein_Rez! I hope you are doing well.

The formula you mentioned for updating W is correct but how you are defining the below terms?

# Retrieve a copy of each parameter from the dictionary "parameters". Use copy.deepcopy(...) for W1 and W2
#(≈ 4 lines of code)
# W1 = ...
# b1 = ...
# W2 = ...
# b2 = ...
# Retrieve each gradient from the dictionary "grads"
#(≈ 4 lines of code)
# dW1 = ...
# db1 = ...
# dW2 = ...
# db2 = ...
As you can see, updating the parameters depends on the above terms.
Did you pass all the previous tests? If so,  then check the code of 
`Exercise 4 - forward_propagation` for a hint.

# Update rule for each parameter
#(≈ 4 lines of code)
# W1 = ...
# b1 = ...
# W2 = ...
# b2 = ...

Hi. Thanks for the help. I changed W1 = copy.deepcopy(“W1”)
to W1 = parameters[“W1”] like previous sections and it worked like a charm.
Don’t know why it mentioned using deepcopy

The deepcopy is necessary to avoid modifying the global object. The reason your deepcopy did not work is you are copying the string name, not the actual parameter value.

Here’s a thread which explains why the copy is a good idea.