Help! function summary() failed on the model returned by music_inference_model()


For programming assignment 3 of week 1 (Improvise_a_Jazz_Solo_with_an_LSTM_Network_v4), exercise 2:

The model is successfully built:
inference_model = music_inference_model(LSTM_cell, densor, Ty = 50)

inference_summary = summary(inference_model) has error:

AttributeError                            Traceback (most recent call last)
<ipython-input-16-c395f100af16> in <module>
      1 # UNIT TEST
----> 2 inference_summary = summary(inference_model)
      3 comparator(inference_summary, music_inference_model_out)

~/work/W1A3/ in summary(model)
     36     result = [ ]
     37     for layer in model.layers:
---> 38         descriptors = [layer.__class__.__name__, layer.output_shape, layer.count_params()]
     39         if (type(layer) == Conv2D):
     40             descriptors.append(layer.padding)

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

AttributeError: The layer "lstm" 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.

Search the forum for the term “multiple inbound nodes”. You’ll find a lot of discussion about this issue.

1 Like

My understanding is: since the model is successfully built, it should be a valid model. That is, the summary function should work. Is there any bug in the library?

There is more likely a bug in your code.

Can you offer some proof that “the model is successfully built”?

Oh, I found the bug. Thanks. But what I do not understand is: inference_model.summary() returns expected results.