Course 5 Week 1 Assignment 3, Error in music_inference_model

I don’t know why but I keep getting this error in the music_inference_model, and it doesn’t go away even after restarting the kernels

AttributeError                            Traceback (most recent call last)
<ipython-input-32-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_1" 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.

I’m lost and don’t know what to do.

Hi @lolzone ,

This testcase picked up some error in your code. Please check the parameters passed to LSTM_cell() are correct. Refer to notes on step 2A to clarify.

1 Like

If you search the forum for the keywords “jazz problem”, you’ll find a lot of threads with tips.

I rechecked all the instructions and went through the forums, but none of them seemed to fix the issue. However the inference_model.summary seems to give the correct output even though the unit test is failing. I think I have followed the instructions correctly but the problem still persists. Any more hints?

I was receiving the same error despite my confidence in implementing the correct code. I didn’t consider restarting the kernel could work until I read you tried that. Thankfully, restarting worked for me (this time). Those “errors” that aren’t really errors (sigh) really test my patience (lol). I just don’t understand what’s going on behind scenes as to when/why restarting works, and how I might know when I need to without just trying it.

1 Like

The instructions for step 2.D say to use argmax “along the last axis”.
That means you need to include “axis = -1” in the arguments for argmax().

1 Like

One issue with the exercises is that they use a lot of global variables, so the sequence in which you run the cells is critical. Also, modifying a cell does not automatically re-compile it.

So if you’re jumping around inside the notebook, making a lot of changes to try to fix an error, it is very easy for the notebook to get its global variables into an unexpected state.

Restarting the kernel and re-running all of the cells is the simplest way to explain to students how to fix this.


Thanks a lot! Restarting the kernel and re-running all of the cells fix this problem.

Thanks, I thought I was going crazy :smiley: