C3W3 assignment Classify test issue


Above shows that my # GRADED FUNCTION: classify code works well on the example and agrees with expected result. But w3_unittest.test_classify has issues. It seems that tensors have issue; but this is related to tester case, not really to the code? I am not sure how to debug without knowing what kinds of tensors are being fet to the classify module. May be someone has a suggestion on this.
Thank you
DS

If you want, you can open test case code for review with “File → Open” and choose the test file.

99% of the time, the test cases are OK. Usually, the learners’ code is to blame for using global variables or other flaws.

Cheers

Hi arvyzukai,
It is not so easy to debug, because the error points to issue in the way Q1 and Q2 are handled. And they are handled OK in a simple exersise following the classify code. I cannot print Q1 and Q2 because tester supresses prints. So I need to modify tester code and then there are a lot of support scripts called by the tester, etc etc. I think this is too much.
I already passed the class (this lab passed non-full score) and ready to move to the next class. I wonder if I can give you my code so you could compare with the correct code and let me know where I handle wrong; this is just for my curiosity.
Thank you!
DS

Hello @Dennis_Sinitsky

Did you take the average of correct predictions to get the accuracy? kindly use
tf.reduce_mean to the accuracy code.

Regards
DP

Hi Deepti,
this is the tf.reduce_mean line of my code:
accuracy = tf.reduce_mean(tf.cast(tf.equal(y_pred, y_test), tf.float64))
wen y_pred=y_test, it will assume 1 (otherwise 0) and average over all comparison events.

1 Like

code is partly incorrect, please do not use tf.equal and also in accuracy we check if if the values of two operands are equal or not , so use == between the actual targets and predictions.

Finally! I figured it out!!! :exploding_head: :grin:

The mistake was that I did not use test_gen. I defined pred = model.predict(with Q1, Q2)
but I had to define pred=model.predict(with test_gen)
I guess, dataset format is key for model.predict input!
Now it works. Thanks Deepti and Arvy!
DS

2 Likes

I guess, the key point here is that if something is defined by instructor in the code, it has to be used. Like test_gen in my case. If it is not used, this is recipe for mistakes :slight_smile:

1 Like

there many response of arvy on these courses, which also helped me resolve many issue. but sometimes its at the end arvy’s help required in some scenario as this courses updated is nail-biting.

Regards
DP

2 Likes