W1 A3 Jazz Music music_inference_model

In this assignment, in 2.D, we have to convert the output from the previous LSTM cell into a new input for the current LSTM cell, and we are instructed to do this in 2 steps:

  • 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.

I am confused here, as to why we are instructed to find the index of the maximum value. If we will do this, then won’t we always sample the same music sequence. Why not we are choosing the index randomly proportional to their associated probabilities, just like the previous assignment, i.e., the dinosaur one.
Am I missing something?

That’s a good question, and I’ve wondered that myself.

I don’t know of any good reason. The notebook for the dinosaur names assignment says it uses random sampling “to make the results more interesting”.

Apparently, the author of the jazz music exercise was happy to have the code generate the same tune every time.

It would be interesting to use random sampling and see what happens.

Thanks a lot @TMosh for your reply. I thought I was missing something out in the Jazz Notebook!