Course 5: Week 1: Music inference model (LSTM)

PLEASE FIX this:
Add: LSTM_cell = LSTM(n_a, return_state = True)
Before:
inference_model = music_inference_model(LSTM_cell, densor, Ty = 50)

I just spent several days on this.

PS. love the courses.

3 Likes

Yes I tried for 2 days but this code worked. Thank you @SteveRegis

I agree this exercise was confusing because of too many information into one exercise and having to scroll up and down many times to read the contents. This exercise could have been divided into two parts.

1 Like

Thank you very much my man :slight_smile:

1 Like

Thank you for this tip. It really helped as it would have taken a lot of time if I had not seen your post.

1 Like

It didnt solve my problem

1 Like

Thanks for your solution. I have the same problem and your answer helped me to solve it. But this is weird to me. In the music_inference_model, I think we should use the trained LSTM_cell from the previous section. However, based on what you suggest and my understanding, we create a new LSTM block that needs to train and use for inference. Can you correct me and explain your idea a little more?
Thanks

2 Likes

That doesn’t work for me.
Although it is possible to skip the whole “Restart the Kernel and RUn all” by just running the code block :

n_values = 90 # number of music values
reshaper = Reshape((1, n_values))                  # Used in Step 2.B of djmodel(), below
LSTM_cell = LSTM(n_a, return_state = True)         # Used in Step 2.C
densor = Dense(n_values, activation='softmax')     # Used in Step 2.D

That is on the beginning on the assignment. This helps save time, but still doesn’t solve the main problem with the shape of x

Welcome to the community!

First, please note that you’ve replied to a thread that has been cold for three years. Most of the mentors and learners don’t stick around long enough to notice you’ve added a late reply.

The challenge with most of the assignments in Course 5 is that the LSTM objects are almost always global variables. So after a object is created, if in debugging your code you modify that object, then the internal state of the notebook can become inconsistent, yielding errors that can be extremely difficult to debug.

So the first line-of-defense for that is “restart the kernel and run all the cells again”.

If you’re aware of the issues and are willing to use another method, you’re certainly welcome to use it.

2 Likes