Jazz Improvisation with LSTM getting an erro

for t in range(Tx):
    
    # Step 2.A: select the "t"th time step vector from X. 
    x = Lambda(lambda x: X[:,t,:])(X)
    # Step 2.B: Use reshaper to reshape x to be (1, n_values) (≈1 line)
    x = reshaper(x)
    # Step 2.C: Perform one step of the LSTM_cell
    a, _, c = LSTM_cell(x, initial_state=[a, c])
    # Step 2.D: Apply densor to the hidden state output of LSTM_Cell
    out = densor(a)
    # Step 2.E: add the output to "outputs"
    outputs.append(out)
# Step 3: Create model instance
model = Model(inputs=[X, a0, c0], outputs=outputs)
### END CODE HERE ###

output getting the blew error
[‘TensorFlowOpLayer’, [(None, 90)], 0]

does not match the input value:

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

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
2 output = summary(model)
----> 3 comparator(output, djmodel_out)

~/work/W1A3/test_utils.py in comparator(learner, instructor)
23 “\n\n does not match the input value: \n\n”,
24 colored(f"{a}", “red”))
—> 25 raise AssertionError(“Error in test”)
26 print(colored(“All tests passed!”, “green”))
27

AssertionError: Error in test

You do not need to use the Lambda function. Just x = X[:,t,:] is sufficient.

1 Like

thank you much …it worked

Hi Mosh, thanks it worked online, but when i run the same code offline in notebook, it gives a new error:

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
2 output = summary(model)
----> 3 comparator(output, djmodel_out)

…test_utils.py in comparator(learner, instructor)
26 “\n\n does not match the input value: \n\n”,
27 colored(f"{a}", “red”))
—> 28 raise AssertionError(“Error in test”)
29 print(colored(“All tests passed!”, “green”))
30

AssertionError: Error in test

Sorry, but I have no idea about how to run the notebook offline.