C5 W3 A1: "AssertionError: Error in test. The lists contain a different number of elements"

I am working on “Neural_machine_translation_with_attention_v4a”, and in Exerciese 2, I got an error message for “UNIT TEST 1”. “UNIT TEST 2” is a pass. What could go wrong?

[['InputLayer', [(None, 30, 37)], 0], ['InputLayer', [(None, 64)], 0], ['Bidirectional', (None, 30, 64), 17920], ['RepeatVector', (None, 30, 64), 0, 30], ['Concatenate', (None, 30, 128), 0], ['Dense', (None, 30, 10), 1290, 'tanh'], ['Dense', (None, 30, 1), 11, 'relu'], ['Activation', (None, 30, 1), 0], ['Dot', (None, 1, 64), 0], ['InputLayer', [(None, 64)], 0], ['LSTM', [(None, 64), (None, 64), (None, 64)], 33024, [(None, 1, 64), (None, 64), (None, 64)], 'tanh'], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['RepeatVector', (None, 30, 64), 0, 30], ['Dense', (None, 11), 715, 'softmax']]

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-27-1492e4d59c1c> in <module>
     34 
     35 
---> 36 modelf_test(modelf)

<ipython-input-27-1492e4d59c1c> in modelf_test(target)
     31     assert len(model.outputs) == 10, f"Wrong output shape. Expected 10 != {len(model.outputs)}"
     32 
---> 33     comparator(summary(model), expected_summary)
     34 
     35 

~/work/W3A1/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,

You posted in the wrong specialization, and I don’t have the option to change it to the correct one.

Overall, it seems your implementation of the exercise is incorrect: the learner and instructor lists should have the same number of elements. Check how you are building them up…

Hi Gent,

I am so grateful for your reply. Am I posting it in the wrong place? Sorry, I do not know where and how should I post it.

This is my last code test, and then I would get the deep learning certificate. I understand the concept, however, I did not know where it goes wrong, my model len(model.outputs) is 10, and am I expecting 10?

I passed UNIT TEST 2, but failed UNIT TEST 2. Am I allow to post my code here for you to review.

You should post under the deep learning specialization posts!

I can have a look at your code though in private! Send me a copy in private.

I’ll move the thread to the correct forum area.

1 Like

@weiweichu have you solved the problem?

1 Like

Yes, Problem solved, it is in my other line of code, Exercise 1.

1 Like