W4_A2 issue with datatype mismatch

I’m having an issue with Week 4 assignment 2, I implemented the functions similar to in the previous assignment. Yet, I am getting the error below.

I looked through many of the other posts here and confirmed I’m not using any global variables in my functions. However, I am a bit confused that in the test cell (that we cannot edit), the learning rate is not set (“parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)”)

but the function definition “def two_layer_model” wants a learning rate… I set it like “two_layer_model(X, Y, layers_dims, num_iterations , print_cost=False,learning_rate=learning_rate):” so that it is in the same order as the function call, but I do find it a bit weird.

the error I get:
Cost after iteration 1: 0.6926114346158595
Cost after first iteration: 0.693049735659989
Error: Datatype mismatch.
Error: Wrong shape
Error: Wrong output
Error: Wrong output
0 Tests passed
4 Tests failed

AssertionError Traceback (most recent call last)
3 print("Cost after first iteration: " + str(costs[0]))
----> 5 two_layer_model_test(two_layer_model)

~/work/release/W4A2/public_tests.py in two_layer_model_test(target)
75 ]
—> 77 multiple_test(test_cases, target)

~/work/release/W4A2/test_utils.py in multiple_test(test_cases, target)
140 print(‘\033[92m’, success," Tests passed")
141 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
→ 142 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.

I appreciate any feedback you have!

No. two_layer_model don’t need the learning rate. And, don’t change the arguments. Only do your code where it is mentioned that:



You just need to call the correct function at the correct place.

Also make sure to use the correct initialization routine: the “deep” version gives a different answer if you use that in the “two layer” case, although it shouldn’t give you a different datatype. Also note that you do not need to “hand copy” over your functions from Week 4 Assignment 1: you can just call them.