I am getting error in the music inference part and predict and sample part of the assignment Improvise_a_Jazz_Solo_with_an_LSTM_Network_v4

May some one figure out? I am also attaching the images here include the code and error.

First, please do not paste your code.

For your error, please double check the guidance in a Jupyter notebook.

Get the index of the maximum value of the predicted output using tf.math.argmax along the last axis.

Dear Sir,
May you please tell me " Get the index of the maximum value of the predicted output using tf.math.argmax along the last axis.", how to do this?

If you look at tf.math.argmax,
you see one parameter, “axis”. What we want to set is the last axis. Python has a good way to do that. That’s “-1”. Actually, “-1” is used at the several cases and useful. (axis=0 is the first axis.)

Dear Sir,
I think that axis=1 is for last axis.

It depends on the test data. It may work for this particular test case. But, in some cases, axis=1 may not be “the last” one if the dimension of data is more than 3. To make our logic woks generally, setting “-1” is much safer than setting a fixed axis.

Thanks a lot, sir for your help.

Since the grader always uses a different data set than the notebook, it’s not a safe assumption that the number of axes are the same.