Deep Learning course 1, Week 3, Assignment 2

Here’s an error, I am facing

Please provide your code in the forward_propagation() function for investigation.

Hi, @iqra. Although it is undoubtedly helpful to the mentors and learners to inspect one’s code, it is a violation of the honor code to show that work to the community and public at large (even if it is at the request of a mentor!) It would be great if you could delete your code and repost.

Many thanks,
Ken B

2 Likes

PS. You handled your original request appropriately, posting only the traceback (i.e. error messages). Thanks!

1 Like

Hi, @kenb. Help me to solve the above error.

It would be helpful if you could post the entire traceback. It appear to be clipped at the bottom. That’s often where the the most useful information lives.

As @sammykyu pointed out, the problem appears to reside in the forward propagation() function. Can I assume that all of your functions have passed their tests prior to nn_model? The traceback is telling you that the final activation is incorrectly shaped.

1 Like

Hi, @iqra. Sorry for the delay; I lost track of your question in the shuffle. The traceback is throwing an assertation error when forward_propagation() is called from nn_model(). The relevant line in the former function is

assert(A2.shape == ((1, X.shape[1]))

This line is checking that the activation in the output layer is of dimension (1, m), where m is the number of training examples. In this assignment, we have a binary classification problem, so the number of nodes in the output layer must be one. If forward_propagation() passed its tests–not raising this AssertionError in the process–then we should look for the problem downstream in nn_model().

One potential source of error is the first line of code for you to complete: parameters = .... Check that the positional arguments in the required function (they are all positional) are correctly ordered. If not, they could trip the aforementioned AssertionError.