Hello All
I have a question about week 3 (Assignment 3) of NLP C3
In Exercise 04 (4.2 Classify), my codes did not pass the unit test with following error message:
Not sure if something wrong in my code, please help me out
Hello All
I have a question about week 3 (Assignment 3) of NLP C3
In Exercise 04 (4.2 Classify), my codes did not pass the unit test with following error message:
Not sure if something wrong in my code, please help me out
It’s hard to say, but it looks like you have a problem with slicing.
Make sure you use test_Q1
and test_Q
in your function (and not Q1_test
and Q2_test
).
Also, remember that v1
and v2
make one half of pred
each (on the last dimension). So make sure that are yous slicing the pred
correctly.
There might be other issues in your code. Did you get the expected result before the unit test?
Hello arvyzukai
Thank you so much for your reply. I checked the code and can confirm that test_Q1
and test_Q2
are used in my function. In fact, the test dataset is wrapped by tf.data.Dataset.from_tensor_slices
in the given code, I do not deal directly with test_Q1/2
.
Also, I followed the example in the assignment to extract the v1
and v2
. But as you mentioned, my result before the unit test is slightly different from the expected one:
Do you have a clue?
You are correct that you don’t need it here, but you might use it in the further calculations (in particular, accuracy, but not necessarily since you can use other variables in their place).
One reason for that could be your d
calculation (and comparing against a threshold). The instructions are not the best in this case, but the code comment is better).
Another reason could be your trained model (did you pass the tests for it?) and it’s predictions.
Calculation of accuracy might not be the problem, since your confusion matrix does not match the expected.
One reason for that could be your
d
calculation (and comparing against a threshold). The instructions are not the best in this case, but the code comment is better).
For each pair questions, my code used tf.math.reduce_sum
as suggested in the comment, and reduced all the dimensions.
Another reason could be your trained model (did you pass the tests for it?) and it’s predictions.
My code passed all other four unit tests, except this one.
Do you want to check my code? I can send it to you.
I have the same error, even though my function outputs the exact same values as the required output. I think there is an error in the test unit.
Maybe you could reach out the mentors in the forum, they are quite helpful to review the code. In my case, they solved my question. It turns out I used another way to attach the problem, which is not recommended by the deeplearning framework.
I got same errors too and even worse:
My output is:
Accuracy 0.54189453125
Confusion matrix:
[[3902 2480]
[2278 1580]]
and
[test_case(msg=‘There was an error evaluating the classify
function. ‘, want=None, got=’{{function_node _wrapped__Pack_N_2_device/job:localhost/replica:0/task:0/device:GPU:0}} Shapes of all inputs must match: values[0].shape = [3500] != values[1].shape = [3584] [Op:Pack] name: stack’, failed=True)]