W 2 A2 | Ex- 8 | Dimension problems

I am trying to combine all of the previously-written functions into a single function.

(Solution code removed, as posting it publicly is against the honour code of this community)

I believe I have a problem that starts with the initialize_with_zeros function. I think that dim should equal 2 (one for 2, one for b), but doing so gives me the following error:


which I take to mean that the shape generated by initialize_with_zeros is incompatible with the next function, propagate. I do not know why the propagate has (4,7) shape, but when I try to correct this by setting dim = 4, the error moves down to the optimize function:

which I take to mean that only a single w value and a single b value should be passed along–not 4.

Hi @Nicklaus_Millican,

Please make sure you are not using any hard-coded values on the functions, unless specifically asked to do so.

Best,
Mubsi

Hi @Nicklaus_Millican,

  • For initialising w, b, you are using a hard-coded value. NEVER use a hard-coded value inside of a graded function unless specifically asked to do so.

  • If you look at the skeleton code, you’ll see the expected variables you are suppose to initialise:

# (≈ 1 line of code)   
# initialize parameters with zeros 
# w, b = ...
    
#(≈ 1 line of code)
# Gradient descent 
# params, grads, costs = ...
    
# Retrieve parameters w and b from dictionary "params"
# w = ...
# b = ...
    
# Predict test/train set examples (≈ 2 lines of code)
# Y_prediction_test = ...
# Y_prediction_train = ...

After looking at this, you’ll realise that for this exercise, you didn’t initialise the variables params, grads, costs = ..., w = ... AND b = ... (please note w, b = is not the same as w = and b =).

Similarly, you computed grads, cost = and params, grads separately, which is not the same as computing params, grads, costs =

You can take a look at your notebook for more details.

Best,
Mubsi

1 Like

Aha. Many thank, @Mubsi !

1 Like