I’m having some trouble with performing step 2.A of the music_inference_model.
I get the following error message when I try to run the “inference_model” line in the cell below:
ValueError: Input 0 is incompatible with layer lstm: expected shape=(None, None, 90), found shape=[None, 1, 1]
(And it points to the LSTM line in the music_inference_model function)
I’ve seen others post their line of code for this segment of the function and stating that a kernel restarted solved the issue. My code is identical to those examples, however, I’ve tried multiple restarts and still this error message pops up.
Since defining ‘x’ is above the “START CODE HERE” and the comment above states that it should be done in one line, I’m feeling quite certain that I haven’t done any errors in defining the input for the LSTM layer.
Please, if anyone could assist me in solving this issue I would greatly appreciate it!
I’ve successfully completed the djmodel section of the assignment. My current problem is related to the music_inference_model function (Exercise 2).
Here is the section of music_inference_model that comes before the ### START CODE HERE ### line:
def music_inference_model(LSTM_cell, densor, Ty=100): """ Uses the trained "LSTM_cell" and "densor" from model() to generate a sequence of values.
Arguments:
LSTM_cell -- the trained "LSTM_cell" from model(), Keras layer object
densor -- the trained "densor" from model(), Keras layer object
Ty -- integer, number of time steps to generate
Returns:
inference_model -- Keras model instance
"""
# Get the shape of input values
n_values = densor.units
# Get the number of the hidden state vector
n_a = LSTM_cell.units
# Define the input of your model with a shape
x0 = Input(shape=(1, n_values))
# Define s0, initial hidden state for the decoder LSTM
a0 = Input(shape=(n_a,), name='a0')
c0 = Input(shape=(n_a,), name='c0')
a = a0
c = c0
x = x0`
As seen in the code snippet above, x is predefined to be x = x0 = Input(shape=(1, n_values)). I’m not making any changes to the input before passing it to LSTM_cell().
I “fixed” my problem. Had to start over by clicking the “get latest version”. In the end, I didn’t do anything really, just re-ran the code I had from the previous attempt and it worked…
A bit frustrating since I have spent some hours trying to fix the issue, with lots of debugging.
Well well, I have a better understanding of the code now at least
Click on ?Help button on the top right of your opened notebook, you will be presented with the ‘get latest version button’.
Please read the How to fresh your workspace item before getting the latest version of your notebook.
Hi,
I have the same problem, @TMosh . I’m passed the music_inference_model function. Everything looking good but when hitting the summary part I get the same error:
AttributeError: The layer “lstm” has multiple inbound nodes, with different output shapes. Hence the notion of “output shape” is ill-defined for the layer. Use get_output_shape_at(node_index) instead.
I followed the instructions above to refresh the notebook but nothing changed. I have the same dimension that my collegue:
this is x0:
Tensor(“input_2:0”, shape=(None, 1, 90), dtype=float32)
This is c0:
Tensor(“c0_1:0”, shape=(None, 64), dtype=float32)
This is a0:
Tensor(“a0_1:0”, shape=(None, 64), dtype=float32)