Having trouble with Course2, wk3: TensorFlow Intro, Exercise 3-One_hot_matrix

Having a problem getting the sizings correct. Have been able to get into row, but not a column using the tf.one_hot(indices=label, depth=4, axis=0), [-1] ). Here is the result and error I am getting using this form. I would appreciate any hints on where to look fix this.

1 Like

It instructions it has been specified we have to consider last elements. In a list we move from left ryt we use 0- length of list but if we traverse ryt to left we start from -1. Go through the instructions again u will get the idea.

TF.one hot take two argument which are

  1. List which has to be one encoded
  2. Depth which is number of classses

It looks like your result is a 1D tensor, but it should be a 2D tensor with one column. The instructions tell you to use tf.reshape on the output of tf.one_hot to get the result into the shape that they specify.

1 Like

Some good advice pointing me in the right direction and a fresh set of eyes = problem found and resolved. Thank you both for the help!