Course 2, Week 3, Exercise 3 - one_hot_matrix passes tests but new_y_test returns error

Hello,

I have implemented the one_hot_matrix function and it passes all tests. However when I run the next cell I get the following error;

Cell:

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

Error:

ValueError: Shape must be rank 1 but is rank 0 for β€˜{{node Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](one_hot, Reshape/shape)’ with input shapes: [6], .

I have spent quite a while figuring out what went wrong. This blocks exercise 6 as compute_total_loss_test requires new_y_train as an input.

Thanks in advance.

After restarting the kernal and clearing all output, rerunning all cells and a bit of debugging I see the following. It looks like there is no data in my y_train and y_test. I do not believe I have made any changes to this. Any ideas what could have happened?

solved. I did not reshape correctly. had shape=C instead of shape=[C,]

2 Likes

It’s great to hear that you found the solution under your own power. Thanks for confirming!