The two models in the Jazz assignment

I am confused about the designation of the two models in the Jazz assignment (Week 1 of Course 5) and their usage:

  1. Where in the code is the trained djmodel used?
  2. Why do we need the inference_model? Where in the code do we train this model or read pre-trained parameters for it?
1 Like

Hi Meir,

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.

Hope this answers your question…

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?

Hi Meir,

My understanding is that you use the weights learned by djmodel in the inference_model(the LSTM_cell, densor…) maybe someone can confirm…

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

1 Like