Hi, I am taking this course on Coursera and finished the assignment.
I had an error that I see multiple people before me also reported:
ValueError: The two structures don’t have the same sequence length. Input structure has length 1, while shallow structure has length 10.
I reviewed my solution for UNQ_C2 as responses tend to point to issues here but I could not find issues.
I did notice that in order to have “Exercise 3” # UNIT TESTS to run validly I had put the metrics in double [[…]] braces because it takes element 0 and still expects that to give a list.
Because this did not seem right I eventually removed the outer [[…]] braces to have metrics=[…]
When I ran the model it no longer gave the length issue and when checking the results it was also doing fairly well (although on the first example it gave the 33’rd as the day where it should be 3)
When I ran the coursera auto-grader it also told me my solution was correct.
I would like to double check that my solution is indeed correct.
If so the unit test code that failed in my final solution may also need to be adjusted to:
assert model.compiled_metrics._user_metrics == [‘accuracy’], “set metrics to [‘accuracy’]”
This is mostly likely just an issue of your notebook being out of sync in the sense that typing new code and then calling the function does nothing: it just runs the old code again. You have to click “Shift-Enter” on the actual changed function cell in order to get the new code incorporated into the “runtime” image. Or do “Kernel → Restart and Clear Output” followed by “Cell → Run All”.
If the grader passes your code and it runs fine in the notebook after doing the above sequence then it’s all good.
I see that when I refreshed the workspace the unit test line changed from:
assert model.compiled_metrics._user_metrics[0] == [‘accuracy’], “set metrics to [‘accuracy’]”
to
assert model.compiled_metrics._user_metrics[0] == ‘accuracy’, “set metrics to [‘accuracy’]”
Which also indeed makes more sense. I’m pretty sure I did not edit the code in the Unit test myself. I guess I somehow got an outdated version to start with indeed (or some user error on my part)
Ok thanks for confirming my solution. I guess there is also nothing to be fixed ^^
Can be closed (if closing topics is a thing here?)
Just did realize that this formulation of the Unit test would allow the learner to add more then 1 metric and still pass the test.
From the Keras documentation it seems like metric’s are purely esthetic in that it allows the developer to look at the metric of choice to evaluate performance but it does not affect the models performance itself? Is that correct?