Course5 week1 assignment3 exercise2 lstm error

In “Jazz Solo with an LSTM Network” in “UNQ_C2: music_inference_model”, I get error from unit test cell states as follow:
“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.”
Arguments of the LSTM_cell are exactly the same as in “UNQ_C1:djmodel”.
It works in C1 but not in C2, where parameter like x,a,c seemingly the same things.
I don’t know why I have error and how to fix it. Please help.

Hello @Surawut_Pawutinan,

The problem is likely to be with the variable x which is the inbound node for the lstm layer. According to the error message, x is inconsistent among the multiple calls by the loop. Note that in the exercise, we will need to modify x a couple of times inside the loop, so a wrong modification can cause the problem.

I suggest you to add one line right after the for loop starts:

    # Step 2: Loop over Ty and generate a value at every time step
    for t in range(Ty):
        print(x) # added for investigation only, to be removed afterwards or grading might be affected

Then when you run this cell
image

Multiple print-lines will show up, where the first one should be

Tensor("input:0", shape=(None, 1, 90), dtype=float32)

Note that the shape of x is initially (None, 1, 90) and it has to stay the same throughout all the print-lines. If it becomes different, then one of the modifications to x has gone wrong. To pinpoint which modification it is, simply add a few more print(x) in between every modification and find out where the “different shape” starts to show up. Then you will find the problematic line, and then you will need to figure out how to fix it with reference to the exercise’s description.

Lastly, don’t forget to remove all of the added print(x), since their existence can interfere with the autograder and can fail your submission.

Cheers,
Raymond

I just forgot axis=-1 in argmax, thanks.