I am doing the one hot encoding in this assignment. The instruction says it must return a column vector
But when I look into the test it is trying to compare the result against a row vector
So even though my function is returning a column vector it keeps failing at the below assert.
Not sure what I am missing, can someone help
assert np.allclose(result, [0., 1. ,0., 0.] ), “Wrong output. Use tf.one_hot”
1 Like
If that’s the assertion that is failing, notice that the array they are comparing against is actually a 1D array meaning that it has no orientation. It’s not a “row” or “column”, it’s just a vector. But if that compare fails, are you sure that there’s not something else wrong? E.g. the values or the number of values?
1 Like
Oh, sorry, I just tried this and that assertion does fail if you produce a 2D array. The problem is that the instructions are wrong. Eeeeek! You want a 1D output for this function.
I will file a bug right away to get the instructions fixed. Sorry that no-one had noticed this issue until now! I’m kind of shocked actually now that I see it.
2 Likes
Ok, the bug is filed. One other thing I noticed in the process of doing that is that they actually gave you the code in the comments to produce the correct 1D shape:
# (approx. 1 line)
# one_hot = None(None(None, None, None), shape=[C, ])
# YOUR CODE STARTS HERE
But it’s totally legitimate to point out that the instructions are just wrong and everything should be consistent here.
Thank you. I did see the instruction, but then I thought that the instruction had a typo
1 Like
Fair enough! Actually they said it incorrectly in two places: both the instruction text before the function cell and in the “docstring” comment in the function body they said it should be a column vector. So two out of three is a majority in any case.
The bug is filed. Since it’s only text stuff, they usually fix that sort of thing pretty quickly.