C5, W1 Jazz Impro

I can’t figure out how the function djmodel () knows that it should use the data stored in X to train the model.

Yes, the input is defined as follows: X = Input(shape=(Tx, n_values)) But for me it is only a “placeholder” / a mask that specifies the shape. Or am I wrong and the fact that the name X is used specifies that the input data should be taken from X?

I can also see that history = model.fit([X, a0, c0], list(Y), epochs=100, verbose = 0) uses X as an argument. But how do both of them (i.e. djmodel and model.fit) know that they should use the same X? Is it only based on the fact that in both of the cases the same letter X is used?

Maybe the code is a little too subtle, but the actual training happens in this cell:

history = model.fit([X, a0, c0], list(Y), epochs=100, verbose = 0)

That specifies the input data. The previous logic you are referring to just defines the structure of the model. It is the “fit()” method of the model that performs the training.

1 Like

The key to understanding how this assignment works is that LSTM_cell() is a global object:

  • It’s used by djmodel() during training,
  • And it’s used by music_inference_model() when making new music predictions.