TensorFlow introduction Assignment - getting shapes correctly

Dear All.

I am posing this question since I can’t understand how to interpret it:

In the Exercise 3 - one_hot_matrix, one must reshape the tensor, using the one_hot_encoded values previously, and then reshapping those. If we are asked clearly on the commented section of that assignment that:

“Returns: one_hot – tf.Tensor A single-column matrix with the one hot encoding.”

I got my answer right, but I have a “no column” tensor:

“Test 1: tf.Tensor([0. 1. 0. 0.], shape=(4,), dtype=float32)
Test 2: tf.Tensor([0. 0. 1. 0.], shape=(4,), dtype=float32)
All test passed”

Isn’t this contradicting the instructions that we have on building the on_hot_encoding?

Kind Regards.
Ricardo

Yes, I think you’re right that the wording there is maybe a bit awkward. What you end up with is a 1D tensor, which is not really the same thing as a column vector (a 2D object).

The other issue here is that the test cell for one_hot_matrix doesn’t catch the error of using a scalar value as the target shape on the reshape. You can’t really be sure your one_hot_matrix code is correct until you run the cell that applies “map()” to produce the one hot encoded version of the training and test data. That cell will “throw” if you use a scalar shape.