DLS C5 W3 Ass1 - Stuck at the model.summary() code cell

Hello mentors,


I am stuck at the code cell in the notebook where it outputs the model summary.

This is the error I am getting. I have passed all the tests prior to this statement. Any help would be appreciated. I have also tried the troubleshooting note that is shown in the uploaded image.

Kshitij Sharma

Please check Step 3: Create model instance to see if you follows the instruction:
If you provided model name or other arguments as a 3rd argument, be sure to use keyword argument rather than position argument. For instance,

model = Model(intputs=my_inputs, outputs=my_outputs, name='my_model_name') # correct
model = Model(my_inputs, my_outputs, name='my_model_name') # correct
model = Model(my_inputs, my_outputs, 'my_model_name') # incorrect

Hi @edwardyu,
Thanks for the reply.

This is my code for step 3.
model = Model([[X, s, c], outputs])

If I write the below mentioned code I get an error:
model = Model([X, s, c], outputs)

First of all, model inputs and outputs are two separated arguments, that’s why you got model has not been built error, tensorflow takes it as only one argument, which is inputs, and loss of outputs.

The second one, the model inputs must be created by Input layer or functions. In your code, X is, but s and c are not, they are intermediate outputs of post_activation_LSTM_cell. Take a look at the instruction carefully, part of the inputs is initial state, rather than intermediate value.

Thank you, that helped. I am still not able to understand that why did we have to give inputs inside double square brackets. like [[X, s0, c0]]. Can you please explain this to me?


If there are multiple inputs, put them in a list, e.g., [inp1, inp2, inp3], double square brackets is not necessary. I guess tenserflow just squeezes its dimensions.

Dear Edwardyu,
I have followed the instruction: put X, s0 c0 to the inputs, and outputs value to ouputs. However, My model give the first input layer with shape [(none,64),0] and second input layer with shape [(none,30,37), 0] which is revered of the expected model. Could you please help me to solve the problem

Hi @Mrtranducdung ,

I try to reproduce your problem, but I can’t. Could you do me a favor to add a line like below, and check if the input_1 (may be different number if you run multiple times.) connected to bidirectional layer?

1 Like

Hi @edwardyu ,
I have added the line that you suggested. But my code can not reach that line. I got error as follow:

[[‘InputLayer’, [(None, 64)], 0], [‘InputLayer’, [(None, 30, 37)], 0], [‘RepeatVector’, (None, 30, 64), 0, 30], [‘Bidirectional’, (None, 30, 64), 17920], [‘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’], [‘Dense’, (None, 11), 715, ‘softmax’]]
Test failed at layer: 0
Expected value

[‘InputLayer’, [(None, 30, 37)], 0]

does not match the input value:

[‘InputLayer’, [(None, 64)], 0]

AssertionError Traceback (most recent call last)
34 model.summary()
—> 36 modelf_test(modelf)

in modelf_test(target)
31 assert len(model.outputs) == 10, f"Wrong output shape. Expected 10 != {len(model.outputs)}"
—> 33 comparator(summary(model), expected_summary)
34 model.summary()

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

AssertionError: Error in test

1 Like

Hi @Mrtranducdung ,

Finally, I reproduced the same problem as yours. It turns out the root cause is in UNQ_C1, which is one_step_attention. Please check following code snippet to make sure the order of its parameters.


Hi @edwardyu,
Thank you very much for your help. The problem is solved when i change the order of ‘a’ and ‘s_prev’.