C5 Wk3 A1, Exercise 2

I don’t know why the code does not work. It looked pretty simple and to me it seemed it makes sense…

AttributeError Traceback (most recent call last)
in
33
34
—> 35 modelf_test(modelf)

in modelf_test(target)
12 model = target(Tx, Ty, n_a, n_s, len_human_vocab, len_machine_vocab)
13
—> 14 print(summary(model))
15
16

~/work/W3A1/test_utils.py in summary(model)
34 result =
35 for layer in model.layers:
—> 36 descriptors = [layer.class.name, layer.output_shape, layer.count_params()]
37 if (type(layer) == Conv2D):
38 descriptors.append(layer.padding)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in output_shape(self)
2190 'ill-defined for the layer. ’
2191 'Use get_output_shape_at(node_index)
→ 2192 ‘instead.’ % self.name)
2193
2194 @property

AttributeError: The layer “concatenate” has multiple inbound nodes, with different output shapes. Hence the notion of “output shape” is ill-defined for the layer. Use get_output_shape_at(node_index) instead.

3 Likes

Hi @user585

You can try using the get_output_shape_at(node_index) method instead of directly accessing the output_shape attribute. This method allows you to get the output shape at a specific node index.

Regards
Muhammad John Abbas

1 Like

:slight_smile:
I finally found out that the code needed re-start of the whole note :blush:

6 Likes

Every time you modify anything in the assignments that use an LSTM layer, you must restart the kernel and re-run the notebook.

This is because the LSTM_cell() is usually a global variable, and changes you make to the notebook after the LSTM is created will not apply to the original object.

3 Likes

I wish this is highlighted in the notebooks. Ran into this multiple times.

1 Like

Ran into this as well, thanks for the heads up! :+1:

1 Like

i tried to restart the kernel and run all the cells again but it didn’t work

1 Like

Hi @Mohammad_Ayman ,

Please start a new query with error message/traceback so that community members and mentors can effectively diagnose what the problem might be and offer solutions.

1 Like

I don’t know how to start a new query

Hi @Mohammad_Ayman

Please check out this link to the ‘How to use the Forum