Week 1 assignment 3

I do not understand what the purpose of using two functions as shown below. Cant, we only use the DJ model?
Screenshot 2022-09-27 094336

Screenshot 2022-09-27 094353
Also, why have we used the LSTM_cell instead of the Keras model LSTM? Is LSTM_cell the one we made the first assignment using numpy?
Screenshot 2022-09-27 094412

Hey @Mohammad_Hamza,
If you carefully look at the 2 functions, then you will find that both the functions implement the same structure for the model, however, the only difference (which is of paramount importance) is how the value that needs to be fed to the next cell (LSTM cell) is chosen.

When we are performing training, we have the true samples, and hence, we are feeding the true values to each of the cells, irrespective of what the previous cell predicts. This is how we have designed the djmodel function.

On the other hand, when we are performing inferencing, we don’t have the true samples. In fact, we don’t even know what to produce. We are just inferencing from our trained model, and we are hoping that the model would produce some jazz. And hence, in this case, we are feeding the values to the next cell, based on what the previous LSTM cell predicted, so that together these values can form some sort of jazz. And this is how we have designed the music_inference_model function

Prof Andrew taught about this in the lecture video entitled “Sampling novel sequences” in Week 1. So, you could watch the lecture video once more if you are still confused about this concept.

As for this, I would like to point out your attention towards:

LSTM_cell = LSTM(n_a, return_state = True)

I hope this answers your remaining query as well. Let me know if this helps.