Course 2 Week 3 one_hot_matrix error

Hi!
I have been stuck on this problem for a while and eventually found out a solution, so here it is:
All test passed in the definition of the function, but I got an error running this cell:

new_y_test = y_test.map(one_hot_matrix)
new_y_train = y_train.map(one_hot_matrix)

ValueError: Shape must be rank 1 but is rank 0 for ‘{{node Reshape}} = Reshape[T=DT_INT32, Tshape=DT_INT32](Reshape/tensor, Reshape/shape)’ with input shapes: [], [].

The instruction suggests using tf.reshape to reshape the tensor. Using instead np.reshape fixed my problem, I hope it won’t impact the rest of the assignment.

Any other ideas why tf.reshape doesn’t work? Is it just a typo in the instructions or is there really a problem in my code that is making this error pop up?

1 Like

Nevermind, I found the problem in my code. I forgot to check the documentation :smirk:

Hey can you tell me whats causing the error, I am also stuck at the same problem

Or can you tell which part of documentation should I refer to?

Hi, @PraveenSingh.

Let me know if this helps.

Good luck with the assignment :slight_smile:

Yup it worked!
Thanks for the suggestion.:grinning:

1 Like