DLS Course 5, Week 1, assignment 3,


After running the unit test of the djmodel, I get the following error message:

Test failed
Expected value

[‘Reshape’, (None, 1, 90), 0]

does not match the input value:

[‘TensorFlowOpLayer’, [(None, 90)], 0]

Even though the following code in the djmodel function gives the correct shapes:
x = X[:,0,:]
(None, 90)
x = reshaper(x)
(None, 1, 90)

please advise.

Thank you

please ignore. problem fixed

Glad that you solved the issue. Maybe it would be great if you share the error and the fix in case other students face the same issue :slight_smile:
Thanks and happy learning


1 Like

Please share how you fixed this, I have exactly the same problem. I have tried to restart the Kernel as was suggested in another thread.

The problem seems to arise in the last part of the code where I use

model = Model(inputs=[X, a0, c0], outputs=outputs)

is this correct?

Problem solved. I went back and read the hint for part 2D of the exercise carefully.

How did you resolve it?

Can you please tell me how you fixed this error?

Read “Step 2.D” instruction carefully.

after reading 2D carefully still could not resolve it. any other hint will be appreciated

1 Like

Step 2.D tells you some important things, along with the documentation of tensorflow:
tf.math.argmax  |  TensorFlow Core v2.5.0 tells us there’s an “axis” parameter. there’s also a mention of “axis” in the 2D hints.
tf.one_hot  |  TensorFlow Core v2.5.0 also mentions a depth parameter that could be important for the final shapes

Hope this helps and is vague enough to count as a “hint”

I am getting the same error. How did you resolve the error?

Thanks for your post. However, under 2.D I have the following hint:

2D. Dense layer

  • Propagate the LSTM’s hidden state through a dense+softmax layer using densor .

The answer to look at 2D more carefully is for problem 3 - Generating Music, not problem 2 - Building the Model. My answer is for problem 2 - Building the Model.

I got this exact same error but it had to do with my answer for 2C. Within the LSTM_cell function,
I set the initial state to [a0, c0]. However, that will only work for the first value of Tx and never gets updated after that. The variables a and c were initialized to a0 and c0 before the for loop. Once I changed the initial state to the correct variables, it worked.


You need not use the Lambda function of keras. Instead just mention x = (lambda x: x[:,t,:])(X)

This should resolve it

Thanks coyne44. This helped me to fix my error. initial state should be initialized using a and c