# Course 5 wk 1 programming assignment 3 exercise 2

AssertionError Traceback (most recent call last)
in
3 # UNIT TEST
4 inference_summary = summary(inference_model)
----> 5 comparator(inference_summary, music_inference_model_out)

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

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

hello:D im recieving the above error for the music_inference_model(LSTM_cell, densor, Ty=100): .

im assuming that for my summary differs from the summary of music_inference_model_out. however,i did get ```
Total params: 45,530
Trainable params: 45,530
Non-trainable params: 0

The `AssertionError` suggests a mismatch in lengths between `inference_summary` and `music_inference_model_out`. To resolve this, ensure both lists are of the same type and inspect them by printing their lengths and values. This will help you identify the source of your problem!

Hope it helps! Feel free to ask if you need further assistance.

hello thank you so much but i am not able to figure out why my len and values are different
when i used len for the `music_inference_model_out` . i have a lenght of 152 while for the inference summary i have 54.

also when i print(music_inference_model_out)
i got this ,

[[‘InputLayer’, [(None, 1, 90)], 0], [‘InputLayer’, [(None, 64)], 0], [‘InputLayer’, [(None, 64)], 0], [‘LSTM’, [(None, 64), (None, 64), (None, 64)], 39680, [(None, 1, 90), (None, 64), (None, 64)], ‘tanh’], [‘Dense’, (None, 90), 5850, ‘softmax’], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1], [‘TensorFlowOpLayer’, [(None,)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘RepeatVector’, (None, 1, 90), 0, 1]]

and when i print(inference_summary), i got this

Model: “functional_3”

# Layer (type) Output Shape Param # Connected to

input_2 (InputLayer) [(None, 1, 90)] 0

a0 (InputLayer) [(None, 64)] 0

c0 (InputLayer) [(None, 64)] 0

lstm (LSTM) [(None, 64), (None, 39680 input_2[0][0]
a0[0][0]
c0[0][0]
repeat_vector[0][0]
lstm[30][1]
lstm[30][2]
repeat_vector_1[0][0]
lstm[31][1]
lstm[31][2]
repeat_vector_2[0][0]
lstm[32][1]
lstm[32][2]
repeat_vector_3[0][0]
lstm[33][1]
lstm[33][2]
repeat_vector_4[0][0]
lstm[34][1]
lstm[34][2]
repeat_vector_5[0][0]
lstm[35][1]
lstm[35][2]
repeat_vector_6[0][0]
lstm[36][1]
lstm[36][2]
repeat_vector_7[0][0]
lstm[37][1]
lstm[37][2]
repeat_vector_8[0][0]
lstm[38][1]
lstm[38][2]
repeat_vector_9[0][0]
lstm[39][1]
lstm[39][2]
repeat_vector_10[0][0]
lstm[40][1]
lstm[40][2]
repeat_vector_11[0][0]
lstm[41][1]
lstm[41][2]
repeat_vector_12[0][0]
lstm[42][1]
lstm[42][2]
repeat_vector_13[0][0]
lstm[43][1]
lstm[43][2]
repeat_vector_14[0][0]
lstm[44][1]
lstm[44][2]
repeat_vector_15[0][0]
lstm[45][1]
lstm[45][2]
repeat_vector_16[0][0]
lstm[46][1]
lstm[46][2]
repeat_vector_17[0][0]
lstm[47][1]
lstm[47][2]
repeat_vector_18[0][0]
lstm[48][1]
lstm[48][2]
repeat_vector_19[0][0]
lstm[49][1]
lstm[49][2]
repeat_vector_20[0][0]
lstm[50][1]
lstm[50][2]
repeat_vector_21[0][0]
lstm[51][1]
lstm[51][2]
repeat_vector_22[0][0]
lstm[52][1]
lstm[52][2]
repeat_vector_23[0][0]
lstm[53][1]
lstm[53][2]
repeat_vector_24[0][0]
lstm[54][1]
lstm[54][2]
repeat_vector_25[0][0]
lstm[55][1]
lstm[55][2]
repeat_vector_26[0][0]
lstm[56][1]
lstm[56][2]
repeat_vector_27[0][0]
lstm[57][1]
lstm[57][2]
repeat_vector_28[0][0]
lstm[58][1]
lstm[58][2]
repeat_vector_29[0][0]
lstm[59][1]
lstm[59][2]
repeat_vector_30[0][0]
lstm[60][1]
lstm[60][2]
repeat_vector_31[0][0]
lstm[61][1]
lstm[61][2]
repeat_vector_32[0][0]
lstm[62][1]
lstm[62][2]
repeat_vector_33[0][0]
lstm[63][1]
lstm[63][2]
repeat_vector_34[0][0]
lstm[64][1]
lstm[64][2]
repeat_vector_35[0][0]
lstm[65][1]
lstm[65][2]
repeat_vector_36[0][0]
lstm[66][1]
lstm[66][2]
repeat_vector_37[0][0]
lstm[67][1]
lstm[67][2]
repeat_vector_38[0][0]
lstm[68][1]
lstm[68][2]
repeat_vector_39[0][0]
lstm[69][1]
lstm[69][2]
repeat_vector_40[0][0]
lstm[70][1]
lstm[70][2]
repeat_vector_41[0][0]
lstm[71][1]
lstm[71][2]
repeat_vector_42[0][0]
lstm[72][1]
lstm[72][2]
repeat_vector_43[0][0]
lstm[73][1]
lstm[73][2]
repeat_vector_44[0][0]
lstm[74][1]
lstm[74][2]
repeat_vector_45[0][0]
lstm[75][1]
lstm[75][2]
repeat_vector_46[0][0]
lstm[76][1]
lstm[76][2]
repeat_vector_47[0][0]
lstm[77][1]
lstm[77][2]
repeat_vector_48[0][0]
lstm[78][1]
lstm[78][2]

dense (Dense) (None, 90) 5850 lstm[30][1]
lstm[31][1]
lstm[32][1]
lstm[33][1]
lstm[34][1]
lstm[35][1]
lstm[36][1]
lstm[37][1]
lstm[38][1]
lstm[39][1]
lstm[40][1]
lstm[41][1]
lstm[42][1]
lstm[43][1]
lstm[44][1]
lstm[45][1]
lstm[46][1]
lstm[47][1]
lstm[48][1]
lstm[49][1]
lstm[50][1]
lstm[51][1]
lstm[52][1]
lstm[53][1]
lstm[54][1]
lstm[55][1]
lstm[56][1]
lstm[57][1]
lstm[58][1]
lstm[59][1]
lstm[60][1]
lstm[61][1]
lstm[62][1]
lstm[63][1]
lstm[64][1]
lstm[65][1]
lstm[66][1]
lstm[67][1]
lstm[68][1]
lstm[69][1]
lstm[70][1]
lstm[71][1]
lstm[72][1]
lstm[73][1]
lstm[74][1]
lstm[75][1]
lstm[76][1]
lstm[77][1]
lstm[78][1]
lstm[79][1]

repeat_vector (RepeatVector) (None, 1, 90) 0 dense[30][0]

repeat_vector_1 (RepeatVector) (None, 1, 90) 0 dense[31][0]

repeat_vector_2 (RepeatVector) (None, 1, 90) 0 dense[32][0]

repeat_vector_3 (RepeatVector) (None, 1, 90) 0 dense[33][0]

repeat_vector_4 (RepeatVector) (None, 1, 90) 0 dense[34][0]

repeat_vector_5 (RepeatVector) (None, 1, 90) 0 dense[35][0]

repeat_vector_6 (RepeatVector) (None, 1, 90) 0 dense[36][0]

repeat_vector_7 (RepeatVector) (None, 1, 90) 0 dense[37][0]

repeat_vector_8 (RepeatVector) (None, 1, 90) 0 dense[38][0]

repeat_vector_9 (RepeatVector) (None, 1, 90) 0 dense[39][0]

repeat_vector_10 (RepeatVector) (None, 1, 90) 0 dense[40][0]

repeat_vector_11 (RepeatVector) (None, 1, 90) 0 dense[41][0]

repeat_vector_12 (RepeatVector) (None, 1, 90) 0 dense[42][0]

repeat_vector_13 (RepeatVector) (None, 1, 90) 0 dense[43][0]

repeat_vector_14 (RepeatVector) (None, 1, 90) 0 dense[44][0]

repeat_vector_15 (RepeatVector) (None, 1, 90) 0 dense[45][0]

repeat_vector_16 (RepeatVector) (None, 1, 90) 0 dense[46][0]

repeat_vector_17 (RepeatVector) (None, 1, 90) 0 dense[47][0]

repeat_vector_18 (RepeatVector) (None, 1, 90) 0 dense[48][0]

repeat_vector_19 (RepeatVector) (None, 1, 90) 0 dense[49][0]

repeat_vector_20 (RepeatVector) (None, 1, 90) 0 dense[50][0]

repeat_vector_21 (RepeatVector) (None, 1, 90) 0 dense[51][0]

repeat_vector_22 (RepeatVector) (None, 1, 90) 0 dense[52][0]

repeat_vector_23 (RepeatVector) (None, 1, 90) 0 dense[53][0]

repeat_vector_24 (RepeatVector) (None, 1, 90) 0 dense[54][0]

repeat_vector_25 (RepeatVector) (None, 1, 90) 0 dense[55][0]

repeat_vector_26 (RepeatVector) (None, 1, 90) 0 dense[56][0]

repeat_vector_27 (RepeatVector) (None, 1, 90) 0 dense[57][0]

repeat_vector_28 (RepeatVector) (None, 1, 90) 0 dense[58][0]

repeat_vector_29 (RepeatVector) (None, 1, 90) 0 dense[59][0]

repeat_vector_30 (RepeatVector) (None, 1, 90) 0 dense[60][0]

repeat_vector_31 (RepeatVector) (None, 1, 90) 0 dense[61][0]

repeat_vector_32 (RepeatVector) (None, 1, 90) 0 dense[62][0]

repeat_vector_33 (RepeatVector) (None, 1, 90) 0 dense[63][0]

repeat_vector_34 (RepeatVector) (None, 1, 90) 0 dense[64][0]

repeat_vector_35 (RepeatVector) (None, 1, 90) 0 dense[65][0]

repeat_vector_36 (RepeatVector) (None, 1, 90) 0 dense[66][0]

repeat_vector_37 (RepeatVector) (None, 1, 90) 0 dense[67][0]

repeat_vector_38 (RepeatVector) (None, 1, 90) 0 dense[68][0]

repeat_vector_39 (RepeatVector) (None, 1, 90) 0 dense[69][0]

repeat_vector_40 (RepeatVector) (None, 1, 90) 0 dense[70][0]

repeat_vector_41 (RepeatVector) (None, 1, 90) 0 dense[71][0]

repeat_vector_42 (RepeatVector) (None, 1, 90) 0 dense[72][0]

repeat_vector_43 (RepeatVector) (None, 1, 90) 0 dense[73][0]

repeat_vector_44 (RepeatVector) (None, 1, 90) 0 dense[74][0]

repeat_vector_45 (RepeatVector) (None, 1, 90) 0 dense[75][0]

repeat_vector_46 (RepeatVector) (None, 1, 90) 0 dense[76][0]

repeat_vector_47 (RepeatVector) (None, 1, 90) 0 dense[77][0]

# repeat_vector_48 (RepeatVector) (None, 1, 90) 0 dense[78][0]

Total params: 45,530
Trainable params: 45,530
Non-trainable params: 0

inference_summary = summary(inference_model)

print( len(inference_summary))

Sorry, but it’s too hard to parse all that voluminous output. Looking for a needle in the proverbial haystack. I think we need to see your code, but (of course) we can’t do that here in public. I will send you a DM about how to proceed with that.

1 Like