Improvise a Jazz Solo with an LSTM Network v4

Hey All. I am a little stuck on Exercise 2 of the Jazz solo assignment in week 1. I get this assertion error and I dont know what i means.

When i run :
inference_model = music_inference_model(LSTM_cell, densor, Ty = 50)

*I get the following : *
WARNING:tensorflow:Functional inputs must come from tf.keras.Input (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to “functional_29” was not an Input tensor, it was generated by layer repeat_vector_430.
Note that input tensors are instantiated via tensor = tf.keras.Input(shape).
The tensor that caused the issue was: repeat_vector_430/Tile:0
WARNING:tensorflow:Functional inputs must come from tf.keras.Input (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to “functional_29” was not an Input tensor, it was generated by layer lstm_7.
Note that input tensors are instantiated via tensor = tf.keras.Input(shape).
The tensor that caused the issue was: lstm_7/PartitionedCall_133:0
WARNING:tensorflow:Functional inputs must come from tf.keras.Input (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to “functional_29” was not an Input tensor, it was generated by layer lstm_7.
Note that input tensors are instantiated via tensor = tf.keras.Input(shape).
The tensor that caused the issue was: lstm_7/PartitionedCall_133:3

---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
in
----> 1 inference_model = music_inference_model(LSTM_cell, densor, Ty = 50)

in music_inference_model(LSTM_cell, densor, Ty)

  • 57 *
    
  • 58     # Step 3: Create model instance with the correct "inputs" and "outputs" (≈1 line)*
    

—> 59 inference_model = Model(inputs=[x, a, c], outputs=outputs)

  • 60 *
    
  • 61     ### END CODE HERE ###*
    

*/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in new(cls, *args, *kwargs)

  • 240 # Functional model*
  • 241 from tensorflow.python.keras.engine import functional # pylint: disable=g-import-not-at-top*
    *–> 242 return functional.Functional(*args, *kwargs)
  • 243 else:*
  • 244 return super(Model, cls).new(cls, *args, *kwargs)

*/opt/conda/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, *kwargs)

  • 455 self._self_setattr_tracking = False # pylint: disable=protected-access*
  • 456 try:*
    *–> 457 result = method(self, *args, *kwargs)
  • 458 finally:*
  • 459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access*

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in init(self, inputs, outputs, name, trainable)

  • 113 # ‘arguments during initialization. Got an unexpected argument:’)*
  • 114 super(Functional, self).init(name=name, trainable=trainable)*
    → 115 self._init_graph_network(inputs, outputs)
  • 116 *
  • 117 @trackable.no_automatic_dependency_tracking*

*/opt/conda/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, *kwargs)

  • 455 self._self_setattr_tracking = False # pylint: disable=protected-access*
  • 456 try:*
    *–> 457 result = method(self, *args, *kwargs)
  • 458 finally:*
  • 459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access*

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in _init_graph_network(self, inputs, outputs)

  • 182 # It’s supposed to be an input layer, so only one node*
  • 183 # and one tensor output.*
    → 184 assert node_index == 0
  • 185 assert tensor_index == 0*
  • 186 self._input_layers.append(layer)*

AssertionError:

I have uploaded the notebook.

Thanks
{moderator edit - notebook attachment removed}

In music_inference_model, you have defined the returned model this way:

inference_model = Model(inputs=[x, a, c], outputs=outputs)

That is incorrect, because the inputs you give are just the latest versions of those variables. The point is that you start from the initial values when you define the complete model, right?

Yeah thats true.
I am still trying to get my head around these algorithm architectures. Appreciate the help sir

i am not getting any clarity about the algorithm i dont know whether it is wrong or right

Hello Kandoori,

What part of the algorithm were you not able to understand. Please let us know. Thanks.