Course 5 Week 1 Assignment 3

I have issue to follow the following step:
Exercise 2 - music_inference_model
2.D: Convert the last output into a new input for the next time step. You will do this in 2 substeps:
Get the index of the maximum value of the predicted output using tf.math.argmax along the last axis.
Convert the index into its n_values-one-hot encoding using tf.one_hot.

My code
x = tf.math.argmax(output, axis=-1)
x = tf.one_hot(x)
always has ValueError: Can’t convert Python sequence with mixed types to Tensor.
Pls advise!

1 Like

Hi @swe ,

In the tf.math.argmax() call, axis should be set to 1 to indicate column.

1 Like

I made a typo causing this error, which wasted my 2 hours.

What was dept in tf.one_hot(x,_?) ?

The depth must match the number of the output units of the densor densor.units

1 Like