Unable to pass an assignment due to test cells

I am stuck on the Week 2 assignment of Logistic Regressions.
I am getting the Assertion error again and again.

[ValidateApp | INFO] Validating ‘/home/jovyan/work/submitted/courseraLearner/W2A2/Logistic_Regression_with_a_Neural_Network_mindset.ipynb’
[ValidateApp | INFO] Executing notebook with kernel: python3
[ValidateApp | ERROR] Timeout waiting for execute reply (30s).
[ValidateApp | ERROR] Interrupting kernel
[ValidateApp | ERROR] Timeout waiting for execute reply (30s).
[ValidateApp | ERROR] Interrupting kernel
Tests failed on 2 cell(s)! These tests could be hidden. Please check your submission.

The following cell failed:

dim = 2
w, b = initialize_with_zeros(dim)

assert type(b) == float
print ("w = " + str(w))
print ("b = " + str(b))

initialize_with_zeros_test(initialize_with_zeros)

The error was:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-11-4f77d2aa60f4> in <module>
      2 w, b = initialize_with_zeros(dim)
      3 
----> 4 assert type(b) == float
      5 print ("w = " + str(w))
      6 print ("b = " + str(b))

AssertionError: 

==========================================================================================
The following cell failed:

from public_tests import *

model_test(model)

The error was:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-19-9408a3dffbf6> in <module>
      1 from public_tests import *
      2 
----> 3 model_test(model)

~/work/submitted/courseraLearner/W2A2/public_tests.py in model_test(target)
    117     assert type(d['costs']) == list, f"Wrong type for d['costs']. {type(d['...
    118     assert len(d['costs']) == 1, f"Wrong length for d['costs']. {len(d['cos...
--> 119     assert np.allclose(d['costs'], expected_output['costs']), f"Wrong value...
    120 
    121     assert type(d['w']) == np.ndarray, f"Wrong type for d['w']. {type(d['w'...

AssertionError: Wrong values for d['costs']. [array(0.15900538)] != [array(0.693147...

What should I do now?

Hi @pragatisharma,

I have moved this post to the DLS Course 1 category as other learners taking the same course might benefit from this.

Kindly make sure if you have any course-specific queries, explore the specialization category and post in the relevant course subcategory as course-specific mentors are actively answering the queries there. The General Discussions category is not monitored by our mentors.

If you are unclear about how to use Discourse, we have made this guide for our learners. I believe that reading this will help you out posting in the appropriate categories next time.


Happy Learning!!
Sharob

hi @pragatisharma , welcome to the discourse community. As a quick note, it is practice not to post solutions on the platform, so I have removed your solution from the post. The error you get is actually quite common. The system is checking whether your parameter b is of data type float, so with numbers of both sides of the decimal. By initializing with b = 0 (in you above code snipit), you actually initialize it as an integer. So what do you need to do to make sure b is of type float?
Hope this helps you in finding the right solution.

3 Likes