C5_W1_A3 Exercise 1 Jazz Solo djmodel

Hi, I think followed all the correct formats, syntax but my code gives error :

    # Step 1: Create empty list to append the outputs while you iterate (≈1 line)
    outputs = []
    # Step 2: Loop over tx
    for t in range(1,Tx):
        # Step 2.A: select the "t"th time step vector from X. 
        x = X[:,t,:]
        # 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(inputs=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"
    # Step 3: Create model instance
    model = Model(inputs=[X, a0, c0], outputs=outputs)
    ### END CODE HERE ###
AssertionError                            Traceback (most recent call last)
<ipython-input-8-8897d013117d> in <module>
      1 # UNIT TEST
      2 output = summary(model)
----> 3 comparator(output, djmodel_out)

~/work/W1A3/test_utils.py in comparator(learner, instructor)
     18 def comparator(learner, instructor):
     19     if len(learner) != len(instructor):
---> 20         raise AssertionError("Error in test. The lists contain a different number of elements")
     21     for index, a in enumerate(instructor):
     22         b = learner[index]

AssertionError: Error in test. The lists contain a different number of elements

1 Like

Hi @rameshgopalan ,

The for loop should be just in range(Tx).

1 Like

Yes, the hint to change to range(Tx) fixed my issue. Thanks to mentor Kic

1 Like

I faced the same problem and @Kic advice helped to solve the issue.
But the reason I faced this problem is because it is written in the instructions to loop t=(1, …, Tx).
I’m wondering if you can update the instructions please (for future generations).
Thank you in advance.