Course 2 Week 3 Exercise 6 Question

Hi (first of all; I’ve checked the related posts but couldn’t find a solution to my problem)!

I’m getting “Test does not match. Did you get the reduce sum of your loss functions?” error. I’ve used transpose, reduce_sum (or reduce_mean) but can’t get the correct result.

I suspect a mistake in previous functions. In exercise 2, with the sigmoid function, I pass the tests but the expected output provided is different than what I get (mine shows the tensor’s value along with its data type and shape instead of the expected output that only shows the value). I wonder if this could be a reason.

And in exercise 4, with the initialize_parameters function, I hard-coded the size of the variables that were initialized. Again, I passed the tests but I wonder if this could have caused a problem in Exercise 6.

Help please!

Here’s a thread with a checklist of the most common errors on compute_total_loss.

That was one of the posts I had checked out which didn’t help me resolve my problem. Thanks anyways.

Please show us the output you get of the failed test case.

I hope you have transpose both logits and labels by setting parameter from_logits=True for total loss function.

Also when you are mentioning using reduce_sum, you have referred this instruction * tf.reduce_sum does the summation over the examples.

Yes, initializing the parameters using hard-coded values is what’s expected.
It’s a terrible implementation, but that’s what this assignment uses.

Here it is:
tf.Tensor(6.7393394, shape=(), dtype=float32)

AssertionError Traceback (most recent call last)
in
17 print(“\033[92mAll test passed”)
18
—> 19 compute_total_loss_test(compute_total_loss, new_y_train )

in compute_total_loss_test(target, Y)
13 print(result)
14 assert(type(result) == EagerTensor), “Use the TensorFlow API”
—> 15 assert (np.abs(result - (0.50722074 + 1.1133534) / 2.0) < 1e-7), “Test does not match. Did you get the reduce sum of your loss functions?”
16
17 print(“\033[92mAll test passed”)

AssertionError: Test does not match. Did you get the reduce sum of your loss functions?

Yes, I used transpose for both logits and labels, set from_logits=True and used tf.reduce_sum.

OK. Thanks.

@Zeynep_Akcay, are you still having troubles with this assignment?

Sorry, I meant to close the loop on the public thread: I had a DM conversation with Zeynep yesterday and the problem is resolved. The issue was that the positional arguments to the TF loss function were in the wrong order. For the record, that is one of the issues that was mentioned on the “checklist” thread that I linked earlier in the conversation.