The djmodel is used for training so you use the ground truth lables (i.e. x → Note sequence, Y → Note sequence shifted one note to the left). You use this model in cell 7 model = djmodel(Tx=30, LSTM_cell=LSTM_cell, densor=densor, reshaper=reshaper)
On the other hand, you use your inference model for prediction where the last output is the input for the new step.
That was exactly my question. Namely, djmodel is trained, but is not used for predictions. So, the question arises: “if we don’t use this model to make predictions, then what did we train it for?”
And the opposite question for the inference_model. Namely, how can we use a model for predictions without having trained it first?
@juancopi81 is right. The models created by two functions are sharing the actual layer object instances.
LSTM_cell and densor are global variables that are passed to both functions. The djmodel() function creates a model that trains these layers. After that model is compiled and fit, the layers have learned to recognize the jazz patterns. These same layer instances are then passed to music_inference_model() function which uses them to predict the music notes.