Week 3 assignment plotting decision boundary

Till predict I got everything working “All Test Passed” but plotting decision boundary i am getting this error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-106-11bad20c9992> in <module>
      3 
      4 # Plot the decision boundary
----> 5 plot_decision_boundary(lambda x: predict(parameters, x.T), X, Y)
      6 plt.title("Decision Boundary for hidden layer size " + str(4))

~/work/release/W3A1/planar_utils.py in plot_decision_boundary(model, X, y)
     14     # Predict the function value for the whole grid
     15     Z = model(np.c_[xx.ravel(), yy.ravel()])
---> 16     Z = Z.reshape(xx.shape)
     17     # Plot the contour and training examples
     18     plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral)

AttributeError: 'list' object has no attribute 'reshape'

This suggests there is an issue in your predict() function with how it is storing the “predictions” values.

Please post a screen capture image that shows the results of the cell that runs the “predict_test_case()”.

2 Likes

The prediction vector that I was creating was not of the right data type hence there was a problem. I am now able to resolve it thankyou.

1 Like