C2W3 - Exercise 3 - one_hot_matrix

Hi, I am struggling to finish my assignment because, just after running:
new_y_test = y_test.map(one_hot_matrix)
new_y_train = y_train.map(one_hot_matrix)

I got a long error message (which I can provide), and then, after running:
print(next(iter(new_y_test)))

I get the message: NameError: name ‘new_y_test’ is not defined

I already updated my notebook and ran again,… but the problem remains.

Maybe my one_hot function is not ok?
one_hot = tf.reshape(tf.one_hot(label, depth,axis = 0),shape = (4,))

any idea of what is going on?
thks!

HI @Rogelio ,
In your code “one_hot = …”, try not to give the dimension directly, instead try using the variable name for giving the dimension of your call to tf.reshape.

1 Like

Hi @D.h.r.u.m.i.l0790,
Your feed-back is great! I replaced the hard coded dimension with what I think is the right parameter. It now works! I can continue with my assignment. Thank you very much!

1 Like