C1_W3_E9 Predict not accepting my activation values

I am attempting to pass my activation values into my prediction array. I’m using np.where to assign my 0 and 1 values based on the A2 value produced by forward_propagation. However, I’m running into the error below and do not understand how to interpret them since my 1s and 0s are definitely integers.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-78-eb08347ef392> in <module>
      1 parameters, t_X = predict_test_case()
      2 
----> 3 predictions = predict(parameters, t_X)
      4 print("Predictions: " + str(predictions))
      5 

<ipython-input-77-998941125bfd> in predict(parameters, X)
     18     # predictions = ...
     19     # YOUR CODE STARTS HERE
---> 20     A2, cache = forward_propagation(parameters, X)
     21     predictions = np.array(np.where(A2 > 0.5, 1,0))
     22 

<ipython-input-12-70b90a51d44d> in forward_propagation(X, parameters)
     18     # b2 = ...
     19     # YOUR CODE STARTS HERE
---> 20     W1 = parameters["W1"]
     21     b1 = parameters["b1"]
     22     W2 = parameters["W2"]

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

I tried to look this up, until I realized week 3 has no associated code.

Can you be a bit more specific ? At least as yet I don’t have all this entirely memorized.

I am not (or do I think any of my friends here are) a GPT.

Its DLS Course 1 Week 3 Assignment 1:
Planar_data_classification_with_one_hidden_layer.ipynb

1 Like

Using np.where() is not necessary. All you need is a logical comparison with >= 0.5.

However, I don’t think that’s where the problem lies. Check the order of your operands.
image

2 Likes

Yes, I can see that now; My brain made a leap and a skip (a lot going on right at present).

I am sorry.

No need to apologize.

This is the solution. I did not have the parameters of the function in the correct order. Thank you.

1 Like